aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/rtc
diff options
context:
space:
mode:
authorScott Mabin <[email protected]>2023-07-30 21:22:48 +0100
committerScott Mabin <[email protected]>2023-07-30 21:22:48 +0100
commite8d3e865912c304e4c495295360955707fffa07c (patch)
tree8eb6a139c40c391fc1b0c44e1f3fe6954cf3a235 /embassy-stm32/src/rtc
parentf3237d7a2cceb37cb822e0c819f739051800a17e (diff)
stm32f2: Avoid resetting rtc backup domain
Also ensure the pwr is enabled before trying to initialize. For the F2 series this is in a seperate clock control register.
Diffstat (limited to 'embassy-stm32/src/rtc')
-rw-r--r--embassy-stm32/src/rtc/v2.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/embassy-stm32/src/rtc/v2.rs b/embassy-stm32/src/rtc/v2.rs
index a2eace6d3..e3b9dfb8b 100644
--- a/embassy-stm32/src/rtc/v2.rs
+++ b/embassy-stm32/src/rtc/v2.rs
@@ -39,9 +39,8 @@ impl<'d, T: Instance> super::Rtc<'d, T> {
39 let rtcsel = reg.rtcsel().to_bits(); 39 let rtcsel = reg.rtcsel().to_bits();
40 40
41 if !reg.rtcen() || rtcsel != clock_config { 41 if !reg.rtcen() || rtcsel != clock_config {
42 #[cfg(not(any(rtc_v2l0, rtc_v2l1)))] 42 #[cfg(not(any(rtc_v2l0, rtc_v2l1, rtc_v2f2)))]
43 crate::pac::RCC.bdcr().modify(|w| w.set_bdrst(true)); 43 crate::pac::RCC.bdcr().modify(|w| w.set_bdrst(true));
44
45 #[cfg(not(any(rtc_v2l0, rtc_v2l1)))] 44 #[cfg(not(any(rtc_v2l0, rtc_v2l1)))]
46 let cr = crate::pac::RCC.bdcr(); 45 let cr = crate::pac::RCC.bdcr();
47 #[cfg(any(rtc_v2l0, rtc_v2l1))] 46 #[cfg(any(rtc_v2l0, rtc_v2l1))]
@@ -201,6 +200,11 @@ impl sealed::Instance for crate::peripherals::RTC {
201 // read to allow the pwr clock to enable 200 // read to allow the pwr clock to enable
202 crate::pac::PWR.cr1().read(); 201 crate::pac::PWR.cr1().read();
203 } 202 }
203 #[cfg(any(rtc_v2f2))]
204 {
205 crate::pac::RCC.apb1enr().modify(|w| w.set_pwren(true));
206 crate::pac::PWR.cr().read();
207 }
204 } 208 }
205 209
206 fn read_backup_register(rtc: &Rtc, register: usize) -> Option<u32> { 210 fn read_backup_register(rtc: &Rtc, register: usize) -> Option<u32> {