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

Add PWR API, support for wake-up via EXTI #25

Merged
merged 9 commits into from
Aug 10, 2019
Merged

Add PWR API, support for wake-up via EXTI #25

merged 9 commits into from
Aug 10, 2019

Conversation

hannobraun
Copy link
Contributor

Add a PRW API with support for Sleep and Stop modes, as well as a method that goes to sleep and waits for an EXTI interrupt. I also snuck in some clean-up of the prelude module, while I was in there.

cc @lthiery

So far, there's just one method, to enter sleep mode.
This is useful for restoring the previous clock configuration after
waking up from Stop mode, but it might also be useful for other
purposes.
Having this trait makes it possible to write sleep functions that are
generic over the specific power mode being used.
@hannobraun
Copy link
Contributor Author

I just noticed I forgot to enable the PWR peripheral clock. I did not notice earlier because everything worked as expected. This could happen because the main work here is being done by SCB, RCC, and wfi, and the PWR interface only serves a secondary role.

Only Stop mode is affected. I think that Stop mode is actually still entered (because I explicitly saw a slower clock after wake-up before I figured out I need to set STOPWUCK), but the extra configuration is probably non-functional. I'll push another commit to fix this shortly.

This should have been done from the beginning, but it slipped through
because things basically worked as expected.

This was possible because the bulk of the work here is done by SCB, RCC,
and of course `wfi`. The PWR peripheral only takes care of some
secondary configuration.
@hannobraun
Copy link
Contributor Author

Pushed another commit. As best as I can tell, everything should work as expected. Once I've implemented more power modes (should happen in a few weeks), I'll do more testing with some actual current measurement.

@hannobraun hannobraun mentioned this pull request Aug 9, 2019
@arkorobotics arkorobotics merged commit c94879b into stm32-rs:master Aug 10, 2019
@arkorobotics
Copy link
Member

Nice! Thanks so much for the PR.

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