diff --git a/src/time.rs b/src/time.rs index b4b421f1dd4c26b560cbff663281e8dacd286ef1..5a5dc12633f72eacccd6eeae889667dcf46b8b6a 100644 --- a/src/time.rs +++ b/src/time.rs @@ -181,13 +181,17 @@ unsafe fn RTC0() { /// Wait for the next interrupt configured by `set_interrupt_frequency`. pub fn wait_for_next_tick() { - RTC.modify(|rtc| { + if RTC.modify(|rtc| { if rtc.is_event_triggered(RtcInterrupt::Compare0) { // the compare register has already triggered TIMER_FLAG.store(false, Ordering::SeqCst); - return; + true + } else { + false } - }); + }) { + return; + } while !TIMER_FLAG.load(Ordering::SeqCst) { cortex_m::asm::wfi();