From 87b556933191bff7ff3b3f860b2679f10d95ae82 Mon Sep 17 00:00:00 2001 From: ainyan03 Date: Fri, 7 Aug 2026 03:17:30 +0000 Subject: [PATCH] Release leftover low power routing when a software I2C port is initialized 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. --- src/lgfx/v1/platforms/esp32/common.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lgfx/v1/platforms/esp32/common.cpp b/src/lgfx/v1/platforms/esp32/common.cpp index c9703058..bf22c21c 100644 --- a/src/lgfx/v1/platforms/esp32/common.cpp +++ b/src/lgfx/v1/platforms/esp32/common.cpp @@ -1697,7 +1697,20 @@ namespace lgfx cpp::result init(int i2c_port) { - if (isSoftPort(i2c_port)) { return soft_i2c_init(i2c_port); } + if (isSoftPort(i2c_port)) + { +#if LGFX_LP_I2C_NUM > 0 && SOC_RTCIO_PIN_COUNT > 0 + if (soft_i2c_valid_port(i2c_port)) + { // 低電力ポートのルーティングはリセットを跨いで残るため、前回実行が + // LP ポートとして使ったピンをソフトポートで取り直す場合にも返却が + // 必要になる。( see releaseLpPad ) + auto& ctx = soft_i2c_ctx(i2c_port); + releaseLpPad((gpio_num_t)ctx.pin_sda); + releaseLpPad((gpio_num_t)ctx.pin_scl); + } +#endif + return soft_i2c_init(i2c_port); + } if (i2c_port >= LGFX_I2C_PORT_NUM) { return cpp::fail(error_t::invalid_arg); } gpio_num_t pin_sda = i2c_context[i2c_port].pin_sda; gpio_num_t pin_scl = i2c_context[i2c_port].pin_scl;