1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 10:12:45 +01:00

cpu/atmega_common/periph_timer: fix spurious IRQs

This commit is contained in:
Marian Buschsieweke 2022-11-25 13:12:18 +01:00
parent f1a8e1f636
commit 787884aa95
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94

View File

@ -158,7 +158,9 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value)
unsigned state = irq_disable(); unsigned state = irq_disable();
ctx[tim].dev->OCR[channel] = (uint16_t)value; 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)); *ctx[tim].mask |= (1 << (channel + OCIE1A));
set_oneshot(tim, channel); 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; unsigned absolute = ctx[tim].dev->CNT + timeout;
ctx[tim].dev->OCR[channel] = absolute; 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)); *ctx[tim].mask |= (1 << (channel + OCIE1A));
set_oneshot(tim, channel); 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].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)); *ctx[tim].mask |= (1 << (channel + OCIE1A));
clear_oneshot(tim, channel); clear_oneshot(tim, channel);