1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/nrf5x: Tolerate NULL callback in timers

timer_set has no documented restriction on this being not null, other
implementations explicitly tolerate it (rpx0xx checks inside the ISR,
but doing it at init time keeps the ISR slim).

This is useful when using a timer just to read, without any action when
it triggers (the action is taken depending on read values, eg. in a
thread context).
This commit is contained in:
chrysn 2023-08-17 13:42:03 +02:00 committed by MrKevinWeiss
parent 5ba18df6fb
commit abf95d14a6
No known key found for this signature in database
GPG Key ID: C26684F1C0767FFF

View File

@ -111,7 +111,9 @@ int timer_init(tim_t tim, uint32_t freq, timer_cb_t cb, void *arg)
}
/* enable interrupts */
NVIC_EnableIRQ(timer_config[tim].irqn);
if (cb != NULL) {
NVIC_EnableIRQ(timer_config[tim].irqn);
}
/* start the timer */
dev(tim)->TASKS_START = 1;