1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/stm32/periph/timer: prevnt spurious IRQs

This patch hardens the STM32 timer driver against some possible causes
of spurious IRQs.
This commit is contained in:
Joshua DeWeese 2024-10-18 15:45:20 -04:00
parent 5b23bfb962
commit 4e357d410c

View File

@ -195,11 +195,13 @@ int timer_set(tim_t tim, int channel, unsigned int timeout)
}
#endif
/* clear spurious IRQs */
dev(tim)->SR &= ~(TIM_SR_CC1IF << channel);
TIM_CHAN(tim, channel) = value;
/* clear spurious IRQs
* note: This might also clear the IRQ just set, but that is handled below
* anyway. */
dev(tim)->SR &= ~(TIM_SR_CC1IF << channel);
/* enable IRQ */
dev(tim)->DIER |= (TIM_DIER_CC1IE << channel);
@ -264,7 +266,13 @@ int timer_clear(tim_t tim, int channel)
}
unsigned irqstate = irq_disable();
/* disable IRQ */
dev(tim)->DIER &= ~(TIM_DIER_CC1IE << channel);
/* clear spurious IRQs */
dev(tim)->SR &= ~(TIM_SR_CC1IF << channel);
irq_restore(irqstate);
#ifdef MODULE_PERIPH_TIMER_PERIODIC