mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #20926 from Enoch247/fix-stm32-periph-timer-spurious-irq
cpu/stm32/periph/timer: prevent spurious IRQs
This commit is contained in:
commit
1938002526
@ -50,7 +50,6 @@ static unsigned channel_numof(tim_t tim)
|
||||
return TIMER_CHANNEL_NUMOF;
|
||||
}
|
||||
|
||||
|
||||
#ifdef MODULE_PERIPH_TIMER_PERIODIC
|
||||
|
||||
/**
|
||||
@ -195,11 +194,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);
|
||||
|
||||
@ -236,7 +237,7 @@ int timer_set_periodic(tim_t tim, int channel, unsigned int value, uint8_t flags
|
||||
dev(tim)->CNT = 0;
|
||||
|
||||
/* wait for the interrupt & clear it */
|
||||
while(dev(tim)->SR == 0) {}
|
||||
while (dev(tim)->SR == 0) {}
|
||||
dev(tim)->SR = 0;
|
||||
}
|
||||
|
||||
@ -264,7 +265,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
|
||||
|
Loading…
Reference in New Issue
Block a user