aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src
diff options
context:
space:
mode:
author1-rafael-1 <[email protected]>2025-09-15 21:10:22 +0200
committer1-rafael-1 <[email protected]>2025-09-15 21:10:22 +0200
commitac32f43c3dc915b78e71328855189b8aacfec8c3 (patch)
tree42d52279b5c13c9557f34bf4e022ca965351b93d /embassy-rp/src
parent37fd802f961486b176c0cdda9087ecf987d51eb8 (diff)
alarm handling to poll hardware status directly; add ci test
Diffstat (limited to 'embassy-rp/src')
-rw-r--r--embassy-rp/src/rtc/mod.rs19
1 files changed, 6 insertions, 13 deletions
diff --git a/embassy-rp/src/rtc/mod.rs b/embassy-rp/src/rtc/mod.rs
index 7289e46af..8e6aa66c9 100644
--- a/embassy-rp/src/rtc/mod.rs
+++ b/embassy-rp/src/rtc/mod.rs
@@ -2,7 +2,7 @@
2mod filter; 2mod filter;
3 3
4use core::future::poll_fn; 4use core::future::poll_fn;
5use core::sync::atomic::{compiler_fence, AtomicBool, Ordering}; 5use core::sync::atomic::{compiler_fence, Ordering};
6use core::task::Poll; 6use core::task::Poll;
7 7
8use embassy_hal_internal::{Peri, PeripheralType}; 8use embassy_hal_internal::{Peri, PeripheralType};
@@ -21,8 +21,6 @@ use crate::interrupt::{self, InterruptExt};
21 21
22// Static waker for the interrupt handler 22// Static waker for the interrupt handler
23static WAKER: AtomicWaker = AtomicWaker::new(); 23static WAKER: AtomicWaker = AtomicWaker::new();
24// Static flag to indicate if an alarm has occurred
25static ALARM_OCCURRED: AtomicBool = AtomicBool::new(false);
26 24
27/// A reference to the real time clock of the system 25/// A reference to the real time clock of the system
28pub struct Rtc<'d, T: Instance> { 26pub struct Rtc<'d, T: Instance> {
@@ -259,19 +257,15 @@ impl<'d, T: Instance> Rtc<'d, T> {
259 poll_fn(|cx| { 257 poll_fn(|cx| {
260 WAKER.register(cx.waker()); 258 WAKER.register(cx.waker());
261 259
262 // If the alarm has occured, we will clear the interrupt and return ready 260 // Check hardware interrupt status directly
263 if ALARM_OCCURRED.load(Ordering::SeqCst) { 261 if self.inner.regs().ints().read().rtc() {
264 // Clear the alarm occurred flag 262 // Clear the interrupt status and disable the alarm
265 ALARM_OCCURRED.store(false, Ordering::SeqCst); 263 self.inner.regs().ints().write(|w| w.set_rtc(true));
266
267 // Clear the interrupt and disable the alarm
268 self.clear_interrupt(); 264 self.clear_interrupt();
269 265
270 // Return ready
271 compiler_fence(Ordering::SeqCst); 266 compiler_fence(Ordering::SeqCst);
272 return Poll::Ready(()); 267 return Poll::Ready(());
273 } else { 268 } else {
274 // If the alarm has not occurred, we will return pending
275 return Poll::Pending; 269 return Poll::Pending;
276 } 270 }
277 }) 271 })
@@ -290,8 +284,7 @@ impl crate::interrupt::typelevel::Handler<crate::interrupt::typelevel::RTC_IRQ>
290 let rtc = crate::pac::RTC; 284 let rtc = crate::pac::RTC;
291 rtc.irq_setup_0().modify(|w| w.set_match_ena(false)); 285 rtc.irq_setup_0().modify(|w| w.set_match_ena(false));
292 286
293 // Set the alarm occurred flag and wake the waker 287 // Wake the waker - interrupt status will be checked directly by polling future
294 ALARM_OCCURRED.store(true, Ordering::SeqCst);
295 WAKER.wake(); 288 WAKER.wake();
296 } 289 }
297} 290}