Release leftover low power routing when a software I2C port is initialized - #239
Merged
Merged
Conversation
…lized A pin routed to the low power I2C keeps that routing across a reset, because it is held in the low power domain rather than by the CPU. set_pin() already hands such pins back before taking them for a hardware port, but the software port path did not: the bit-banged lines stayed bound to the low power peripheral and never reached the pads, so the board autodetect probe (which runs on a software port) failed on every warm boot until a power cycle reset the routing. Release the pads in init() for a software port as well, the same way the hardware port path does.
There was a problem hiding this comment.
Pull request overview
This PR fixes warm-boot / deep-sleep-wake I2C failures on ESP32 targets where a GPIO previously routed to the low-power (LP) I2C peripheral stays bound across reset. It aligns the software (bit-banged) I2C initialization path with the existing hardware-port behavior by explicitly releasing any lingering LP pad routing before the software port starts using the pins.
Changes:
- In
init(), when initializing a software I2C port, release LP-domain pad routing for the configured SDA/SCL pins (when applicable) before callingsoft_i2c_init(). - Guard the LP pad release with the same build-time conditions used elsewhere (
LGFX_LP_I2C_NUM > 0 && SOC_RTCIO_PIN_COUNT > 0) and ensure the port number is valid before accessing the soft I2C context.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A pin routed to the low power I2C keeps that routing across a reset, because it is held in the low power domain rather than by the CPU.
set_pin()already hands such pins back before taking them for a hardware port, but the software port path did not: the bit-banged lines stayed bound to the low power peripheral and never reached the pads.On boards whose autodetect probes the internal bus with a software port (e.g. ToughC5), this made the probe fail on every warm boot - after flashing, after a reset, and after waking from deep sleep - while a cold boot (power cycle) worked, because only a power cycle resets the routing.
This change releases the pads in
init()for a software port as well, the same way the hardware port path does.Verified on ToughC5: board autodetect now succeeds right after flashing and after waking from deep sleep.