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:
commit
69b522e114
@ -19,10 +19,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "periph/timer.h"
|
#include "periph/timer.h"
|
||||||
|
#include "irq.h"
|
||||||
|
|
||||||
#ifndef PERIPH_TIMER_PROVIDES_SET
|
#ifndef PERIPH_TIMER_PROVIDES_SET
|
||||||
int timer_set(tim_t dev, int channel, unsigned int timeout)
|
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
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user