embassy-stm32

Crates

git

Versions

stm32l011f4

Flavors

Module low_power

Module low_power 

Source
Expand description

Low-power support.

The STM32 line of microcontrollers support various deep-sleep modes which exploit clock-gating to reduce power consumption. The embassy-stm32 HAL provides a sleep() function 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 possible.

sleep() 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:

  • GPIO
  • RTC

Other peripherals which block stop when busy include (this list may be stale):

  • I2C
  • USART

Since entering and leaving low-power modes typically incurs a significant latency, sleep() will only attempt to enter when the next timer event is at least [config.min_stop_pause] in the future.

embassy-stm32 also provides an embassy-executor platform implementation that integrates sleep() into the main loop. It is available in the embassy_stm32::executor module, and is enabled by the executor-thread or executor-interrupt features. This stm32-specific executor is the preferred way to lower power consumption if you’re using async, instead of calling sleep() directly.

Re-exports§

pub use crate::rcc::StopMode;

Functions§

sleep
Sleep with WFI, attempting to enter the deepest STOP mode possible.