AP_HAL_ChibiOS: allow option to enable ChibiOS features in bootloader

This commit is contained in:
Siddharth Purohit 2021-06-20 11:44:41 +05:30 committed by Andrew Tridgell
parent c18652f35a
commit 9b2359b34c
1 changed files with 16 additions and 3 deletions

View File

@ -839,7 +839,19 @@ def write_mcu_config(f):
# setup for bootloader build
if args.bootloader:
f.write('''
if get_config('FULL_CHIBIOS_BOOTLOADER', required=False, default=False):
# we got enough space to fit everything so we enable almost everything
f.write('''
#define HAL_BOOTLOADER_BUILD TRUE
#define HAL_USE_ADC FALSE
#define HAL_USE_EXT FALSE
#define HAL_USE_I2C FALSE
#define HAL_USE_PWM FALSE
#define HAL_NO_UARTDRIVER
#define CH_CFG_USE_DYNAMIC FALSE
''')
else:
f.write('''
#define HAL_BOOTLOADER_BUILD TRUE
#define HAL_USE_ADC FALSE
#define HAL_USE_EXT FALSE
@ -1347,7 +1359,9 @@ def write_UART_config(f):
f.write('#define AP_FEATURE_RTSCTS 1\n')
if OTG2_index is not None:
f.write('#define HAL_OTG2_UART_INDEX %d\n' % OTG2_index)
f.write('''
f.write('#define HAL_HAVE_DUAL_USB_CDC 1\n')
if env_vars.get('AP_PERIPH', 0) == 0:
f.write('''
#if HAL_NUM_CAN_IFACES
#ifndef HAL_OTG2_PROTOCOL
#define HAL_OTG2_PROTOCOL SerialProtocol_SLCAN
@ -1356,7 +1370,6 @@ def write_UART_config(f):
#define HAL_SERIAL%d_BAUD 115200
#endif
''' % (OTG2_index, OTG2_index))
f.write('#define HAL_HAVE_DUAL_USB_CDC 1\n')
f.write('#define HAL_UART_DEVICE_LIST %s\n\n' % ','.join(devlist))
if not need_uart_driver and not args.bootloader: