-
Notifications
You must be signed in to change notification settings - Fork 221
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 UART wakeup source #1727
Add UART wakeup source #1727
Conversation
/// Panics if `threshold` is out of bounds. | ||
pub fn new(threshold: u16) -> Self { | ||
if threshold > 1023 { | ||
panic!("Invalid threshold"); |
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.
I think in this case a panic gets much less into user's ways than having to check a Result
which might just gets unwrapped
@@ -131,6 +131,71 @@ impl<'a, 'b> RtcioWakeupSource<'a, 'b> { | |||
} | |||
} | |||
|
|||
macro_rules! uart_wakeup_impl { |
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.
could have implemented some trait on the UARTs and have generics but I think in this very simple case a macro is not a bad way to do it
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! Could/should we add a small test for this (just like the testing example that you provided)?
Ideally having the whole sleep stuff covered by HIL testing would be great, I think. Not sure if adding more examples is a good idea since we already have a couple of (somewhat redundant) sleep examples 🤔 While we cannot really test most wake-up sources with the current setup, at least a simple test for light-sleep with a timer wake-up should be possible (hopefully - no sure how probe-rs will like the chip getting to sleep). Will try to add that and maybe create a separate PR 👍 |
mhhh - not unexpectedly probe-rs doesn't like a sleeping chip 😞 |
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! If you could just rebase please it this should be good to merge.
e0956cf
to
17d993a
Compare
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo xtask fmt-packages
command to ensure that all changed code is formatted correctly.CHANGELOG.md
in the proper section.Extra:
Pull Request Details 📖
Description
This adds uart as a wake-up source. Like with #1724 this adds it for all chips but anything besides ESP32-C6 currently seems to have light-sleep issues.
Starting with C6 there are more ways to configure UART-wake-up but those additional options didn't "just work" for me and they are apparently not available in ESP-IDF - so let's keep that for later when we can see what is really needed to make them work.
Testing
Use this example