From 8e7a1edd114b89a35006b71422c92de60e62d7c0 Mon Sep 17 00:00:00 2001 From: Michel Rottleuthner Date: Thu, 9 Jan 2020 15:51:59 +0100 Subject: [PATCH] drivers/periph_common/timer: protect timer_set from IRQs --- drivers/periph_common/timer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/periph_common/timer.c b/drivers/periph_common/timer.c index 5fcf6275f1..8e657312a8 100644 --- a/drivers/periph_common/timer.c +++ b/drivers/periph_common/timer.c @@ -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