From be74dde7d0eafcd1635ccc97d49d78b8e1794f37 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 19 Dec 2023 11:00:01 +1100 Subject: [PATCH] Extend RTC low power mode for STM32G0 --- embassy-stm32/src/rtc/mod.rs | 9 +++++++-- embassy-stm32/src/rtc/v3.rs | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/src/rtc/mod.rs b/embassy-stm32/src/rtc/mod.rs index fa359cda..37496303 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs @@ -43,7 +43,7 @@ pub(crate) enum WakeupPrescaler { Div16 = 16, } -#[cfg(any(stm32wb, stm32f4, stm32l0, stm32g4))] +#[cfg(any(stm32wb, stm32f4, stm32l0, stm32g4, stm32g0))] impl From for crate::pac::rtc::vals::Wucksel { fn from(val: WakeupPrescaler) -> Self { use crate::pac::rtc::vals::Wucksel; @@ -57,7 +57,7 @@ impl From for crate::pac::rtc::vals::Wucksel { } } -#[cfg(any(stm32wb, stm32f4, stm32l0, stm32g4))] +#[cfg(any(stm32wb, stm32f4, stm32l0, stm32g4, stm32g0))] impl From for WakeupPrescaler { fn from(val: crate::pac::rtc::vals::Wucksel) -> Self { use crate::pac::rtc::vals::Wucksel; @@ -422,6 +422,11 @@ impl Rtc { #[cfg(any(rtc_v3, rtc_v3u5))] regs.scr().write(|w| w.set_cwutf(Calrf::CLEAR)); + #[cfg(all(stm32g0))] + crate::pac::EXTI + .rpr(0) + .modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); + #[cfg(all(not(stm32g0)))] crate::pac::EXTI .pr(0) .modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); diff --git a/embassy-stm32/src/rtc/v3.rs b/embassy-stm32/src/rtc/v3.rs index d2d0d930..6e4fad95 100644 --- a/embassy-stm32/src/rtc/v3.rs +++ b/embassy-stm32/src/rtc/v3.rs @@ -132,9 +132,15 @@ impl sealed::Instance for crate::peripherals::RTC { #[cfg(all(feature = "low-power", stm32g4))] const EXTI_WAKEUP_LINE: usize = 20; + #[cfg(all(feature = "low-power", stm32g0))] + const EXTI_WAKEUP_LINE: usize = 19; + #[cfg(all(feature = "low-power", stm32g4))] type WakeupInterrupt = crate::interrupt::typelevel::RTC_WKUP; + #[cfg(all(feature = "low-power", stm32g0))] + type WakeupInterrupt = crate::interrupt::typelevel::RTC_TAMP; + fn read_backup_register(_rtc: &Rtc, register: usize) -> Option { #[allow(clippy::if_same_then_else)] if register < Self::BACKUP_REGISTER_COUNT {