stm32: fix rtc wakeup timing and add dbg

This commit is contained in:
xoviat
2023-08-27 21:15:57 -05:00
parent 9f928010a8
commit e981cd4968
7 changed files with 62 additions and 15 deletions

View File

@ -47,6 +47,18 @@ struct RtcInstant {
subsecond: u16,
}
#[cfg(all(feature = "low-power", feature = "defmt"))]
impl defmt::Format for RtcInstant {
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(
fmt,
"{}:{}",
self.second,
RTC::regs().prer().read().prediv_s() - self.subsecond,
)
}
}
#[cfg(feature = "low-power")]
impl core::ops::Sub for RtcInstant {
type Output = embassy_time::Duration;
@ -174,7 +186,7 @@ impl Rtc {
let second = bcd2_to_byte((tr.st(), tr.su()));
// Unlock the registers
r.dr();
r.dr().read();
RtcInstant { second, subsecond }
}