Merge pull request #2368 from chrenderle/l5-rtc
Add low-power support for stm32l5
This commit is contained in:
commit
750aa3ceec
2 changed files with 19 additions and 7 deletions
|
@ -24,7 +24,7 @@ use crate::time::Hertz;
|
||||||
),
|
),
|
||||||
path = "v2.rs"
|
path = "v2.rs"
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(any(rtc_v3, rtc_v3u5), path = "v3.rs")]
|
#[cfg_attr(any(rtc_v3, rtc_v3u5, rtc_v3l5), path = "v3.rs")]
|
||||||
mod _version;
|
mod _version;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
pub use _version::*;
|
pub use _version::*;
|
||||||
|
@ -43,7 +43,7 @@ pub(crate) enum WakeupPrescaler {
|
||||||
Div16 = 16,
|
Div16 = 16,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(stm32wb, stm32f4, stm32l0, stm32g4))]
|
#[cfg(any(stm32wb, stm32f4, stm32l0, stm32g4, stm32l5))]
|
||||||
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, stm32l5))]
|
||||||
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;
|
||||||
|
@ -348,7 +348,7 @@ impl Rtc {
|
||||||
) {
|
) {
|
||||||
use embassy_time::{Duration, TICK_HZ};
|
use embassy_time::{Duration, TICK_HZ};
|
||||||
|
|
||||||
#[cfg(any(rtc_v3, rtc_v3u5))]
|
#[cfg(any(rtc_v3, rtc_v3u5, rtc_v3l5))]
|
||||||
use crate::pac::rtc::vals::Calrf;
|
use crate::pac::rtc::vals::Calrf;
|
||||||
|
|
||||||
// Panic if the rcc mod knows we're not using low-power rtc
|
// Panic if the rcc mod knows we're not using low-power rtc
|
||||||
|
@ -375,7 +375,7 @@ impl Rtc {
|
||||||
while !regs.isr().read().wutwf() {}
|
while !regs.isr().read().wutwf() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(rtc_v3, rtc_v3u5))]
|
#[cfg(any(rtc_v3, rtc_v3u5, rtc_v3l5))]
|
||||||
{
|
{
|
||||||
regs.scr().write(|w| w.set_cwutf(Calrf::CLEAR));
|
regs.scr().write(|w| w.set_cwutf(Calrf::CLEAR));
|
||||||
while !regs.icsr().read().wutwf() {}
|
while !regs.icsr().read().wutwf() {}
|
||||||
|
@ -404,7 +404,7 @@ impl Rtc {
|
||||||
/// was called, otherwise none
|
/// was called, otherwise none
|
||||||
pub(crate) fn stop_wakeup_alarm(&self, cs: critical_section::CriticalSection) -> Option<embassy_time::Duration> {
|
pub(crate) fn stop_wakeup_alarm(&self, cs: critical_section::CriticalSection) -> Option<embassy_time::Duration> {
|
||||||
use crate::interrupt::typelevel::Interrupt;
|
use crate::interrupt::typelevel::Interrupt;
|
||||||
#[cfg(any(rtc_v3, rtc_v3u5))]
|
#[cfg(any(rtc_v3, rtc_v3u5, rtc_v3l5))]
|
||||||
use crate::pac::rtc::vals::Calrf;
|
use crate::pac::rtc::vals::Calrf;
|
||||||
|
|
||||||
let instant = self.instant().unwrap();
|
let instant = self.instant().unwrap();
|
||||||
|
@ -420,13 +420,19 @@ impl Rtc {
|
||||||
))]
|
))]
|
||||||
regs.isr().modify(|w| w.set_wutf(false));
|
regs.isr().modify(|w| w.set_wutf(false));
|
||||||
|
|
||||||
#[cfg(any(rtc_v3, rtc_v3u5))]
|
#[cfg(any(rtc_v3, rtc_v3u5, rtc_v3l5))]
|
||||||
regs.scr().write(|w| w.set_cwutf(Calrf::CLEAR));
|
regs.scr().write(|w| w.set_cwutf(Calrf::CLEAR));
|
||||||
|
|
||||||
|
#[cfg(not(stm32l5))]
|
||||||
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));
|
||||||
|
|
||||||
|
#[cfg(stm32l5)]
|
||||||
|
crate::pac::EXTI
|
||||||
|
.fpr(0)
|
||||||
|
.modify(|w| w.set_line(RTC::EXTI_WAKEUP_LINE, true));
|
||||||
|
|
||||||
<RTC as crate::rtc::sealed::Instance>::WakeupInterrupt::unpend();
|
<RTC as crate::rtc::sealed::Instance>::WakeupInterrupt::unpend();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,12 @@ impl sealed::Instance for crate::peripherals::RTC {
|
||||||
#[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", stm32l5))]
|
||||||
|
const EXTI_WAKEUP_LINE: usize = 17;
|
||||||
|
|
||||||
|
#[cfg(all(feature = "low-power", stm32l5))]
|
||||||
|
type WakeupInterrupt = crate::interrupt::typelevel::RTC;
|
||||||
|
|
||||||
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 {
|
||||||
|
|
Loading…
Reference in a new issue