diff options
Diffstat (limited to 'libhw/rp2040_hwtimer.c')
-rw-r--r-- | libhw/rp2040_hwtimer.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/libhw/rp2040_hwtimer.c b/libhw/rp2040_hwtimer.c index 6f37d85..9f0d901 100644 --- a/libhw/rp2040_hwtimer.c +++ b/libhw/rp2040_hwtimer.c @@ -115,7 +115,7 @@ static bool rp2040_hwtimer_add_trigger(implements_alarmclock *_alarmclock, trigger->cb = cb; trigger->cb_arg = cb_arg; - cr_disable_interrupts(); + bool saved = cr_save_and_disable_interrupts(); struct alarmclock_trigger **dst = &alarmclock->queue; while (*dst && fire_at_ns >= (*dst)->fire_at_ns) dst = &(*dst)->next; @@ -135,14 +135,15 @@ static bool rp2040_hwtimer_add_trigger(implements_alarmclock *_alarmclock, /* Force the interrupt handler to trigger as soon as * we enable interrupts. This handles the case of * when fire_at_ns is before when we called - * cr_disable_interrupts(). We could check + * cr_save_and_disable_interrupts(). We could check * timer_time_us_64() again after calling - * cr_disable_interrupts() and do this conditionally, - * but I don't think that would be any more efficient - * than just letting the interrupt fire. */ + * cr_save_and_disable_interrupts() and do this + * conditionally, but I don't think that would be any + * more efficient than just letting the interrupt + * fire. */ hw_set_bits(&timer_hw->intf, 1 << alarmclock->alarm_num); } - cr_enable_interrupts(); + cr_restore_interrupts(saved); return false; } @@ -154,7 +155,7 @@ static void rp2040_hwtimer_del_trigger(implements_alarmclock *_alarmclock, assert(alarmclock); assert(trigger); - cr_disable_interrupts(); + bool saved = cr_save_and_disable_interrupts(); if (trigger->alarmclock == alarmclock) { if (!trigger->prev) alarmclock->queue = trigger->next; @@ -166,5 +167,5 @@ static void rp2040_hwtimer_del_trigger(implements_alarmclock *_alarmclock, trigger->prev = NULL; trigger->next = NULL; } - cr_enable_interrupts(); + cr_restore_interrupts(saved); } |