Fix nrf::rtc errata workaround (#858)

* Deprecate `should_dequeue_check`

* Fix errata by delaying the wakeup point

* Add changelog

* Fix changelog typos
This commit is contained in:
Finomnis 2023-12-06 19:36:06 +01:00 committed by GitHub
parent 89160b7cb9
commit f377471e44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 18 deletions

View file

@ -12,6 +12,7 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
### Changed
- Docs: Add sanity check to `half_period_counter` code example
- Deprecate `Monotonic::should_dequeue_check` as it was erroneous
### Fixed

View file

@ -1,6 +1,6 @@
[package]
name = "rtic-time"
version = "1.1.0"
version = "1.2.0"
edition = "2021"
authors = [

View file

@ -133,7 +133,7 @@ impl<Mono: Monotonic> TimerQueue<Mono> {
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<Mono: Monotonic> TimerQueue<Mono> {
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;

View file

@ -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 {
<Self as Monotonic>::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.