mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 00:02:28 +00:00
low-power: add stop support for stm32l5
This commit is contained in:
parent
cbdd570ad5
commit
f1c077ed2e
@ -157,7 +157,7 @@ pub struct Config {
|
||||
/// RCC config.
|
||||
pub rcc: rcc::Config,
|
||||
|
||||
/// Enable debug during sleep.
|
||||
/// Enable debug during sleep and stop.
|
||||
///
|
||||
/// May incrase power consumption. Defaults to true.
|
||||
#[cfg(dbgmcu)]
|
||||
|
@ -37,6 +37,8 @@
|
||||
//! async fn async_main(spawner: Spawner) {
|
||||
//! // initialize the platform...
|
||||
//! let mut config = embassy_stm32::Config::default();
|
||||
//! // when enabled the power-consumption is much higher during stop, but debugging and RTT is working
|
||||
//! config.enable_debug_during_sleep = false;
|
||||
//! let p = embassy_stm32::init(config);
|
||||
//!
|
||||
//! // give the RTC to the executor...
|
||||
@ -107,6 +109,19 @@ pub enum StopMode {
|
||||
Stop2,
|
||||
}
|
||||
|
||||
#[cfg(stm32l5)]
|
||||
use stm32_metapac::pwr::vals::Lpms;
|
||||
|
||||
#[cfg(stm32l5)]
|
||||
impl Into<Lpms> for StopMode {
|
||||
fn into(self) -> Lpms {
|
||||
match self {
|
||||
StopMode::Stop1 => Lpms::STOP1,
|
||||
StopMode::Stop2 => Lpms::STOP2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Thread mode executor, using WFE/SEV.
|
||||
///
|
||||
/// This is the simplest and most common kind of executor. It runs on
|
||||
@ -164,8 +179,9 @@ impl Executor {
|
||||
}
|
||||
}
|
||||
|
||||
fn configure_stop(&mut self, _stop_mode: StopMode) {
|
||||
// TODO: configure chip-specific settings for stop
|
||||
fn configure_stop(&mut self, stop_mode: StopMode) {
|
||||
#[cfg(stm32l5)]
|
||||
crate::pac::PWR.cr1().modify(|m| m.set_lpms(stop_mode.into()));
|
||||
}
|
||||
|
||||
fn configure_pwr(&mut self) {
|
||||
|
Loading…
Reference in New Issue
Block a user