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:
parent
5b23bfb962
commit
4e357d410c
@ -195,11 +195,13 @@ int timer_set(tim_t tim, int channel, unsigned int timeout)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* clear spurious IRQs */
|
|
||||||
dev(tim)->SR &= ~(TIM_SR_CC1IF << channel);
|
|
||||||
|
|
||||||
TIM_CHAN(tim, channel) = value;
|
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 */
|
/* enable IRQ */
|
||||||
dev(tim)->DIER |= (TIM_DIER_CC1IE << channel);
|
dev(tim)->DIER |= (TIM_DIER_CC1IE << channel);
|
||||||
|
|
||||||
@ -264,7 +266,13 @@ int timer_clear(tim_t tim, int channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned irqstate = irq_disable();
|
unsigned irqstate = irq_disable();
|
||||||
|
|
||||||
|
/* disable IRQ */
|
||||||
dev(tim)->DIER &= ~(TIM_DIER_CC1IE << channel);
|
dev(tim)->DIER &= ~(TIM_DIER_CC1IE << channel);
|
||||||
|
|
||||||
|
/* clear spurious IRQs */
|
||||||
|
dev(tim)->SR &= ~(TIM_SR_CC1IF << channel);
|
||||||
|
|
||||||
irq_restore(irqstate);
|
irq_restore(irqstate);
|
||||||
|
|
||||||
#ifdef MODULE_PERIPH_TIMER_PERIODIC
|
#ifdef MODULE_PERIPH_TIMER_PERIODIC
|
||||||
|
Loading…
Reference in New Issue
Block a user