From b4aa6a13a1bcb072f60bfb8bffe56ab1f4996990 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Mon, 6 Jan 2025 22:33:31 +0100 Subject: [PATCH] Merge pull request #4450 from adafruit/main Add correct pin availability for ESP32 Mini modules --- wled00/pin_manager.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/wled00/pin_manager.cpp b/wled00/pin_manager.cpp index 86f0c88e..9ccdf1e0 100644 --- a/wled00/pin_manager.cpp +++ b/wled00/pin_manager.cpp @@ -755,7 +755,22 @@ bool PinManagerClass::isPinOk(byte gpio, bool output) const // JTAG: GPIO39-42 are usually used for inline debugging // GPIO46 is input only and pulled down #else - if (gpio > 5 && gpio < 12) return false; //SPI flash pins + if ((gpio > 5 && gpio < 12) && // WLEDMM slightly faster to first check for "potentially reserved pins" and then call ESP.getChipModel() + ((strncmp_P(PSTR("ESP32-U4WDH"), ESP.getChipModel(), 11) == 0) || // this is the correct identifier, but.... + (strncmp_P(PSTR("ESP32-PICO-D2"), ESP.getChipModel(), 13) == 0))) // https://github.com/espressif/arduino-esp32/issues/10683 + { + // this chip has 4 MB of internal Flash and different packaging, so available pins are different! + if (((gpio > 5) && (gpio < 9)) || (gpio == 11)) + return false; + } else { + // for classic ESP32 (non-mini) modules, these are the SPI flash pins + if (gpio > 5 && gpio < 12) return false; //SPI flash pins + } + //WLEDMM gpio 16/17 (PSRAM or SPI FLASH) are handled differently + // if (((strncmp_P(PSTR("ESP32-PICO"), ESP.getChipModel(), 10) == 0) || + // (strncmp_P(PSTR("ESP32-U4WDH"), ESP.getChipModel(), 11) == 0)) + // && (gpio == 16 || gpio == 17)) return false; // PICO-D4/U4WDH: gpio16+17 are in use for onboard SPI FLASH + // if (gpio == 16 || gpio == 17) return !psramFound(); //PSRAM pins on ESP32 (these are IO) #endif if (output) return digitalPinCanOutput(gpio); else return true;