-
Notifications
You must be signed in to change notification settings - Fork 687
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
Standardise order for setting GPIO pin default values #2942
Conversation
Depending on the specific implementation of how the MCU interfaces with the code, the default state may be to leave all IO pins NC, neither pulled high nor low. If this is the case, and by setting the state of the pin via Overall, if it is not critical to NEVER have the pin set as something else, there is no need to check with the MCU for startup glitches, default driving, and set the Because of this, I may actually change all "initialising" of pins to their Meshastatic-decided default values to call I would like your thoughts on this, should we change all instances as shown in files changed to call |
Yes, I think it makes sense to call |
🤖 Pull request artifacts
|
On my ESP32-S3 dev board, I measure that turning the board on, if a pin isn't configured by I also measure that once I haven't specifically tested strapping pins. Some pins (GPIO 0) have weak resistors pulling up/down. In GPIO 0 (BOOT)'s case, it's a weak internal pullup to 3.3V. As pins default to being pulled LOW once pinMode is set, I believe the default state should be set before the pinMode is set. I don't have an osciliscope to measure if in this configuration there is a tiny moment where it is pulled low, but I would assume not, that it just applies what is in the IO table (which defaults to 0, but we we set it to 1 (digital) it applies that instead). This is only the behaviour on the ESP32-S3, other platforms (nRF52, RP2040, etc.) will vary. But we have not seen any problems calling writes right before pinMode is set, so I will change them all to be like this. The risk I can think of is if there is a low driven relay, this could cause unexpected behaviour. Or an external component is pulled high externally to be turned on at boot, but setting the pinMode before writing HIGH to it anyway could make it power cycle that external component. |
…stic#2942)" This reverts commit 2544733.
In cases where a digitalWrite is (clearly) called on a pin, and then pinMode is set for that same pin, the two lines are flipped such that the pinMode is set before calling the digitalWrite.