Skip to content

py/port/esp32 support on esp32c3 for deepsleep wakeup with gpio pins #15498

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

m-cas
Copy link

@m-cas m-cas commented Jul 19, 2024

Adding support on esp32c3 port for deepsleep wakeup with gpio pins and retriving the pin(s) that triggered the wakeup

Summary

The current support for the ESP32C3 platform contains errors preventing the usage of deep sleep wakeup with pins. Two older PRs (#13333 and #7990) were created to fix this using gpio pins and to add the necessary calls to retrieve the pin(s) that triggered the wake. I have refactored the code, updated to the latest master (e.g. STATIC -> static) and tested.

Testing

I created a new version of the firmware for a project of mine and it has been working since months.

Trade-offs and Alternatives

No tradeoffs that I am aware of.

…d retriving the pin(s) that triggered the wakeup
@m-cas m-cas changed the title Adding support on esp32c3 port for deepsleep wakeup with gpio pins an… Support on esp32c3 port for deepsleep wakeup with gpio pins Jul 19, 2024
@m-cas m-cas changed the title Support on esp32c3 port for deepsleep wakeup with gpio pins py/port/esp32 support on esp32c3 for deepsleep wakeup with gpio pins Jul 19, 2024
@m-cas
Copy link
Author

m-cas commented Jul 19, 2024

To publish this PR I had to learn git, GitHub, and a bunch of other things like ssh keys, tokens, etc etc
Honest, I have no idea what I need to fix in the failed checks, if someone would be so kind to help or simply tell me what I have to do I am more than happy to.

Copy link
Contributor

@projectgus projectgus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @m-cas for picking up this long-standing feature PR.

As mentioned on some of the earlier incarnations, I feel like there's an opportunity here to add ESP32-C3 pin wake functionality via the existing machine.Pin.irq(wake=) argument (see `esp32/machine_pin.c). This is the standard non-port-specific way to do wakeup. It's actually a good fit for the C3 because there isn't the weird distinction between EXT0 and EXT1.

What do you think about this idea?

@@ -166,6 +166,24 @@ Power related functions

Availability: ESP32, WiPy.

.. function:: wake_ext1_pins()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The machine module, as much as possible, should contain port-agnostic functions. So the options here would be:

  1. Move these functions to the esp32 module, as they're port specific.
  2. Make a generic wake_pins() function and document it as only available currently on the ESP32 port. This creates the possibility that other ports can support it in the future.

I don't know if returning only the EXT1 wake pins as a wake_pins() result would be too misleading or not, but I assume the function could be extended to include EXT0 pins if there were any?

@projectgus
Copy link
Contributor

projectgus commented Jan 29, 2025

, I have no idea what I need to fix in the failed checks, if someone would be so kind to help or simply tell me what I have to do I am more than happy to.

Unfortunately the CI logs have been cleaned up, but if you rebase this commit and push again then it'll refresh.

The general docs for contributing are here: https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md

My guess is what you'll need to do is:

  • Re-write the commit message to have a shorter first line, some short body description, and a Signed-off-by line. Look in the micropython git log for some examples of what it's looking for.
  • Run uncrustify (see CODECONVENTIONS doc) and apply whatever small tweaks it makes to the C code formatting.

You should be able to use git commit --amend to apply the changes, then force-push the updated branch. Jim has a guide for this process at https://github.com/jimmo/git-and-micropython#README - or there are many non-MicroPython-specific guides out there.

@damian-barker
Copy link

Hi. Firstly thanks for all the work you guys did.on this but im still confused as to the current status. Simply put if i use the latest micropython build for an esp32 c3 and want to use deepsleep and wake on the state change of a gpio pin..(doesnt matter which one and it doesnt matter to my program which one woke it) , my application just needs to wake and connect to wifi and send some data... will it work?

@m-cas
Copy link
Author

m-cas commented Feb 11, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants