From f377471e440d8be0b2f9e9c8877ed015f62dc19e Mon Sep 17 00:00:00 2001 From: Finomnis Date: Wed, 6 Dec 2023 19:36:06 +0100 Subject: Fix `nrf::rtc` errata workaround (#858) * Deprecate `should_dequeue_check` * Fix errata by delaying the wakeup point * Add changelog * Fix changelog typos --- rtic-time/src/lib.rs | 4 ++-- rtic-time/src/monotonic.rs | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'rtic-time/src') diff --git a/rtic-time/src/lib.rs b/rtic-time/src/lib.rs index 6254bca..9cd20d5 100644 --- a/rtic-time/src/lib.rs +++ b/rtic-time/src/lib.rs @@ -133,7 +133,7 @@ impl TimerQueue { let head = self.queue.pop_if(|head| { release_at = Some(head.release_at); - let should_pop = Mono::should_dequeue_check(head.release_at); + let should_pop = Mono::now() >= head.release_at; head.was_popped.store(should_pop, Ordering::Relaxed); should_pop @@ -147,7 +147,7 @@ impl TimerQueue { Mono::enable_timer(); Mono::set_compare(instant); - if Mono::should_dequeue_check(instant) { + if Mono::now() >= instant { // The time for the next instant passed while handling it, // continue dequeueing continue; diff --git a/rtic-time/src/monotonic.rs b/rtic-time/src/monotonic.rs index 0c0d6f3..0e8d2b8 100644 --- a/rtic-time/src/monotonic.rs +++ b/rtic-time/src/monotonic.rs @@ -36,11 +36,15 @@ pub trait Monotonic { /// queue in RTIC checks this. fn set_compare(instant: Self::Instant); - /// Override for the dequeue check, override with timers that have bugs. - /// - /// E.g. nRF52 RTCs needs to be dequeued if the time is within 4 ticks. - fn should_dequeue_check(release_at: Self::Instant) -> bool { - ::now() >= release_at + /// This method used to be required by an errata workaround + /// for the nrf52 family, but it has been disabled as the + /// workaround was erroneous. + #[deprecated( + since = "1.2.0", + note = "this method is erroneous and has been disabled" + )] + fn should_dequeue_check(_: Self::Instant) -> bool { + panic!("This method should not be used as it is erroneous.") } /// Clear the compare interrupt flag. -- cgit v1.2.3