diff --git a/wled00/bus_wrapper.h b/wled00/bus_wrapper.h index b9f5cb4d..325a1f53 100644 --- a/wled00/bus_wrapper.h +++ b/wled00/bus_wrapper.h @@ -3,6 +3,18 @@ #include "NeoPixelBrightnessBus.h" +// temporary - these defines should actually be set in platformio.ini +// C3: I2S0 and I2S1 methods not supported +// S2: I2S1 methods not supported +// S3: I2S0 and I2S1 methods not supported yet +#if !defined(WLED_NO_I2S0_PIXELBUS) && (defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3)) +#define WLED_NO_I2S0_PIXELBUS +#endif +#if !defined(WLED_NO_I2S1_PIXELBUS) && (defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2)) +#define WLED_NO_I2S1_PIXELBUS +#endif +// temporary end + //Hardware SPI Pins #define P_8266_HS_MOSI 13 #define P_8266_HS_CLK 14 @@ -117,43 +129,43 @@ #ifdef ARDUINO_ARCH_ESP32 //RGB #define B_32_RN_NEO_3 NeoPixelBrightnessBus -#ifndef CONFIG_IDF_TARGET_ESP32C3 +#ifndef WLED_NO_I2S0_PIXELBUS #define B_32_I0_NEO_3 NeoPixelBrightnessBus #endif -#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) +#ifndef WLED_NO_I2S1_PIXELBUS #define B_32_I1_NEO_3 NeoPixelBrightnessBus #endif //RGBW #define B_32_RN_NEO_4 NeoPixelBrightnessBus -#ifndef CONFIG_IDF_TARGET_ESP32C3 +#ifndef WLED_NO_I2S0_PIXELBUS #define B_32_I0_NEO_4 NeoPixelBrightnessBus #endif -#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) +#ifndef WLED_NO_I2S1_PIXELBUS #define B_32_I1_NEO_4 NeoPixelBrightnessBus #endif //400Kbps #define B_32_RN_400_3 NeoPixelBrightnessBus -#ifndef CONFIG_IDF_TARGET_ESP32C3 +#ifndef WLED_NO_I2S0_PIXELBUS #define B_32_I0_400_3 NeoPixelBrightnessBus #endif -#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) +#ifndef WLED_NO_I2S1_PIXELBUS #define B_32_I1_400_3 NeoPixelBrightnessBus #endif //TM1814 (RGBW) #define B_32_RN_TM1_4 NeoPixelBrightnessBus -#ifndef CONFIG_IDF_TARGET_ESP32C3 +#ifndef WLED_NO_I2S0_PIXELBUS #define B_32_I0_TM1_4 NeoPixelBrightnessBus #endif -#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) +#ifndef WLED_NO_I2S1_PIXELBUS #define B_32_I1_TM1_4 NeoPixelBrightnessBus #endif //Bit Bang theoratically possible, but very undesirable and not needed (no pin restrictions on RMT and I2S) //TM1829 (RGB) #define B_32_RN_TM2_3 NeoPixelBrightnessBus -#ifndef CONFIG_IDF_TARGET_ESP32C3 +#ifndef WLED_NO_I2S0_PIXELBUS #define B_32_I0_TM2_3 NeoPixelBrightnessBus #endif -#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) +#ifndef WLED_NO_I2S1_PIXELBUS #define B_32_I1_TM2_3 NeoPixelBrightnessBus #endif //Bit Bang theoratically possible, but very undesirable and not needed (no pin restrictions on RMT and I2S) @@ -237,33 +249,33 @@ class PolyBus { #endif #ifdef ARDUINO_ARCH_ESP32 case I_32_RN_NEO_3: (static_cast(busPtr))->Begin(); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_3: (static_cast(busPtr))->Begin(); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_3: (static_cast(busPtr))->Begin(); break; #endif case I_32_RN_NEO_4: (static_cast(busPtr))->Begin(); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_4: (static_cast(busPtr))->Begin(); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_4: (static_cast(busPtr))->Begin(); break; #endif case I_32_RN_400_3: (static_cast(busPtr))->Begin(); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_400_3: (static_cast(busPtr))->Begin(); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_400_3: (static_cast(busPtr))->Begin(); break; #endif case I_32_RN_TM1_4: beginTM1814(busPtr); break; case I_32_RN_TM2_3: (static_cast(busPtr))->Begin(); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_TM1_4: beginTM1814(busPtr); break; case I_32_I0_TM2_3: (static_cast(busPtr))->Begin(); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_TM1_4: beginTM1814(busPtr); break; case I_32_I1_TM2_3: (static_cast(busPtr))->Begin(); break; #endif @@ -309,33 +321,33 @@ class PolyBus { #endif #ifdef ARDUINO_ARCH_ESP32 case I_32_RN_NEO_3: busPtr = new B_32_RN_NEO_3(len, pins[0], (NeoBusChannel)channel); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_3: busPtr = new B_32_I0_NEO_3(len, pins[0]); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_3: busPtr = new B_32_I1_NEO_3(len, pins[0]); break; #endif case I_32_RN_NEO_4: busPtr = new B_32_RN_NEO_4(len, pins[0], (NeoBusChannel)channel); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_4: busPtr = new B_32_I0_NEO_4(len, pins[0]); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_4: busPtr = new B_32_I1_NEO_4(len, pins[0]); break; #endif case I_32_RN_400_3: busPtr = new B_32_RN_400_3(len, pins[0], (NeoBusChannel)channel); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_400_3: busPtr = new B_32_I0_400_3(len, pins[0]); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_400_3: busPtr = new B_32_I1_400_3(len, pins[0]); break; #endif case I_32_RN_TM1_4: busPtr = new B_32_RN_TM1_4(len, pins[0], (NeoBusChannel)channel); break; case I_32_RN_TM2_3: busPtr = new B_32_RN_TM2_3(len, pins[0], (NeoBusChannel)channel); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_TM1_4: busPtr = new B_32_I0_TM1_4(len, pins[0]); break; case I_32_I0_TM2_3: busPtr = new B_32_I0_TM2_3(len, pins[0]); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_TM1_4: busPtr = new B_32_I1_TM1_4(len, pins[0]); break; case I_32_I1_TM2_3: busPtr = new B_32_I1_TM2_3(len, pins[0]); break; #endif @@ -382,33 +394,33 @@ class PolyBus { #endif #ifdef ARDUINO_ARCH_ESP32 case I_32_RN_NEO_3: (static_cast(busPtr))->Show(); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_3: (static_cast(busPtr))->Show(); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_3: (static_cast(busPtr))->Show(); break; #endif case I_32_RN_NEO_4: (static_cast(busPtr))->Show(); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_4: (static_cast(busPtr))->Show(); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_4: (static_cast(busPtr))->Show(); break; #endif case I_32_RN_400_3: (static_cast(busPtr))->Show(); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_400_3: (static_cast(busPtr))->Show(); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_400_3: (static_cast(busPtr))->Show(); break; #endif case I_32_RN_TM1_4: (static_cast(busPtr))->Show(); break; case I_32_RN_TM2_3: (static_cast(busPtr))->Show(); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_TM1_4: (static_cast(busPtr))->Show(); break; case I_32_I0_TM2_3: (static_cast(busPtr))->Show(); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_TM1_4: (static_cast(busPtr))->Show(); break; case I_32_I1_TM2_3: (static_cast(busPtr))->Show(); break; #endif @@ -452,33 +464,33 @@ class PolyBus { #endif #ifdef ARDUINO_ARCH_ESP32 case I_32_RN_NEO_3: return (static_cast(busPtr))->CanShow(); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_3: return (static_cast(busPtr))->CanShow(); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_3: return (static_cast(busPtr))->CanShow(); break; #endif case I_32_RN_NEO_4: return (static_cast(busPtr))->CanShow(); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_4: return (static_cast(busPtr))->CanShow(); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_4: return (static_cast(busPtr))->CanShow(); break; #endif case I_32_RN_400_3: return (static_cast(busPtr))->CanShow(); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_400_3: return (static_cast(busPtr))->CanShow(); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_400_3: return (static_cast(busPtr))->CanShow(); break; #endif case I_32_RN_TM1_4: return (static_cast(busPtr))->CanShow(); break; case I_32_RN_TM2_3: return (static_cast(busPtr))->CanShow(); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_TM1_4: return (static_cast(busPtr))->CanShow(); break; case I_32_I0_TM2_3: return (static_cast(busPtr))->CanShow(); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_TM1_4: return (static_cast(busPtr))->CanShow(); break; case I_32_I1_TM2_3: return (static_cast(busPtr))->CanShow(); break; #endif @@ -546,33 +558,33 @@ class PolyBus { #endif #ifdef ARDUINO_ARCH_ESP32 case I_32_RN_NEO_3: (static_cast(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_3: (static_cast(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_3: (static_cast(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break; #endif case I_32_RN_NEO_4: (static_cast(busPtr))->SetPixelColor(pix, col); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_4: (static_cast(busPtr))->SetPixelColor(pix, col); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_4: (static_cast(busPtr))->SetPixelColor(pix, col); break; #endif case I_32_RN_400_3: (static_cast(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_400_3: (static_cast(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_400_3: (static_cast(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break; #endif case I_32_RN_TM1_4: (static_cast(busPtr))->SetPixelColor(pix, col); break; case I_32_RN_TM2_3: (static_cast(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_TM1_4: (static_cast(busPtr))->SetPixelColor(pix, col); break; case I_32_I0_TM2_3: (static_cast(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_TM1_4: (static_cast(busPtr))->SetPixelColor(pix, col); break; case I_32_I1_TM2_3: (static_cast(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break; #endif @@ -616,33 +628,33 @@ class PolyBus { #endif #ifdef ARDUINO_ARCH_ESP32 case I_32_RN_NEO_3: (static_cast(busPtr))->SetBrightness(b); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_3: (static_cast(busPtr))->SetBrightness(b); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_3: (static_cast(busPtr))->SetBrightness(b); break; #endif case I_32_RN_NEO_4: (static_cast(busPtr))->SetBrightness(b); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_4: (static_cast(busPtr))->SetBrightness(b); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_4: (static_cast(busPtr))->SetBrightness(b); break; #endif case I_32_RN_400_3: (static_cast(busPtr))->SetBrightness(b); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_400_3: (static_cast(busPtr))->SetBrightness(b); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_400_3: (static_cast(busPtr))->SetBrightness(b); break; #endif case I_32_RN_TM1_4: (static_cast(busPtr))->SetBrightness(b); break; case I_32_RN_TM2_3: (static_cast(busPtr))->SetBrightness(b); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_TM1_4: (static_cast(busPtr))->SetBrightness(b); break; case I_32_I0_TM2_3: (static_cast(busPtr))->SetBrightness(b); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_TM1_4: (static_cast(busPtr))->SetBrightness(b); break; case I_32_I1_TM2_3: (static_cast(busPtr))->SetBrightness(b); break; #endif @@ -687,33 +699,33 @@ class PolyBus { #endif #ifdef ARDUINO_ARCH_ESP32 case I_32_RN_NEO_3: col = (static_cast(busPtr))->GetPixelColor(pix); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_3: col = (static_cast(busPtr))->GetPixelColor(pix); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_3: col = (static_cast(busPtr))->GetPixelColor(pix); break; #endif case I_32_RN_NEO_4: col = (static_cast(busPtr))->GetPixelColor(pix); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_4: col = (static_cast(busPtr))->GetPixelColor(pix); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_4: col = (static_cast(busPtr))->GetPixelColor(pix); break; #endif case I_32_RN_400_3: col = (static_cast(busPtr))->GetPixelColor(pix); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_400_3: col = (static_cast(busPtr))->GetPixelColor(pix); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_400_3: col = (static_cast(busPtr))->GetPixelColor(pix); break; #endif case I_32_RN_TM1_4: col = (static_cast(busPtr))->GetPixelColor(pix); break; case I_32_RN_TM2_3: col = (static_cast(busPtr))->GetPixelColor(pix); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_TM1_4: col = (static_cast(busPtr))->GetPixelColor(pix); break; case I_32_I0_TM2_3: col = (static_cast(busPtr))->GetPixelColor(pix); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_TM1_4: col = (static_cast(busPtr))->GetPixelColor(pix); break; case I_32_I1_TM2_3: col = (static_cast(busPtr))->GetPixelColor(pix); break; #endif @@ -777,33 +789,33 @@ class PolyBus { #endif #ifdef ARDUINO_ARCH_ESP32 case I_32_RN_NEO_3: delete (static_cast(busPtr)); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_3: delete (static_cast(busPtr)); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_3: delete (static_cast(busPtr)); break; #endif case I_32_RN_NEO_4: delete (static_cast(busPtr)); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_NEO_4: delete (static_cast(busPtr)); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_NEO_4: delete (static_cast(busPtr)); break; #endif case I_32_RN_400_3: delete (static_cast(busPtr)); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_400_3: delete (static_cast(busPtr)); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_400_3: delete (static_cast(busPtr)); break; #endif case I_32_RN_TM1_4: delete (static_cast(busPtr)); break; case I_32_RN_TM2_3: delete (static_cast(busPtr)); break; - #ifndef CONFIG_IDF_TARGET_ESP32C3 + #ifndef WLED_NO_I2S0_PIXELBUS case I_32_I0_TM1_4: delete (static_cast(busPtr)); break; case I_32_I0_TM2_3: delete (static_cast(busPtr)); break; #endif - #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + #ifndef WLED_NO_I2S1_PIXELBUS case I_32_I1_TM1_4: delete (static_cast(busPtr)); break; case I_32_I1_TM2_3: delete (static_cast(busPtr)); break; #endif diff --git a/wled00/const.h b/wled00/const.h index 429d4566..2830746a 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -25,10 +25,14 @@ #ifdef ESP8266 #define WLED_MAX_BUSSES 3 #else - #ifdef CONFIG_IDF_TARGET_ESP32S2 + #if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) #define WLED_MAX_BUSSES 5 #else - #define WLED_MAX_BUSSES 10 + #if defined(CONFIG_IDF_TARGET_ESP32S3) + #define WLED_MAX_BUSSES 8 + #else + #define WLED_MAX_BUSSES 10 + #endif #endif #endif #endif diff --git a/wled00/pin_manager.cpp b/wled00/pin_manager.cpp index 14d5b65b..c8e5a984 100644 --- a/wled00/pin_manager.cpp +++ b/wled00/pin_manager.cpp @@ -198,6 +198,38 @@ bool PinManagerClass::isPinAllocated(byte gpio, PinOwner tag) return bitRead(pinAlloc[by], bi); } +#ifdef CONFIG_IDF_TARGET_ESP32S3 +// ESP32-S3 GPIO layout + /* see https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/gpio.html + * The ESP32-S3 chip features 45 physical GPIO pins (GPIO0 ~ GPIO21 and GPIO26 ~ GPIO48). Each pin can be used as a general-purpose I/O + * Strapping pins: GPIO0, GPIO3, GPIO45 and GPIO46 are strapping pins. For more infomation, please refer to ESP32-S3 datasheet. + * Serial TX = GPIO43, RX = GPIO44; LED BUILTIN is usually GPIO39 + * USB-JTAG: GPIO 19 and 20 are used by USB-JTAG by default. In order to use them as GPIOs, USB-JTAG will be disabled by the drivers. + * SPI0/1: GPIO26-32 are usually used for SPI flash and PSRAM and not recommended for other uses. + * When using Octal Flash or Octal PSRAM or both, GPIO33~37 are connected to SPIIO4 ~ SPIIO7 and SPIDQS. Therefore, on boards embedded with ESP32-S3R8 / ESP32-S3R8V chip, GPIO33~37 are also not recommended for other uses. + * + * see https://docs.espressif.com/projects/esp-idf/en/v4.4.2/esp32s3/api-reference/peripherals/adc.html + * https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/adc_oneshot.html + * ADC1: GPIO1 - GPIO10 (channel 0..9) + * ADC2: GPIO11 - GPIO20 (channel 0..9) + * adc_power_acquire(): Please do not use the interrupt of GPIO36 and GPIO39 when using ADC or Wi-Fi and Bluetooth with sleep mode enabled. As a workaround, call adc_power_acquire() in the APP. + * Since the ADC2 module is also used by the Wi-Fi, reading operation of adc2_get_raw() may fail between esp_wifi_start() and esp_wifi_stop(). Use the return code to see whether the reading is successful. + */ +bool PinManagerClass::isPinOk(byte gpio, bool output) +{ + if (gpio < 19) return true; // 00 to 18 are for general use. Be careful about straping pins GPIO0 and GPIO3 - these may be pulled-up or pulled-down on your board. + if (gpio < 21) return false; // 19 + 20 = USB-JTAG. Not recommended for other uses. + if((gpio > 21) && (gpio < 26)) return false; // 22 to 25: not connected + + if (gpio < 33) return false; // 26 to 32: SPI flash and PSRAM. Not recommended for other uses. + //if (gpio <38) return false; // 33 to 37: not availeable if using _octal_ SPI Flash or _octal_ PSRAM + + if (gpio < 49) return true; // 38 to 48 are for general use. Be careful about straping pins GPIO45 and GPIO46 - these may be pull-up or pulled-down on your board. + + return false; +} + +#else // ESP32 and ESP8266 GPIO layout bool PinManagerClass::isPinOk(byte gpio, bool output) { if (gpio < 6) return true; @@ -212,6 +244,7 @@ bool PinManagerClass::isPinOk(byte gpio, bool output) return false; } +#endif PinOwner PinManagerClass::getPinOwner(byte gpio) { if (!isPinOk(gpio, false)) return PinOwner::None; @@ -219,11 +252,20 @@ PinOwner PinManagerClass::getPinOwner(byte gpio) { } #ifdef ARDUINO_ARCH_ESP32 +#if defined(CONFIG_IDF_TARGET_ESP32C3) + #define MAX_LED_CHANNELS 6 +#else + #if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) + #define MAX_LED_CHANNELS 8 + #else + #define MAX_LED_CHANNELS 16 + #endif +#endif byte PinManagerClass::allocateLedc(byte channels) { - if (channels > 16 || channels == 0) return 255; + if (channels > MAX_LED_CHANNELS || channels == 0) return 255; byte ca = 0; - for (byte i = 0; i < 16; i++) { + for (byte i = 0; i < MAX_LED_CHANNELS; i++) { byte by = i >> 3; byte bi = i - 8*by; if (bitRead(ledcAlloc[by], bi)) { //found occupied pin @@ -248,7 +290,7 @@ byte PinManagerClass::allocateLedc(byte channels) void PinManagerClass::deallocateLedc(byte pos, byte channels) { for (byte j = pos; j < pos + channels; j++) { - if (j > 16) return; + if (j > MAX_LED_CHANNELS) return; byte by = j >> 3; byte bi = j - 8*by; bitWrite(ledcAlloc[by], bi, false); diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 8246485f..d98f7b5e 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -363,9 +363,9 @@ void getSettingsJS(byte subPage, char* dest) // set limits oappend(SET_F("bLimits(")); - #if defined(ESP32) && defined(USERMOD_AUDIOREACTIVE) + #if defined(ESP32) && defined(USERMOD_AUDIOREACTIVE) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32C3) // requested by @softhack007 https://github.com/blazoncek/WLED/issues/33 - oappend(itoa(WLED_MAX_BUSSES-2,nS,10)); oappend(","); // prevent use of I2S buses if audio installed + oappend(itoa(WLED_MAX_BUSSES-2,nS,10)); oappend(","); // prevent use of I2S buses if audio installed. ESP32-S3 currently does not support these busses. #else oappend(itoa(WLED_MAX_BUSSES,nS,10)); oappend(","); #endif