File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,20 @@ 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| w. rsf ( ) . clear_bit ( ) ) ;
207+
208+ while self . rtc . isr . read ( ) . rsf ( ) . bit_is_clear ( ) { }
209+ }
210+
197211 /// Set date and time.
198212 pub fn set_datetime ( & mut self , datetime : & PrimitiveDateTime ) {
199213 self . write ( true , |rtc| {
You can’t perform that action at this time.
0 commit comments