Skip to content

Commit 87ee78e

Browse files
committed
cpu/lpc23xx/periph/timer: protect ISR callback context update
1 parent 8252c47 commit 87ee78e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

cpu/lpc23xx/periph/timer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ int timer_init(tim_t tim, uint32_t freq, timer_cb_t cb, void *arg)
137137
uint32_t scale, prescale;
138138
lpc23xx_pclk_scale(CLOCK_PCLK, freq, &scale, &prescale);
139139

140+
unsigned irq_state = irq_disable();
141+
140142
/* save the callback */
141143
isr_ctx[tim].cb = cb;
142144
isr_ctx[tim].arg = arg;
@@ -149,6 +151,7 @@ int timer_init(tim_t tim, uint32_t freq, timer_cb_t cb, void *arg)
149151
dev->PR = prescale - 1;
150152
/* enable timer */
151153
dev->TCR = 1;
154+
irq_restore(irq_state);
152155
return 0;
153156
}
154157

0 commit comments

Comments
 (0)