Skip to content

Commit

Permalink
Add RTC initialization functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Aug 4, 2022
1 parent bf2ded1 commit 546c81c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,20 @@ impl Rtc {
rtc_struct
}

/// Check if the RTC has been initialized, i.e. if a date and time have been set.
pub fn initialized(&self) -> bool {
self.rtc.isr.read().inits().bit_is_set()
}

/// Wait for the calendar registers to be synchronized with the shadow registers.
///
/// This must be called after a system reset or after waking up from low-power mode.
pub fn wait_for_sync(&self) {
self.rtc.isr.modify(|r, w| w.rsf().clear_bit());

while self.rtc.isr.read().rsf().bit_is_clear() {}
}

/// Set date and time.
pub fn set_datetime(&mut self, datetime: &PrimitiveDateTime) {
self.write(true, |rtc| {
Expand Down

0 comments on commit 546c81c

Please sign in to comment.