diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-11-15 00:46:44 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-11-19 20:15:48 -0700 |
commit | 5e04cdf350f9cede59263b52c2271f7c066439e3 (patch) | |
tree | 9d731c522a5a6d7b1bd49293f0350da1f4e2bd47 /libhw/rp2040_hwtimer.c | |
parent | 712f71f1a7c6d06ce9f8f011c5d5c03add0e9d72 (diff) |
libcr: Begone with PRE_RUNNABLE
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); } |