aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/rtc/v2/v2l0.rs52
-rw-r--r--embassy-stm32/src/rtc/v2/v2l1.rs50
-rw-r--r--embassy-stm32/src/rtc/v3.rs3
3 files changed, 38 insertions, 67 deletions
diff --git a/embassy-stm32/src/rtc/v2/v2l0.rs b/embassy-stm32/src/rtc/v2/v2l0.rs
index 8d8005887..dbd3b0882 100644
--- a/embassy-stm32/src/rtc/v2/v2l0.rs
+++ b/embassy-stm32/src/rtc/v2/v2l0.rs
@@ -1,40 +1,26 @@
1pub const BACKUP_REGISTER_COUNT: usize = 20; 1pub const BACKUP_REGISTER_COUNT: usize = 20;
2 2
3/// Unlock the backup domain 3/// Unlock the backup domain
4pub(super) unsafe fn unlock_backup_domain(_clock_config: u8) { 4pub(super) unsafe fn unlock_backup_domain(clock_config: u8) {
5 // FIXME: 5 // TODO: Missing from PAC?
6 // crate::pac::PWR.cr1().modify(|w| w.set_dbp(true)); 6 // crate::pac::PWR.cr().modify(|w| w.set_dbp(true));
7 // while !crate::pac::PWR.cr1().read().dbp() {} 7 // while !crate::pac::PWR.cr().read().dbp() {}
8 8
9 // let reg = crate::pac::RCC.bdcr().read(); 9 let reg = crate::pac::RCC.csr().read();
10 // assert!(!reg.lsecsson(), "RTC is not compatible with LSE CSS, yet."); 10
11 11 if !reg.rtcen() || reg.rtcsel().0 != clock_config {
12 // if !reg.rtcen() || reg.rtcsel().0 != clock_config { 12 crate::pac::RCC.csr().modify(|w| {
13 // crate::pac::RCC.bdcr().modify(|w| w.set_bdrst(true)); 13 // Select RTC source
14 14 w.set_rtcsel(crate::pac::rcc::vals::Rtcsel(clock_config));
15 // crate::pac::RCC.bdcr().modify(|w| { 15 w.set_rtcen(true);
16 // // Reset 16
17 // w.set_bdrst(false); 17 w.set_lseon(reg.lseon());
18 18 w.set_lsedrv(reg.lsedrv());
19 // // Select RTC source 19 w.set_lsebyp(reg.lsebyp());
20 // w.set_rtcsel(Rtcsel(clock_config)); 20 });
21 // w.set_rtcen(true); 21 }
22
23 // // Restore bcdr
24 // w.set_lscosel(reg.lscosel());
25 // w.set_lscoen(reg.lscoen());
26
27 // w.set_lseon(reg.lseon());
28 // w.set_lsedrv(reg.lsedrv());
29 // w.set_lsebyp(reg.lsebyp());
30 // });
31 // }
32} 22}
33 23
34pub(crate) unsafe fn enable_peripheral_clk() { 24pub(crate) unsafe fn enable_peripheral_clk() {
35 // // enable peripheral clock for communication 25 // Nothing to do
36 // crate::pac::rcc.apb1enr1().modify(|w| w.set_rtcapben(true));
37
38 // // read to allow the pwr clock to enable
39 // crate::pac::PWR.cr1().read();
40} 26}
diff --git a/embassy-stm32/src/rtc/v2/v2l1.rs b/embassy-stm32/src/rtc/v2/v2l1.rs
index 8d8005887..1ac78b31a 100644
--- a/embassy-stm32/src/rtc/v2/v2l1.rs
+++ b/embassy-stm32/src/rtc/v2/v2l1.rs
@@ -1,40 +1,24 @@
1pub const BACKUP_REGISTER_COUNT: usize = 20; 1pub const BACKUP_REGISTER_COUNT: usize = 20;
2 2
3/// Unlock the backup domain 3/// Unlock the backup domain
4pub(super) unsafe fn unlock_backup_domain(_clock_config: u8) { 4pub(super) unsafe fn unlock_backup_domain(clock_config: u8) {
5 // FIXME: 5 crate::pac::PWR.cr().modify(|w| w.set_dbp(true));
6 // crate::pac::PWR.cr1().modify(|w| w.set_dbp(true)); 6 while !crate::pac::PWR.cr().read().dbp() {}
7 // while !crate::pac::PWR.cr1().read().dbp() {} 7
8 8 let reg = crate::pac::RCC.csr().read();
9 // let reg = crate::pac::RCC.bdcr().read(); 9
10 // assert!(!reg.lsecsson(), "RTC is not compatible with LSE CSS, yet."); 10 if !reg.rtcen() || reg.rtcsel().0 != clock_config {
11 11 crate::pac::RCC.csr().modify(|w| {
12 // if !reg.rtcen() || reg.rtcsel().0 != clock_config { 12 // Select RTC source
13 // crate::pac::RCC.bdcr().modify(|w| w.set_bdrst(true)); 13 w.set_rtcsel(crate::pac::rcc::vals::Rtcsel(clock_config));
14 14 w.set_rtcen(true);
15 // crate::pac::RCC.bdcr().modify(|w| { 15
16 // // Reset 16 w.set_lseon(reg.lseon());
17 // w.set_bdrst(false); 17 w.set_lsebyp(reg.lsebyp());
18 18 });
19 // // Select RTC source 19 }
20 // w.set_rtcsel(Rtcsel(clock_config));
21 // w.set_rtcen(true);
22
23 // // Restore bcdr
24 // w.set_lscosel(reg.lscosel());
25 // w.set_lscoen(reg.lscoen());
26
27 // w.set_lseon(reg.lseon());
28 // w.set_lsedrv(reg.lsedrv());
29 // w.set_lsebyp(reg.lsebyp());
30 // });
31 // }
32} 20}
33 21
34pub(crate) unsafe fn enable_peripheral_clk() { 22pub(crate) unsafe fn enable_peripheral_clk() {
35 // // enable peripheral clock for communication 23 // Nothing to do
36 // crate::pac::rcc.apb1enr1().modify(|w| w.set_rtcapben(true));
37
38 // // read to allow the pwr clock to enable
39 // crate::pac::PWR.cr1().read();
40} 24}
diff --git a/embassy-stm32/src/rtc/v3.rs b/embassy-stm32/src/rtc/v3.rs
index dfe27ed6e..c9a794c3a 100644
--- a/embassy-stm32/src/rtc/v3.rs
+++ b/embassy-stm32/src/rtc/v3.rs
@@ -32,7 +32,8 @@ impl<'d, T: Instance> super::Rtc<'d, T> {
32 feature = "stm32wl54jc-cm0p", 32 feature = "stm32wl54jc-cm0p",
33 feature = "stm32wle5ub", 33 feature = "stm32wle5ub",
34 feature = "stm32g0c1ve", 34 feature = "stm32g0c1ve",
35 feature = "stm32wl55jc-cm4" 35 feature = "stm32wl55jc-cm4",
36 feature = "stm32wl55uc-cm4"
36 )))] 37 )))]
37 let config_rtcsel = stm32_metapac::rtc::vals::Rtcsel(config_rtcsel); 38 let config_rtcsel = stm32_metapac::rtc::vals::Rtcsel(config_rtcsel);
38 #[cfg(feature = "stm32g0c1ve")] 39 #[cfg(feature = "stm32g0c1ve")]