1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 14:03:55 +01:00

Merge pull request #18978 from maribu/cpu/atmega_common/periph_timer/spurious_irqs

cpu/atmega_common/periph_timer: fix spurious IRQs
This commit is contained in:
Marian Buschsieweke 2022-11-26 16:29:18 +01:00 committed by GitHub
commit 476dca2e8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -158,7 +158,9 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value)
unsigned state = irq_disable();
ctx[tim].dev->OCR[channel] = (uint16_t)value;
*ctx[tim].flag &= ~(1 << (channel + OCF1A));
/* clear spurious IRQs, if any */
*ctx[tim].flag = (1 << (channel + OCF1A));
/* unmask IRQ */
*ctx[tim].mask |= (1 << (channel + OCIE1A));
set_oneshot(tim, channel);
@ -177,6 +179,9 @@ int timer_set(tim_t tim, int channel, unsigned int timeout)
unsigned absolute = ctx[tim].dev->CNT + timeout;
ctx[tim].dev->OCR[channel] = absolute;
/* clear spurious IRQs, if any */
*ctx[tim].flag = (1 << (channel + OCF1A));
/* unmask IRQ */
*ctx[tim].mask |= (1 << (channel + OCIE1A));
set_oneshot(tim, channel);
@ -210,7 +215,9 @@ int timer_set_periodic(tim_t tim, int channel, unsigned int value, uint8_t flags
ctx[tim].dev->OCR[channel] = (uint16_t)value;
*ctx[tim].flag &= ~(1 << (channel + OCF1A));
/* clear spurious IRQs, if any */
*ctx[tim].flag = (1 << (channel + OCF1A));
/* unmask IRQ */
*ctx[tim].mask |= (1 << (channel + OCIE1A));
clear_oneshot(tim, channel);