From 65c3d4ff20c20a2bda2155c15cbc8c48003791c7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 29 Oct 2019 08:17:31 +1100 Subject: [PATCH] HAL_ChibiOS: enable advanced timers if we have any N PWM channels --- libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index f2d86220db..53dbbcebe5 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -1192,6 +1192,7 @@ def write_PWM_config(f): f.write('\n') f.write('// PWM output config\n') groups = [] + have_complementary = False for t in sorted(pwm_timers): group = len(groups) + 1 n = int(t[3:]) @@ -1210,6 +1211,7 @@ def write_PWM_config(f): chan_list[chan - 1] = pwm - 1 if compl: chan_mode[chan - 1] = 'PWM_COMPLEMENTARY_OUTPUT_ACTIVE_HIGH' + have_complementary = True else: chan_mode[chan - 1] = 'PWM_OUTPUT_ACTIVE_HIGH' alt_functions[chan - 1] = p.af @@ -1252,6 +1254,8 @@ def write_PWM_config(f): alt_functions[0], alt_functions[1], alt_functions[2], alt_functions[3], pal_lines[0], pal_lines[1], pal_lines[2], pal_lines[3])) f.write('#define HAL_PWM_GROUPS %s\n\n' % ','.join(groups)) + if have_complementary: + f.write('#define STM32_PWM_USE_ADVANCED TRUE\n') def write_ADC_config(f):