From 406f3b7cbf2242be2e455a748352265cfb65f750 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 15 Feb 2021 01:22:38 +0100 Subject: [PATCH] rtc: use SeqCst for periods. --- embassy-nrf/src/rtc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/embassy-nrf/src/rtc.rs b/embassy-nrf/src/rtc.rs index 5d1cc0ee..079e9b32 100644 --- a/embassy-nrf/src/rtc.rs +++ b/embassy-nrf/src/rtc.rs @@ -143,7 +143,7 @@ impl RTC { fn next_period(&self) { interrupt::free(|cs| { - let period = self.period.fetch_add(1, Ordering::Relaxed) + 1; + let period = self.period.fetch_add(1, Ordering::SeqCst) + 1; let t = (period as u64) << 23; for n in 0..ALARM_COUNT { @@ -231,7 +231,7 @@ impl RTC { impl embassy::time::Clock for RTC { fn now(&self) -> u64 { // `period` MUST be read before `counter`, see comment at the top for details. - let period = self.period.load(Ordering::Relaxed); + let period = self.period.load(Ordering::SeqCst); let counter = self.rtc.counter.read().bits(); calc_now(period, counter) }