Skip to content

Commit 31aa7fa

Browse files
committed
Add RTC initialization functions.
1 parent bf2ded1 commit 31aa7fa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/rtc.rs

+16
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,22 @@ impl Rtc {
194194
rtc_struct
195195
}
196196

197+
/// Check if the RTC has been initialized, i.e. if a date and time have been set.
198+
pub fn initialized(&self) -> bool {
199+
self.rtc.isr.read().inits().bit_is_set()
200+
}
201+
202+
/// Wait for the calendar registers to be synchronized with the shadow registers.
203+
///
204+
/// This must be called after a system reset or after waking up from low-power mode.
205+
pub fn wait_for_sync(&self) {
206+
self.rtc.isr.modify(|r, w| {
207+
w.rsf().clear_bit()
208+
});
209+
210+
while self.rtc.isr.read().rsf().bit_is_clear() {}
211+
}
212+
197213
/// Set date and time.
198214
pub fn set_datetime(&mut self, datetime: &PrimitiveDateTime) {
199215
self.write(true, |rtc| {

0 commit comments

Comments
 (0)