Skip to content

Comments

stm32: Add standby mode support#3891

Draft
rappet wants to merge 1 commit intoembassy-rs:mainfrom
rappet:stm32-standby
Draft

stm32: Add standby mode support#3891
rappet wants to merge 1 commit intoembassy-rs:mainfrom
rappet:stm32-standby

Conversation

@rappet
Copy link

@rappet rappet commented Feb 17, 2025

This is currently work in progress. Following things are missing in my opinion.

  • clearer documentation
  • RTC configuration (at least the option to disable it until alarms are supported in general)
  • WKUP pins
  • add and test more chips

Tested only with an STM32F103 and STM32L031

I don't have a good idea how to build a good API for the WKUP pins.
They are quite a bit different than usual hardware as you can just steal the affected pins from other peripherals
as the chip is stopped anyway (and you might have already used them for a button that you also want to use for waking for example).

I currently see an array/struct with a Config for each pin.

Depending on series, there is also some difference between the WKUP pins. I know at least of those variants:

  • if enabled, set to pull down and wake on high/rising edge
  • if enabled, wake on low/falling edge or high/rising edge depending on wake-up pin polarity flag

/// it will not be disabled and can still reset the core if it was not pet.
/// This can also be used to wake up after and inaccurate amount of time has passed in standby mode,
/// which has the advantage that it is in most cases less power hungry than the RTC.
pub fn standby(_config: &StandbyConfig) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn standby(_config: &StandbyConfig) {
pub fn standby(_config: &StandbyConfig) -> ! {

denotes nicely that this doesn't return.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, had to move unreachable! out of the critical section.

Currently tested only with a STM32F103 and STM32L031

- STM32F103 current was <50uA for a whole "BluePill" devboard from WeAct
  Studio, with the Power LED desoldered.
  - WKUP behaves weird, need to debug
- STM32L031 was tested using a custom PCB with <3uA
- STM32F411CEU was tested on a "BlackPill" devboard from WeAct Studio.
- STM32H743VIT6 was tested on a devboard from WeAct Studio.

For the measurements I used a very cheap multimeter. I only expect the
measurements to be roughly in the same order of magnitude.

If not specified, current was not measured.

WKUP has to be reworked to be a stable API

Signed-off-by: Raphael Peters <rappet@rappet.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants