diff options
| author | Finomnis <Finomnis@users.noreply.github.com> | 2023-12-06 19:36:09 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-06 18:36:09 +0000 |
| commit | bbed94528528fbfe53ed7baf9cc38ca012785d13 (patch) | |
| tree | 45269ff41ff0007e2b405c5cbea2c3ba19928b46 /rtic-monotonics | |
| parent | f377471e440d8be0b2f9e9c8877ed015f62dc19e (diff) | |
Fix race condition in `calculate_now` (#860)
* Fix race condition in calculate_now
* Add changelog
* Update changelog
* Refine comment
* More comment fixes
Diffstat (limited to 'rtic-monotonics')
| -rw-r--r-- | rtic-monotonics/CHANGELOG.md | 1 | ||||
| -rw-r--r-- | rtic-monotonics/src/imxrt.rs | 2 | ||||
| -rw-r--r-- | rtic-monotonics/src/nrf/rtc.rs | 2 | ||||
| -rw-r--r-- | rtic-monotonics/src/nrf/timer.rs | 2 | ||||
| -rw-r--r-- | rtic-monotonics/src/stm32.rs | 2 |
5 files changed, 5 insertions, 4 deletions
diff --git a/rtic-monotonics/CHANGELOG.md b/rtic-monotonics/CHANGELOG.md index 041cff9..e1a0f83 100644 --- a/rtic-monotonics/CHANGELOG.md +++ b/rtic-monotonics/CHANGELOG.md @@ -13,6 +13,7 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top! - Fix race condition in `nrf::rtc`. - Fix errata in `nrf::rtc`. - Add internal counter integrity check to all half-period based monotonics. +- Apply race condition fixes from `rtic-time`. ## v1.4.0 - 2023-12-04 diff --git a/rtic-monotonics/src/imxrt.rs b/rtic-monotonics/src/imxrt.rs index ecf9129..2299bea 100644 --- a/rtic-monotonics/src/imxrt.rs +++ b/rtic-monotonics/src/imxrt.rs @@ -212,7 +212,7 @@ macro_rules! make_timer { let gpt = unsafe{ $timer::instance() }; Self::Instant::from_ticks(calculate_now( - $period.load(Ordering::Relaxed), + || $period.load(Ordering::Relaxed), || ral::read_reg!(ral::gpt, gpt, CNT) )) } diff --git a/rtic-monotonics/src/nrf/rtc.rs b/rtic-monotonics/src/nrf/rtc.rs index 643d8bd..d425b11 100644 --- a/rtic-monotonics/src/nrf/rtc.rs +++ b/rtic-monotonics/src/nrf/rtc.rs @@ -224,7 +224,7 @@ macro_rules! make_rtc { fn now() -> Self::Instant { let rtc = unsafe { &*$rtc::PTR }; Self::Instant::from_ticks(calculate_now( - $overflow.load(Ordering::Relaxed), + || $overflow.load(Ordering::Relaxed), || TimerValueU24(rtc.counter.read().bits()) )) } diff --git a/rtic-monotonics/src/nrf/timer.rs b/rtic-monotonics/src/nrf/timer.rs index 2f83f40..7b760e4 100644 --- a/rtic-monotonics/src/nrf/timer.rs +++ b/rtic-monotonics/src/nrf/timer.rs @@ -242,7 +242,7 @@ macro_rules! make_timer { let timer = unsafe { &*$timer::PTR }; Self::Instant::from_ticks(calculate_now( - $overflow.load(Ordering::Relaxed), + || $overflow.load(Ordering::Relaxed), || { timer.tasks_capture[3].write(|w| unsafe { w.bits(1) }); timer.cc[3].read().bits() diff --git a/rtic-monotonics/src/stm32.rs b/rtic-monotonics/src/stm32.rs index 601196a..68f95a2 100644 --- a/rtic-monotonics/src/stm32.rs +++ b/rtic-monotonics/src/stm32.rs @@ -234,7 +234,7 @@ macro_rules! make_timer { fn now() -> Self::Instant { Self::Instant::from_ticks(calculate_now( - $overflow.load(Ordering::Relaxed), + || $overflow.load(Ordering::Relaxed), || $timer.cnt().read().cnt() )) } |
