aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Enderle <[email protected]>2024-01-02 23:05:47 +0100
committerChristian Enderle <[email protected]>2024-01-02 23:05:47 +0100
commitf1c077ed2e420b1b4f8c1835fe05a1279a742267 (patch)
tree2c013a92a3c83427c1fe1dd75042fd7853fbf3b2
parentcbdd570ad55c841ad80ab76b5d77c4ed930a6109 (diff)
low-power: add stop support for stm32l5
-rw-r--r--embassy-stm32/src/lib.rs2
-rw-r--r--embassy-stm32/src/low_power.rs20
2 files changed, 19 insertions, 3 deletions
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs
index 2508c4fca..45a2ab63e 100644
--- a/embassy-stm32/src/lib.rs
+++ b/embassy-stm32/src/lib.rs
@@ -157,7 +157,7 @@ pub struct Config {
157 /// RCC config. 157 /// RCC config.
158 pub rcc: rcc::Config, 158 pub rcc: rcc::Config,
159 159
160 /// Enable debug during sleep. 160 /// Enable debug during sleep and stop.
161 /// 161 ///
162 /// May incrase power consumption. Defaults to true. 162 /// May incrase power consumption. Defaults to true.
163 #[cfg(dbgmcu)] 163 #[cfg(dbgmcu)]
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs
index 4fab8dae4..c5c5dd96f 100644
--- a/embassy-stm32/src/low_power.rs
+++ b/embassy-stm32/src/low_power.rs
@@ -37,6 +37,8 @@
37//! async fn async_main(spawner: Spawner) { 37//! async fn async_main(spawner: Spawner) {
38//! // initialize the platform... 38//! // initialize the platform...
39//! let mut config = embassy_stm32::Config::default(); 39//! let mut config = embassy_stm32::Config::default();
40//! // when enabled the power-consumption is much higher during stop, but debugging and RTT is working
41//! config.enable_debug_during_sleep = false;
40//! let p = embassy_stm32::init(config); 42//! let p = embassy_stm32::init(config);
41//! 43//!
42//! // give the RTC to the executor... 44//! // give the RTC to the executor...
@@ -107,6 +109,19 @@ pub enum StopMode {
107 Stop2, 109 Stop2,
108} 110}
109 111
112#[cfg(stm32l5)]
113use stm32_metapac::pwr::vals::Lpms;
114
115#[cfg(stm32l5)]
116impl Into<Lpms> for StopMode {
117 fn into(self) -> Lpms {
118 match self {
119 StopMode::Stop1 => Lpms::STOP1,
120 StopMode::Stop2 => Lpms::STOP2,
121 }
122 }
123}
124
110/// Thread mode executor, using WFE/SEV. 125/// Thread mode executor, using WFE/SEV.
111/// 126///
112/// This is the simplest and most common kind of executor. It runs on 127/// This is the simplest and most common kind of executor. It runs on
@@ -164,8 +179,9 @@ impl Executor {
164 } 179 }
165 } 180 }
166 181
167 fn configure_stop(&mut self, _stop_mode: StopMode) { 182 fn configure_stop(&mut self, stop_mode: StopMode) {
168 // TODO: configure chip-specific settings for stop 183 #[cfg(stm32l5)]
184 crate::pac::PWR.cr1().modify(|m| m.set_lpms(stop_mode.into()));
169 } 185 }
170 186
171 fn configure_pwr(&mut self) { 187 fn configure_pwr(&mut self) {