From a8bd46c5218fe12e8eb1e389e13fe0271eabdb94 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 14 Dec 2023 20:36:05 +0100 Subject: [PATCH] bugfix - unusable pins on pico32 boards (#3573) According to the technical manual, GPIO 16 + 17 are used for onboard flash, so cannot be used by WLED. example buildenv: [env:esp32_pico] extends = env:esp32dev_qio80 board = pico32 --- wled00/const.h | 4 ++-- wled00/wled.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wled00/const.h b/wled00/const.h index 0afa8a574..3f4ef5cfc 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -460,8 +460,8 @@ //this is merely a default now and can be changed at runtime #ifndef LEDPIN -#if defined(ESP8266) || (defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)) || defined(CONFIG_IDF_TARGET_ESP32C3) - #define LEDPIN 2 // GPIO2 (D4) on Wemos D1 mini compatible boards +#if defined(ESP8266) || (defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(ARDUINO_ESP32_PICO) + #define LEDPIN 2 // GPIO2 (D4) on Wemos D1 mini compatible boards, and on boards where GPIO16 is not available #else #define LEDPIN 16 // aligns with GPIO2 (D4) on Wemos D1 mini32 compatible boards #endif diff --git a/wled00/wled.cpp b/wled00/wled.cpp index bf1ab2256..505160215 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -374,6 +374,11 @@ void WLED::setup() #else DEBUG_PRINTLN(F("PSRAM not used.")); #endif +#endif +#if defined(ARDUINO_ESP32_PICO) +// special handling for PICO-D4: gpio16+17 are in use for onboard SPI FLASH (not PSRAM) +managed_pin_type pins[] = { {16, true}, {17, true} }; +pinManager.allocateMultiplePins(pins, sizeof(pins)/sizeof(managed_pin_type), PinOwner::SPI_RAM); #endif //DEBUG_PRINT(F("LEDs inited. heap usage ~"));