diff --git a/src/internal/NeoMethods.h b/src/internal/NeoMethods.h index 31a595f..9c53586 100644 --- a/src/internal/NeoMethods.h +++ b/src/internal/NeoMethods.h @@ -54,15 +54,15 @@ License along with NeoPixel. If not, see #elif defined(ARDUINO_ARCH_ESP32) -#if !defined(ARDUINO_ESP32C6_DEV) && !defined(ARDUINO_ESP32H2_DEV) +#if !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) #include "methods/NeoEsp32I2sMethod.h" #include "methods/NeoEsp32RmtMethod.h" #include "methods/DotStarEsp32DmaSpiMethod.h" #include "methods/NeoEsp32I2sXMethod.h" -#include "methods/NeoEspBitBangMethod.h" -#endif +#endif +#include "methods/NeoEspBitBangMethod.h" #elif defined(ARDUINO_ARCH_NRF52840) // must be before __arm__ diff --git a/src/internal/methods/Esp32_i2s.c b/src/internal/methods/Esp32_i2s.c index 46b3986..d132385 100644 --- a/src/internal/methods/Esp32_i2s.c +++ b/src/internal/methods/Esp32_i2s.c @@ -14,11 +14,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -// ESP32 C3 & S3 I2S is not supported yet due to significant changes to interface -#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(ARDUINO_ESP32C3_DEV) && !defined(ARDUINO_ESP32S3_DEV) && !defined(ARDUINO_ESP32C6_DEV) && !defined(ARDUINO_ESP32H2_DEV) +#if defined(ARDUINO_ARCH_ESP32) #include "sdkconfig.h" // this sets useful config symbols, like CONFIG_IDF_TARGET_ESP32C3 +// ESP32 C3, S3, C6, and H2 I2S is not supported yet due to significant changes to interface +#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) + #include #include #include "stdlib.h" @@ -47,7 +49,6 @@ #include "soc/dport_reg.h" #endif -#include "soc/sens_reg.h" #include "driver/gpio.h" #include "driver/i2s.h" @@ -1046,5 +1047,6 @@ bool i2sGetClks(uint8_t bus_num, } #endif -#endif // defined(ARDUINO_ARCH_ESP32) ** !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) +#endif // !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) +#endif // defined(ARDUINO_ARCH_ESP32) \ No newline at end of file diff --git a/src/internal/methods/NeoEsp32RmtMethod.cpp b/src/internal/methods/NeoEsp32RmtMethod.cpp index b998285..5f7e82e 100644 --- a/src/internal/methods/NeoEsp32RmtMethod.cpp +++ b/src/internal/methods/NeoEsp32RmtMethod.cpp @@ -27,9 +27,9 @@ License along with NeoPixel. If not, see . -------------------------------------------------------------------------*/ -#if defined(ARDUINO_ARCH_ESP32) && !defined(ARDUINO_ESP32C6_DEV) && !defined(ARDUINO_ESP32H2_DEV) - #include + +#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) #include "../NeoUtil.h" #include "../NeoSettings.h" #include "../NeoBusChannel.h" diff --git a/src/internal/methods/NeoEspBitBangMethod.cpp b/src/internal/methods/NeoEspBitBangMethod.cpp index f013674..d3a4b5f 100644 --- a/src/internal/methods/NeoEspBitBangMethod.cpp +++ b/src/internal/methods/NeoEspBitBangMethod.cpp @@ -24,16 +24,29 @@ License along with NeoPixel. If not, see . -------------------------------------------------------------------------*/ -#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) && !defined(ARDUINO_ESP32C6_DEV) && !defined(ARDUINO_ESP32H2_DEV) - #include +#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) + #include "..\NeoUtil.h" #if ESP_IDF_VERSION_MAJOR>=5 #include #endif +static inline uint32_t getCycleCount(void) +{ + uint32_t ccount; + +#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2) + __asm__ __volatile__("csrr %0,0x7e2":"=r" (ccount)); + //ccount = esp_cpu_get_ccount(); +#else + __asm__ __volatile__("rsr %0,ccount":"=a" (ccount)); +#endif + return ccount; +} + // Interrupt lock class, used for RAII interrupt disabling class InterruptLock { @@ -101,7 +114,7 @@ uint32_t IRAM_ATTR neoEspBitBangWriteSpacingPixels(const uint8_t* data, uint32_t cyclesNext = 0; #if defined(ARDUINO_ARCH_ESP32) -#if defined(CONFIG_IDF_TARGET_ESP32C3) +#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2) volatile uint32_t* setRegister = &GPIO.out_w1ts.val; volatile uint32_t* clearRegister = &GPIO.out_w1tc.val; setValue = _BV(pin); @@ -109,7 +122,7 @@ uint32_t IRAM_ATTR neoEspBitBangWriteSpacingPixels(const uint8_t* data, #else volatile uint32_t* setRegister = &GPIO.out_w1ts; volatile uint32_t* clearRegister = &GPIO.out_w1tc; -#endif // defined(CONFIG_IDF_TARGET_ESP32C3) +#endif // defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2) #else uint32_t setRegister = PERIPHS_GPIO_BASEADDR + GPIO_OUT_W1TS_ADDRESS; uint32_t clearRegister = PERIPHS_GPIO_BASEADDR + GPIO_OUT_W1TC_ADDRESS; diff --git a/src/internal/methods/NeoEspBitBangMethod.h b/src/internal/methods/NeoEspBitBangMethod.h index 770d62b..f1b17d4 100644 --- a/src/internal/methods/NeoEspBitBangMethod.h +++ b/src/internal/methods/NeoEspBitBangMethod.h @@ -410,6 +410,45 @@ typedef NeoEsp32BitBangWs2805InvertedMethod NeoEsp32BitBangWs2814InvertedNoIntrM typedef NeoEsp32BitBangTm1814InvertedMethod NeoEsp32BitBangTm1914InvertedNoIntrMethod; typedef NeoEsp32BitBangSk6812InvertedMethod NeoEsp32BitBangLc8812InvertedNoIntrMethod; +#if defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2) +// +// Esp32 C6 && H2 currently use BitBang as the default until other support +// is created, as they are not compatible with older generation chips +typedef NeoEsp32BitBangWs2812xMethod NeoWs2813Method; +typedef NeoEsp32BitBangWs2812xMethod NeoWs2812xMethod; +typedef NeoEsp32BitBang800KbpsMethod NeoWs2812Method; +typedef NeoEsp32BitBangWs2812xMethod NeoWs2811Method; +typedef NeoEsp32BitBangWs2812xMethod NeoWs2816Method; +typedef NeoEsp32BitBangWs2805Method NeoWs2805Method; +typedef NeoEsp32BitBangWs2814Method NeoWs2814Method; +typedef NeoEsp32BitBangSk6812Method NeoSk6812Method; +typedef NeoEsp32BitBangTm1814Method NeoTm1814Method; +typedef NeoEsp32BitBangTm1829Method NeoTm1829Method; +typedef NeoEsp32BitBangTm1914Method NeoTm1914Method; +typedef NeoEsp32BitBangSk6812Method NeoLc8812Method; +typedef NeoEsp32BitBangApa106Method NeoApa106Method; + +typedef NeoEsp32BitBangWs2812xMethod Neo800KbpsMethod; +typedef NeoEsp32BitBang400KbpsMethod Neo400KbpsMethod; + +typedef NeoEsp32BitBangWs2812xInvertedMethod NeoWs2813InvertedMethod; +typedef NeoEsp32BitBangWs2812xInvertedMethod NeoWs2812xInvertedMethod; +typedef NeoEsp32BitBangWs2812xInvertedMethod NeoWs2811InvertedMethod; +typedef NeoEsp32BitBangWs2812xInvertedMethod NeoWs2816InvertedMethod; +typedef NeoEsp32BitBangWs2805InvertedMethod NeoWs2805InvertedMethod; +typedef NeoEsp32BitBangWs2814InvertedMethod NeoWs2814InvertedMethod; +typedef NeoEsp32BitBang800KbpsInvertedMethod NeoWs2812InvertedMethod; +typedef NeoEsp32BitBangSk6812InvertedMethod NeoSk6812InvertedMethod; +typedef NeoEsp32BitBangTm1814InvertedMethod NeoTm1814InvertedMethod; +typedef NeoEsp32BitBangTm1829InvertedMethod NeoTm1829InvertedMethod; +typedef NeoEsp32BitBangTm1914InvertedMethod NeoTm1914InvertedMethod; +typedef NeoEsp32BitBangSk6812InvertedMethod NeoLc8812InvertedMethod; +typedef NeoEsp32BitBangApa106InvertedMethod NeoApa106InvertedMethod; + +typedef NeoEsp32BitBangWs2812xInvertedMethod Neo800KbpsInvertedMethod; +typedef NeoEsp32BitBang400KbpsInvertedMethod Neo400KbpsInvertedMethod; +#endif + #else // defined(ARDUINO_ARCH_ESP8266) typedef NeoEspBitBangMethodBase NeoEsp8266BitBangWs2811Method; @@ -484,6 +523,8 @@ typedef NeoEsp8266BitBangWs2805InvertedMethod NeoEsp8266BitBangWs2814InvertedNoI typedef NeoEsp8266BitBangTm1814InvertedMethod NeoEsp8266BitBangTm1914InvertedNoIntrMethod; typedef NeoEsp8266BitBangSk6812InvertedMethod NeoEsp8266BitBangLc8812InvertedNoIntrMethod; + + #endif // defined(ARDUINO_ARCH_ESP32) // ESP bitbang doesn't have defaults and should avoided except for testing