Expand description
Low-power support.
The STM32 line of microcontrollers support various deep-sleep modes which exploit clock-gating
to reduce power consumption. embassy-stm32 provides a low-power executor, Executor which
can use knowledge of which peripherals are currently blocked upon to transparently and safely
enter such low-power modes including STOP1 and STOP2 when idle.
The executor determines which peripherals are active by their RCC state; consequently,
low-power states can only be entered if peripherals which block stop have been drop’d and if
peripherals that do not block stop are busy. Peripherals which never block stop include:
GPIORTC
Other peripherals which block stop when busy include (this list may be stale):
I2CUSART
Since entering and leaving low-power modes typically incurs a significant latency, the
low-power executor will only attempt to enter when the next timer event is at least
[config.min_stop_pause] in the future.
use embassy_executor::Spawner;
use embassy_time::Duration;
#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
async fn main(spawner: Spawner) {
// initialize the platform...
let mut config = embassy_stm32::Config::default();
// the default value, but can be adjusted
config.min_stop_pause = Duration::from_millis(250);
// 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);
// your application here...
}Re-exports§
pub use crate::rcc::StopMode;
Structs§
- Device
Busy - Prevent the device from going into the stop mode if held
- Executor
- Thread mode executor, using WFE/SEV.
Functions§
- stop_
ready - Get whether the core is ready to enter the given stop mode.