-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ESP32-S2: Add IDF pin resets to Microcontroller #3643
Conversation
I'm not sure we want to use gpio_pin_reset because 1) it enables pull up and 2) attaches GPIO to the output. (Source) The pull up behavior doesn't match other ports and we may want to switch back to the default pin function such as JTAG. We definitely should refine this code though. We do want to reset individual pins. |
We could store a table of default pin setting information, the way we do for the i.MX, and revert to that? |
@hierophect I don't think you need that. The ESP32-S2 IOMUX can be set back to digital function 0 which is the default. The GPIO mux can be set back to its default as well. |
@tannewt I've replaced the resets with |
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.
Are you sure this resets the IOMUX too? Also, you need to make sure the idf isn't changed.
How do you know this/what functions have you seen used to do it? I'm finding the IOMUX to be scant on both online and inline documentation. |
For folks following along. The best places to get details about the chip and the IOMUX are the datasheet and the technical reference. |
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.
Looks good to me! Thank you!
I do want to note that the IDF includes this comment in the
So it's feasible that if someone who really cares about power savings might want to either tweak this in their own version, or implement a new pin modification function that sets the pins to this lower power consuming state. |
@tannewt also, before I merge anything, my latest commit still wasn't quite what you'd asked for, since it still sets the IOMUX to 1 as per the default inside
which halts GPIO output and sets the IOMUX to Function 0. But my concern is that Digital Function 0 can default to things like the DAC or SPI, and since they circumvent the GPIO, this could result in the exact kind of behavior we're trying to avoid, where peripherals continue to deliver output to the pin even after a reset. So my recommendation is to use what I've implemented, but I wanted to let you know about this alternative. |
We can always do this later. I'm sure there are bigger power savings to do before that.
Digital function 0 is what we should use because UART0 and JTAG are enabled by it. (Not the DAC because it's analog.) It's ok if one of the SPIs is connected. We can fix that later if need be. The other SPI is for flash and ram so we definitely want to leave it. |
@tannewt I've changed the pin function to 0 in the pin reset process with |
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.
Looks good! Thank you!
This PR adds the ESP-IDF
gpio_reset_pin
function to the Microcontroller/Pin module'sreset_pin_number
andreset_all_pins
. This should resolve issues where pins would remain connected to previously used peripherals even after soft reboots or de-inits, since the IDF does not alter the pin matrix for most peripheral de-init functions.Tested on the Saola 1 Wrover with Neopixel and I2C. Any help testing additional applications for unforeseen problems would be appreciated.