mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 00:02:28 +00:00
Merge pull request #3496 from chrenderle/u5-low-power
low-power: add support for stm32u5
This commit is contained in:
commit
650f97924a
@ -112,10 +112,10 @@ pub enum StopMode {
|
||||
Stop2,
|
||||
}
|
||||
|
||||
#[cfg(any(stm32l4, stm32l5))]
|
||||
#[cfg(any(stm32l4, stm32l5, stm32u5))]
|
||||
use stm32_metapac::pwr::vals::Lpms;
|
||||
|
||||
#[cfg(any(stm32l4, stm32l5))]
|
||||
#[cfg(any(stm32l4, stm32l5, stm32u5))]
|
||||
impl Into<Lpms> for StopMode {
|
||||
fn into(self) -> Lpms {
|
||||
match self {
|
||||
@ -184,7 +184,7 @@ impl Executor {
|
||||
|
||||
#[allow(unused_variables)]
|
||||
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()));
|
||||
#[cfg(stm32h5)]
|
||||
crate::pac::PWR.pmcr().modify(|v| {
|
||||
|
@ -65,7 +65,7 @@ pub(crate) enum WakeupPrescaler {
|
||||
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 {
|
||||
fn from(val: WakeupPrescaler) -> Self {
|
||||
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 {
|
||||
fn from(val: crate::pac::rtc::vals::Wucksel) -> Self {
|
||||
use crate::pac::rtc::vals::Wucksel;
|
||||
@ -219,12 +219,21 @@ impl Rtc {
|
||||
|
||||
pub(crate) fn enable_wakeup_line(&self) {
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
use crate::pac::EXTI;
|
||||
|
||||
<RTC as crate::rtc::SealedInstance>::WakeupInterrupt::unpend();
|
||||
unsafe { <RTC as crate::rtc::SealedInstance>::WakeupInterrupt::enable() };
|
||||
|
||||
#[cfg(not(stm32u5))]
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -285,6 +285,7 @@ trait SealedInstance {
|
||||
const BACKUP_REGISTER_COUNT: usize;
|
||||
|
||||
#[cfg(feature = "low-power")]
|
||||
#[cfg(not(stm32u5))]
|
||||
const EXTI_WAKEUP_LINE: usize;
|
||||
|
||||
#[cfg(feature = "low-power")]
|
||||
|
@ -140,6 +140,8 @@ impl SealedInstance for crate::peripherals::RTC {
|
||||
} else if #[cfg(any(stm32l5, stm32h5))] {
|
||||
const EXTI_WAKEUP_LINE: usize = 17;
|
||||
type WakeupInterrupt = crate::interrupt::typelevel::RTC;
|
||||
} else if #[cfg(stm32u5)] {
|
||||
type WakeupInterrupt = crate::interrupt::typelevel::RTC;
|
||||
}
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user