-
Notifications
You must be signed in to change notification settings - Fork 280
deep sleep api for esp32 #574
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
Conversation
Thanks for working on this, looking forward to it being ready for review! Please let me know if there is anything we can do to support you in the meantime. |
@jessebraham I'd love thoughts on what the API should be - particularly with respect to ownership, for instance when you're going to wake using ext0 (RTC GPIO pin) the pin needs to be setup to be routed to RTC - and set in the RTC_IO ext_wakeup0 register - should that be handled in sleep or should that be separately managed by the user? |
b48671f
to
31ba351
Compare
Disclaimer: I'm just shouting in from the sidelines. That is actually pretty nice, good job! For what it's worth, I think I would still prefer if creating a wakeup source would immediately configure it. It wouldn't be hard from here - make the user create the WakeupTriggers object, then pass it to each WakeupSource constructor that immediately applies itself (or not if you want them reusable). Then, WakeupTriggers could be used to start the sleep, maybe. The only difference would be that this way we wouldn't require |
I think I need to implement |
I like this idea, however I have some concerns: (apologies in advance for the rambling below) There is also a Also - what should happen if the a WakeSource instance dropped after it had been applied and before the sleep? We would need to undo the changes to Maybe make the apply method from the wake source return a EDIT: maybe make a
To be passed to sleep() instead of the array. |
well
has the issue that you have to specify a type for |
You can do a trick like I did in the object-chain crate, where you build up a type in compile time. It will not be very nice, though, and not very flexible. |
My two cents: This looks already good and maybe we should just get it in a mergeable shape (checking comments and documentation) and merge it. Then the community can iterate on the API based on real use cases I don't think having breaking API changes here in the future is going to be a big problem (like we currently have them everywhere) |
I'm sort of leaning towards what @bjoernQ has said as well. We can nitpick the API as much as we want, but I think this is very useful already in its current state and we can open issues for any problems which have been identified. I'd prefer to have an imperfect solution than no solution at all :) (Also I'm sorry it's taken us so long to come to this conclusion!) I think if you're able to please rebase then this is probably pretty much good to go. |
Sorry for being a cause of delay here. I have some interest in adapting this PR to the S3, so I'd second getting this merged sooner than later. |
add Ext0 wakeup source (WIP/Non-working)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - just want to wait for Jesse's approval before merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you once again for all your work on this, LGTM!
* deep sleep api for esp32 * move to list of wakeup sources * improve Ext0WakeupSource - still WIP * add deep sleep with timer wakeup example add Ext0 wakeup source (WIP/Non-working) * removed alloc (using heapless now) * Sleep: ext0 wakeup working * add sleep_timer_ext0 example * API change: move sleep into RTC as sleep, sleep_deep, sleep_light * fix sleep examples for new API * sleep only implemented for esp32 at this time * sleep only implemented for esp32 at this time * Implement a simple RTCPin trait to support sleep * implement RTCPin for all xtensa SOC * cargo fmt & update changelog * fix change log order (accidentally swaped during rebase) * implement Drop for Ext0WakeupSource * added Ext1 wakeup source * cargo fmt * healpess was unused, removed * fix pase macro usage
Hi, sorry for commenting on this closed issue. |
In the examples? To make sure the print messages are sent before the UART is powered down. |
Sorry, I meant here: https://github.com/liebman/esp-hal/blob/a2b0941001a95366759009c3206b980423769e9e/esp-hal-common/src/rtc_cntl/mod.rs#L239 |
I'd have to assume then that this was left in by mistake. Please open an issue so we don't loose track of this. |
This is an implementation of deep and light sleep for esp32. Included is a minimal implementation of RTCPin for RTC GPIO pins for Xtensa chips.
Wakeup sources implemented:
Examples for wake up:
Most of the settings for sleep were pulled from
esp-idf
or gleaned by comparing register settings betweenesp-idf-hal
andesp32-hal
directly after an initial boot and after wakeup from sleep. Note in particularRtcSleepConfig::base_settings
which are theRTC_CTRL
differences after boot betweenesp-idf-hal
andesp32-hal
.In Deep sleep I'm seeing about 0.15mA with a ESP32-WROOM32 module on a custom board.
Thank you!
Thank you for your contribution.
Please make sure that your submission includes the following:
Must
errors
orwarnings
.cargo fmt
was run.CHANGELOG.md
in the proper section.Nice to have