cpu/stm32_common: minimize power consumption on STM32L1#10052
cpu/stm32_common: minimize power consumption on STM32L1#10052olegart wants to merge 9 commits intoRIOT-OS:masterfrom
Conversation
|
@MichelRottleuthner this is a good candidate for you to review, right :-)? |
|
@olegart would you address the codacy issue please? |
First one addressed, on the second issue (whether uint32_t is an unsigned int or a long unsigned int) Codacy is in disagreement with gcc-7. |
05bfeaf to
08398f3
Compare
| /* initialize the system clock as configured in the periph_conf.h */ | ||
| stmclk_init_sysclk(); | ||
|
|
||
| #if defined(CPU_FAM_STM32L1) |
There was a problem hiding this comment.
This approach is valid for the whole stm32 family AFAIK
There was a problem hiding this comment.
It's valid, but not needed at least on L0 and L4 - they have GPIO configured as analog inputs by default (see default MODER value in the Reference Manual).
Not sure about F1 (not an energy-efficient series anyway), but probably newer F-series don't need it either.
|
Added option (enabled by default) to preserve the state of JTAG pins - PA13, PA14, PA15, PB2 and PB3 configured as Alternate Function Mode. Doesn't affect power consumption if those pins are left floated. |
|
Closing since ##11832 was merged. |
Contribution description
Automatically configure all STM32L1 GPIOs as analog inputs.
GPIOs on STM32L1 MCUs are configured as digital inputs with Schmitt triggers, which means, if they are left floating, their power consumption is not 0 but few microamperes per GPIO due to random noise on high-impedance pin and constant random trigger switching.
To achieve minimum possible consumption, GPIOs must be reconfigured as analog inputs. It can be done automatically during MCU initialization.
Function needs cpu_check_address to check what GPIOs are available (it depends on MCU package and so can't be deduced from MCU model data available to RIOT).
Newer STM32 energy-efficient series (L0, L4) already have GPIO configured as AIN by default.
Testing procedure
STM32L1 power consumption without this patch in STOP+RTC mode and GPIOs left floating may be as high as 100 uA. With the patch, it should be < 2 uA.
Issues/PRs references
Depends on PR #10051