HAL_ChibiOS: auto-enable CAN when pins are defined

This commit is contained in:
Andrew Tridgell 2018-03-01 17:38:10 +11:00
parent fed1579187
commit ebbd15ea17
3 changed files with 10 additions and 4 deletions

View File

@ -450,9 +450,6 @@ define AP_FEATURE_RTSCTS 1
# enable SBUS_OUT on IOMCU (if you have an IOMCU) # enable SBUS_OUT on IOMCU (if you have an IOMCU)
define AP_FEATURE_SBUS_OUT 1 define AP_FEATURE_SBUS_OUT 1
# enable UAVCAN support if you have setup some CAN devices above
define HAL_WITH_UAVCAN 1
# now setup the default battery pins driver analog pins and default # now setup the default battery pins driver analog pins and default
# scaling for the power brick # scaling for the power brick
define HAL_BATT_VOLT_PIN 2 define HAL_BATT_VOLT_PIN 2

View File

@ -277,6 +277,10 @@ def get_config(name, column=0, required=True, default=None, type=None):
error("Badly formed config value %s (got %s)" % (name, ret)) error("Badly formed config value %s (got %s)" % (name, ret))
return ret return ret
def enable_can(f):
'''setup for a CAN enabled board'''
f.write('#define HAL_WITH_UAVCAN 1\n')
env_vars['HAL_WITH_UAVCAN'] = '1'
def write_mcu_config(f): def write_mcu_config(f):
'''write MCU config defines''' '''write MCU config defines'''
@ -303,6 +307,8 @@ def write_mcu_config(f):
f.write('#define HAL_USE_SERIAL_USB TRUE\n') f.write('#define HAL_USE_SERIAL_USB TRUE\n')
if 'OTG2' in bytype: if 'OTG2' in bytype:
f.write('#define STM32_USB_USE_OTG2 TRUE\n') f.write('#define STM32_USB_USE_OTG2 TRUE\n')
if 'CAN1' in bytype or 'CAN2' in bytype or 'CAN3' in bytype:
enable_can(f)
# write any custom STM32 defines # write any custom STM32 defines
for d in alllines: for d in alllines:
if d.startswith('STM32_'): if d.startswith('STM32_'):

View File

@ -12,8 +12,11 @@ undef USART3
undef USART3_TX undef USART3_TX
undef USART3_RX undef USART3_RX
undef CAN1 undef CAN1
undef CAN1_RX
undef CAN1_TX
undef CAN2 undef CAN2
undef HAL_WITH_UAVCAN undef CAN2_RX
undef CAN2_TX
undef IOMCU_UART undef IOMCU_UART
undef AP_FEATURE_SBUS_OUT undef AP_FEATURE_SBUS_OUT
undef HAL_OS_FATFS_IO undef HAL_OS_FATFS_IO