I have a few bugfixes in our ChibiOS (git) tree that I would like to mainline. Here is the first one, a bug in the PWM driver.
Code: Select all
From: Patrick Spieler <stapelzeiger@gmail.com>
Date: Fri, 1 May 2015 17:03:29 +0200
Subject: [PATCH] fix pwm driver enable notification function
- bit mask was not correct (not inverted)
- the flag must be cleared before enabling interrupts to have the
desired effect
---
os/hal/ports/STM32/LLD/TIMv1/pwm_lld.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/os/hal/ports/STM32/LLD/TIMv1/pwm_lld.c b/os/hal/ports/STM32/LLD/TIMv1/pwm_lld.c
index c033035..f110802 100644
--- a/os/hal/ports/STM32/LLD/TIMv1/pwm_lld.c
+++ b/os/hal/ports/STM32/LLD/TIMv1/pwm_lld.c
@@ -755,8 +755,8 @@ void pwm_lld_enable_periodic_notification(PWMDriver *pwmp) {
/* If the IRQ is not already enabled care must be taken to clear it,
it is probably already pending because the timer is running.*/
if ((dier & STM32_TIM_DIER_UIE) == 0) {
+ pwmp->tim->SR &= ~STM32_TIM_SR_UIF;
pwmp->tim->DIER = dier | STM32_TIM_DIER_UIE;
- pwmp->tim->SR &= STM32_TIM_SR_UIF;
}
}
Antoine