From ad64d7b20b26e0854c4d1302f562df51e67a022b Mon Sep 17 00:00:00 2001 From: Christian Enderle Date: Thu, 21 Sep 2023 17:17:58 +0200 Subject: [PATCH] fix low-power: APB1 needed for LSE --- embassy-stm32/src/rcc/bd.rs | 5 +++++ embassy-stm32/src/rtc/mod.rs | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/src/rcc/bd.rs b/embassy-stm32/src/rcc/bd.rs index 762e8435..4915d5e2 100644 --- a/embassy-stm32/src/rcc/bd.rs +++ b/embassy-stm32/src/rcc/bd.rs @@ -88,6 +88,11 @@ impl BackupDomain { ))] #[allow(dead_code, unused_variables)] pub fn configure_ls(clock_source: RtcClockSource, lsi: bool, lse: Option) { + if lsi || lse.is_some() { + use crate::rtc::sealed::Instance; + crate::peripherals::RTC::enable_peripheral_clk(); + } + if lsi { #[cfg(rtc_v3u5)] let csr = crate::pac::RCC.bdcr(); diff --git a/embassy-stm32/src/rtc/mod.rs b/embassy-stm32/src/rtc/mod.rs index 07b4fe1f..7eafedec 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs @@ -154,8 +154,6 @@ impl Default for RtcCalibrationCyclePeriod { impl Rtc { pub fn new(_rtc: impl Peripheral

, rtc_config: RtcConfig) -> Self { - RTC::enable_peripheral_clk(); - let mut this = Self { #[cfg(feature = "low-power")] stop_time: Mutex::const_new(CriticalSectionRawMutex::new(), Cell::new(None)),