@@ -81,6 +81,7 @@ impl PwrExt for PWR {
81
81
any( feature = "rm0433" , feature = "rm0399" )
82
82
) ) ]
83
83
enable_vos0 : false ,
84
+ backup_regulator : false ,
84
85
}
85
86
}
86
87
}
@@ -97,6 +98,7 @@ pub struct Pwr {
97
98
any( feature = "rm0433" , feature = "rm0399" )
98
99
) ) ]
99
100
enable_vos0 : bool ,
101
+ backup_regulator : bool ,
100
102
}
101
103
102
104
/// Voltage Scale
@@ -332,6 +334,15 @@ impl Pwr {
332
334
self
333
335
}
334
336
337
+ /// Enable the backup domain voltage regulator
338
+ ///
339
+ /// The backup domain voltage regulator maintains the contents of backup SRAM
340
+ /// in Standby and VBAT modes.
341
+ pub fn backup_regulator ( mut self ) -> Self {
342
+ self . backup_regulator = true ;
343
+ self
344
+ }
345
+
335
346
pub fn freeze ( self ) -> PowerConfiguration {
336
347
// NB. The lower bytes of CR3 can only be written once after
337
348
// POR, and must be written with a valid combination. Refer to
@@ -418,7 +429,14 @@ impl Pwr {
418
429
419
430
// Disable backup power domain write protection
420
431
self . rb . cr1 . modify ( |_, w| w. dbp ( ) . set_bit ( ) ) ;
421
- let backup = unsafe { BackupREC :: new_singleton ( ) } ;
432
+ while self . rb . cr1 . read ( ) . dbp ( ) . bit_is_clear ( ) { }
433
+
434
+ if self . backup_regulator {
435
+ self . rb . cr2 . modify ( |_, w| w. bren ( ) . set_bit ( ) ) ;
436
+ while self . rb . cr2 . read ( ) . brrdy ( ) . bit_is_clear ( ) { }
437
+ }
438
+
439
+ let backup = unsafe { BackupREC :: new_singleton ( self . backup_regulator ) } ;
422
440
423
441
PowerConfiguration {
424
442
vos,
0 commit comments