Merge pull request #13060 from MichelRottleuthner/pr_periph_timer_irq_safe

drivers/periph_common/timer: protect timer_set from IRQs
This commit is contained in:
Kaspar Schleiser 2020-01-10 11:27:59 +01:00 committed by GitHub
commit 69b522e114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,10 +19,14 @@
*/
#include "periph/timer.h"
#include "irq.h"
#ifndef PERIPH_TIMER_PROVIDES_SET
int timer_set(tim_t dev, int channel, unsigned int timeout)
{
return timer_set_absolute(dev, channel, timer_read(dev) + timeout);
unsigned int state = irq_disable();
int res = timer_set_absolute(dev, channel, timer_read(dev) + timeout);
irq_restore(state);
return res;
}
#endif