low-power: add support for stm32u5

This commit is contained in:
Christian Enderle 2024-11-03 10:56:40 +01:00
parent fcbbef01cd
commit 926ae1a1d5
4 changed files with 20 additions and 8 deletions

View File

@ -112,10 +112,10 @@ pub enum StopMode {
Stop2, Stop2,
} }
#[cfg(any(stm32l4, stm32l5))] #[cfg(any(stm32l4, stm32l5, stm32u5))]
use stm32_metapac::pwr::vals::Lpms; use stm32_metapac::pwr::vals::Lpms;
#[cfg(any(stm32l4, stm32l5))] #[cfg(any(stm32l4, stm32l5, stm32u5))]
impl Into<Lpms> for StopMode { impl Into<Lpms> for StopMode {
fn into(self) -> Lpms { fn into(self) -> Lpms {
match self { match self {
@ -184,7 +184,7 @@ impl Executor {
#[allow(unused_variables)] #[allow(unused_variables)]
fn configure_stop(&mut self, stop_mode: StopMode) { fn configure_stop(&mut self, stop_mode: StopMode) {
#[cfg(any(stm32l4, stm32l5))] #[cfg(any(stm32l4, stm32l5, stm32u5))]
crate::pac::PWR.cr1().modify(|m| m.set_lpms(stop_mode.into())); crate::pac::PWR.cr1().modify(|m| m.set_lpms(stop_mode.into()));
#[cfg(stm32h5)] #[cfg(stm32h5)]
crate::pac::PWR.pmcr().modify(|v| { crate::pac::PWR.pmcr().modify(|v| {

View File

@ -65,7 +65,7 @@ pub(crate) enum WakeupPrescaler {
Div16 = 16, Div16 = 16,
} }
#[cfg(any(stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0))] #[cfg(any(stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0, stm32u5))]
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;
@ -79,7 +79,7 @@ impl From<WakeupPrescaler> for crate::pac::rtc::vals::Wucksel {
} }
} }
#[cfg(any(stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0))] #[cfg(any(stm32f4, stm32l0, stm32g4, stm32l4, stm32l5, stm32wb, stm32h5, stm32g0, stm32u5))]
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;
@ -219,12 +219,21 @@ impl Rtc {
pub(crate) fn enable_wakeup_line(&self) { pub(crate) fn enable_wakeup_line(&self) {
use crate::interrupt::typelevel::Interrupt; use crate::interrupt::typelevel::Interrupt;
use crate::pac::EXTI;
<RTC as crate::rtc::SealedInstance>::WakeupInterrupt::unpend(); <RTC as crate::rtc::SealedInstance>::WakeupInterrupt::unpend();
unsafe { <RTC as crate::rtc::SealedInstance>::WakeupInterrupt::enable() }; unsafe { <RTC as crate::rtc::SealedInstance>::WakeupInterrupt::enable() };
EXTI.rtsr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); #[cfg(not(stm32u5))]
EXTI.imr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true)); {
use crate::pac::EXTI;
EXTI.rtsr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true));
EXTI.imr(0).modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true));
}
#[cfg(stm32u5)]
{
use crate::pac::RCC;
RCC.srdamr().modify(|w| w.set_rtcapbamen(true));
RCC.apb3smenr().modify(|w| w.set_rtcapbsmen(true));
}
} }
} }

View File

@ -285,6 +285,7 @@ trait SealedInstance {
const BACKUP_REGISTER_COUNT: usize; const BACKUP_REGISTER_COUNT: usize;
#[cfg(feature = "low-power")] #[cfg(feature = "low-power")]
#[cfg(not(stm32u5))]
const EXTI_WAKEUP_LINE: usize; const EXTI_WAKEUP_LINE: usize;
#[cfg(feature = "low-power")] #[cfg(feature = "low-power")]

View File

@ -140,6 +140,8 @@ impl SealedInstance for crate::peripherals::RTC {
} else if #[cfg(any(stm32l5, stm32h5))] { } else if #[cfg(any(stm32l5, stm32h5))] {
const EXTI_WAKEUP_LINE: usize = 17; const EXTI_WAKEUP_LINE: usize = 17;
type WakeupInterrupt = crate::interrupt::typelevel::RTC; type WakeupInterrupt = crate::interrupt::typelevel::RTC;
} else if #[cfg(stm32u5)] {
type WakeupInterrupt = crate::interrupt::typelevel::RTC;
} }
); );