Skip to content

Commit 1178e24

Browse files
Add function to get the wakeup period
1 parent 97912d3 commit 1178e24

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

hal/src/rtc/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,17 @@ impl Rtc {
523523
self.rtc.cr.modify(|_, w| w.wute().clear_bit());
524524
}
525525

526+
/// Returns the value of the wakeup timer as calculated by the RTC logic in RTC cycles
527+
pub fn wakeup_period_cycles(&self) -> u32 {
528+
let wutr = self.rtc.wutr.read().wut().bits();
529+
let wucksel_extension = self.rtc.cr.read().wucksel().is_clock_spare_with_offset();
530+
if wucksel_extension {
531+
u32::from(wutr) + 0x1_0000
532+
} else {
533+
u32::from(wutr)
534+
}
535+
}
536+
526537
/// Set alarm A.
527538
///
528539
/// This will disable the alarm if previously enabled.

0 commit comments

Comments
 (0)