Extend RTC low power mode for STM32G0

This commit is contained in:
Ben V. Brown 2023-12-19 11:00:01 +11:00
parent 4ed7747a98
commit be74dde7d0
2 changed files with 13 additions and 2 deletions

View File

@ -43,7 +43,7 @@ pub(crate) enum WakeupPrescaler {
Div16 = 16, Div16 = 16,
} }
#[cfg(any(stm32wb, stm32f4, stm32l0, stm32g4))] #[cfg(any(stm32wb, stm32f4, stm32l0, stm32g4, stm32g0))]
impl From<WakeupPrescaler> for crate::pac::rtc::vals::Wucksel { impl From<WakeupPrescaler> for crate::pac::rtc::vals::Wucksel {
fn from(val: WakeupPrescaler) -> Self { fn from(val: WakeupPrescaler) -> Self {
use crate::pac::rtc::vals::Wucksel; use crate::pac::rtc::vals::Wucksel;
@ -57,7 +57,7 @@ impl From<WakeupPrescaler> for crate::pac::rtc::vals::Wucksel {
} }
} }
#[cfg(any(stm32wb, stm32f4, stm32l0, stm32g4))] #[cfg(any(stm32wb, stm32f4, stm32l0, stm32g4, stm32g0))]
impl From<crate::pac::rtc::vals::Wucksel> for WakeupPrescaler { impl From<crate::pac::rtc::vals::Wucksel> for WakeupPrescaler {
fn from(val: crate::pac::rtc::vals::Wucksel) -> Self { fn from(val: crate::pac::rtc::vals::Wucksel) -> Self {
use crate::pac::rtc::vals::Wucksel; use crate::pac::rtc::vals::Wucksel;
@ -422,6 +422,11 @@ impl Rtc {
#[cfg(any(rtc_v3, rtc_v3u5))] #[cfg(any(rtc_v3, rtc_v3u5))]
regs.scr().write(|w| w.set_cwutf(Calrf::CLEAR)); 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 crate::pac::EXTI
.pr(0) .pr(0)
.modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); .modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true));

View File

@ -132,9 +132,15 @@ impl sealed::Instance for crate::peripherals::RTC {
#[cfg(all(feature = "low-power", stm32g4))] #[cfg(all(feature = "low-power", stm32g4))]
const EXTI_WAKEUP_LINE: usize = 20; const EXTI_WAKEUP_LINE: usize = 20;
#[cfg(all(feature = "low-power", stm32g0))]
const EXTI_WAKEUP_LINE: usize = 19;
#[cfg(all(feature = "low-power", stm32g4))] #[cfg(all(feature = "low-power", stm32g4))]
type WakeupInterrupt = crate::interrupt::typelevel::RTC_WKUP; 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<u32> { fn read_backup_register(_rtc: &Rtc, register: usize) -> Option<u32> {
#[allow(clippy::if_same_then_else)] #[allow(clippy::if_same_then_else)]
if register < Self::BACKUP_REGISTER_COUNT { if register < Self::BACKUP_REGISTER_COUNT {