Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more efficient mode for STM32L4XX stop mode #1097

Merged
merged 8 commits into from
Jul 3, 2020
Merged

Use more efficient mode for STM32L4XX stop mode #1097

merged 8 commits into from
Jul 3, 2020

Conversation

angelnu
Copy link
Contributor

@angelnu angelnu commented Jun 12, 2020

Summary

This PR fixes/implements the following bugs/features

  • Feature 1 - save power in stop mode for STM32L4XX devices
  • Feature 2 - Use MSI as wake up clock when available
  • Breaking changes

Feature 1
Currently the low power library uses HAL_PWR_EnterSTOPMode for all devices. This does not leverage the stop2 mode which is available in the STM32L4XX. This results in 4,6 uA instead of 1,35 uA in my nucleo_l412kb.

Stop1 is only required when the UART device needs to wake up. So when not used the patch calls HAL_PWREx_EnterSTOP2Mode directly.

Feature 2
When available use the MSI as wake up clock. This avoids starting the HSI which generates a short spike of ca 300 uA until the SystemClock_ConfigFromStop is called.

Validation

  • Ensure CI build is passed.
  • Demonstrate the code is solid. [e.g. Provide a sketch]

Not adding a new sketch since no external APIs are changed by this patch.

Code formatting

  • Ensure AStyle check is passed thanks CI

Closing issues
NA

@fpistm
Copy link
Member

fpistm commented Jun 12, 2020

Hi @angelnu
as you know I'm currently working on the SubSeconds managements and I'm studying to move the low power driver to the Low Power library. Anyway, I have to study the impact of the mode you propose.

@angelnu
Copy link
Contributor Author

angelnu commented Jun 12, 2020

Jep, I know (looking forward to it) :-)

This patch is independent from the sleep time. I made it specific for the STM32L4 since this is the only device I have that supports STOP2. It would be nice if there would be a define for all platforms with STOP2...

I hope I can get the style check to agree so the patch is ready. If you have any other feedback you would like to get here please let me know.

libraries/SrcWrapper/src/stm32/low_power.c Outdated Show resolved Hide resolved
@fpistm fpistm added this to In progress in STM32 core based on ST HAL via automation Jul 3, 2020
@fpistm fpistm added this to the 2.0.0 milestone Jul 3, 2020
@fpistm fpistm merged commit 348fdc4 into stm32duino:master Jul 3, 2020
STM32 core based on ST HAL automation moved this from In progress to Done Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants