From aea0b62a2633148761c45b722f9b2504e23e51a0 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 8 Mar 2020 09:03:05 +0000 Subject: [PATCH] Added complementary capability to TIM channel 4, some devices support it. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13402 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/hal/ports/STM32/LLD/TIMv1/hal_pwm_lld.c | 10 ++++++++++ os/hal/ports/STM32/LLD/TIMv1/stm32_tim.h | 1 + 2 files changed, 11 insertions(+) diff --git a/os/hal/ports/STM32/LLD/TIMv1/hal_pwm_lld.c b/os/hal/ports/STM32/LLD/TIMv1/hal_pwm_lld.c index b003ca970..eb6bebc7e 100644 --- a/os/hal/ports/STM32/LLD/TIMv1/hal_pwm_lld.c +++ b/os/hal/ports/STM32/LLD/TIMv1/hal_pwm_lld.c @@ -953,6 +953,16 @@ void pwm_lld_start(PWMDriver *pwmp) { default: ; } + switch (pwmp->config->channels[3].mode & PWM_COMPLEMENTARY_OUTPUT_MASK) { + case PWM_COMPLEMENTARY_OUTPUT_ACTIVE_LOW: + ccer |= STM32_TIM_CCER_CC4NP; + /* Falls through.*/ + case PWM_COMPLEMENTARY_OUTPUT_ACTIVE_HIGH: + ccer |= STM32_TIM_CCER_CC4NE; + /* Falls through.*/ + default: + ; + } } #endif /* STM32_PWM_USE_ADVANCED*/ diff --git a/os/hal/ports/STM32/LLD/TIMv1/stm32_tim.h b/os/hal/ports/STM32/LLD/TIMv1/stm32_tim.h index 4ab843d77..8f158fedc 100644 --- a/os/hal/ports/STM32/LLD/TIMv1/stm32_tim.h +++ b/os/hal/ports/STM32/LLD/TIMv1/stm32_tim.h @@ -279,6 +279,7 @@ #define STM32_TIM_CCER_CC3NP (1U << 11) #define STM32_TIM_CCER_CC4E (1U << 12) #define STM32_TIM_CCER_CC4P (1U << 13) +#define STM32_TIM_CCER_CC4NE (1U << 14) #define STM32_TIM_CCER_CC4NP (1U << 15) #define STM32_TIM_CCER_CC5E (1U << 16) #define STM32_TIM_CCER_CC5P (1U << 17)