diff --git a/src/internal/DotStarEsp32DmaSpiMethod.h b/src/internal/DotStarEsp32DmaSpiMethod.h index b3ddf4e..d71cf79 100644 --- a/src/internal/DotStarEsp32DmaSpiMethod.h +++ b/src/internal/DotStarEsp32DmaSpiMethod.h @@ -29,6 +29,12 @@ License along with NeoPixel. If not, see #include "driver/spi_master.h" +#if defined(CONFIG_IDF_TARGET_ESP32C3) +// HSPI_HOST depreciated in C3 +#define HSPI_HOST SPI3_HOST +#endif + +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) class Esp32VspiBus { public: @@ -36,6 +42,7 @@ public: const static int DmaChannel = 1; // arbitrary assignment, but based on the fact there are only two DMA channels and two available SPI ports, we need to split them somehow const static int ParallelBits = 1; }; +#endif class Esp32HspiBus { @@ -45,6 +52,7 @@ public: const static int ParallelBits = 1; }; +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) class Esp32Vspi2BitBus { public: @@ -52,6 +60,7 @@ public: const static int DmaChannel = 1; // arbitrary assignment, but based on the fact there are only two DMA channels and two available SPI ports, we need to split them somehow const static int ParallelBits = 2; }; +#endif class Esp32Hspi2BitBus { @@ -61,6 +70,7 @@ public: const static int ParallelBits = 2; }; +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) class Esp32Vspi4BitBus { public: @@ -68,6 +78,7 @@ public: const static int DmaChannel = 1; // arbitrary assignment, but based on the fact there are only two DMA channels and two available SPI ports, we need to split them somehow const static int ParallelBits = 4; }; +#endif class Esp32Hspi4BitBus { @@ -163,6 +174,7 @@ public: // If pins aren't specified, initialize bus with just the default SCK and MOSI pins for the SPI peripheral (no SS, no >1-bit pins) void Initialize() { +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) if (T_SPIBUS::SpiHostDevice == VSPI_HOST) { Initialize(SCK, -1, MOSI, -1, -1, -1); @@ -171,6 +183,9 @@ public: { Initialize(14, -1, 13, -1, -1, -1); } +#else + Initialize(SCK, -1, MOSI, -1, -1, -1); +#endif } void Update(bool) @@ -262,6 +277,7 @@ private: int8_t _ssPin; }; +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) // Clock Speed and Default Definitions for DotStarEsp32DmaVspi typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaVspi40MhzMethod; typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaVspi20MhzMethod; @@ -273,6 +289,7 @@ typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaVs typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaVspiHzMethod; typedef DotStarEsp32DmaVspi10MhzMethod DotStarEsp32DmaVspiMethod; +#endif // Clock Speed and Default Definitions for DotStarEsp32DmaHspi typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaHspi40MhzMethod; @@ -286,6 +303,7 @@ typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaHspiHz typedef DotStarEsp32DmaHspi10MhzMethod DotStarEsp32DmaHspiMethod; +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) // Clock Speed and Default Definitions for DotStarEsp32DmaVspi2Bit typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaVspi2Bit40MhzMethod; typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaVspi2Bit20MhzMethod; @@ -297,6 +315,7 @@ typedef DotStarEsp32DmaSpiMethod DotStarEsp32Dm typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaVspi2BitHzMethod; typedef DotStarEsp32DmaVspi2Bit10MhzMethod DotStarEsp32DmaVspi2BitMethod; +#endif // Clock Speed and Default Definitions for DotStarEsp32DmaHspi2Bit typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaHspi2Bit40MhzMethod; @@ -310,6 +329,7 @@ typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaHsp typedef DotStarEsp32DmaHspi2Bit10MhzMethod DotStarEsp32DmaHspi2BitMethod; +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) // Clock Speed and Default Definitions for DotStarEsp32DmaVspi4Bit typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaVspi4Bit40MhzMethod; typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaVspi4Bit20MhzMethod; @@ -321,6 +341,7 @@ typedef DotStarEsp32DmaSpiMethod DotStarEsp32Dm typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaVspi4BitHzMethod; typedef DotStarEsp32DmaVspi4Bit10MhzMethod DotStarEsp32DmaVspi4BitMethod; +#endif // Clock Speed and Default Definitions for DotStarEsp32DmaHspi4Bit typedef DotStarEsp32DmaSpiMethod DotStarEsp32DmaHspi4Bit40MhzMethod; diff --git a/src/internal/Esp32_i2s.c b/src/internal/Esp32_i2s.c index 9751294..d25856a 100644 --- a/src/internal/Esp32_i2s.c +++ b/src/internal/Esp32_i2s.c @@ -15,7 +15,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if defined(ARDUINO_ARCH_ESP32) +#if defined(ARDUINO_ARCH_ESP32) + +#include "sdkconfig.h" // this sets useful config symbols, like CONFIG_IDF_TARGET_ESP32C3 + +// ESP32C3 I2S is not supported yet due to significant changes to interface +#if !defined(CONFIG_IDF_TARGET_ESP32C3) #include #include @@ -38,7 +43,10 @@ #include "soc/io_mux_reg.h" #include "soc/rtc_cntl_reg.h" #include "soc/i2s_struct.h" +#if defined(CONFIG_IDF_TARGET_ESP32) +/* included here for ESP-IDF v4.x compatibility */ #include "soc/dport_reg.h" +#endif #include "soc/sens_reg.h" #include "driver/gpio.h" #include "driver/i2s.h" @@ -104,7 +112,7 @@ typedef struct { static uint8_t i2s_silence_buf[I2S_DMA_SILENCE_SIZE] = { 0 }; -#if !defined(CONFIG_IDF_TARGET_ESP32S2) +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) // (I2S_NUM_MAX == 2) static i2s_bus_t I2S[I2S_NUM_MAX] = { {&I2S0, -1, -1, -1, -1, 0, NULL, NULL, i2s_silence_buf, I2S_DMA_SILENCE_SIZE, NULL, I2S_DMA_BLOCK_COUNT_DEFAULT, 0, 0, I2s_Is_Idle}, @@ -178,7 +186,7 @@ esp_err_t i2sSetClock(uint8_t bus_num, uint8_t div_num, uint8_t div_b, uint8_t d typeof(i2s->clkm_conf) clkm_conf; clkm_conf.val = 0; -#if !defined(CONFIG_IDF_TARGET_ESP32S2) +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) clkm_conf.clka_en = 0; #else clkm_conf.clk_sel = 2; @@ -213,7 +221,7 @@ void i2sSetPins(uint8_t bus_num, int8_t out, bool invert) { pinMode(out, OUTPUT); int i2sSignal; -#if !defined(CONFIG_IDF_TARGET_ESP32S2) +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) // (I2S_NUM_MAX == 2) if (bus_num == 1) { i2sSignal = I2S1O_DATA_OUT23_IDX; @@ -259,7 +267,7 @@ void i2sInit(uint8_t bus_num, return; } -#if !defined(CONFIG_IDF_TARGET_ESP32S2) +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) // (I2S_NUM_MAX == 2) if (bus_num) { periph_module_enable(PERIPH_I2S1_MODULE); @@ -301,7 +309,7 @@ void i2sInit(uint8_t bus_num, lc_conf.out_eof_mode = 1; i2s->lc_conf.val = lc_conf.val; -#if !defined(CONFIG_IDF_TARGET_ESP32S2) +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) i2s->pdm_conf.pcm2pdm_conv_en = 0; i2s->pdm_conf.pdm2pcm_conv_en = 0; #endif @@ -332,7 +340,7 @@ void i2sInit(uint8_t bus_num, i2s->fifo_conf.tx_fifo_mod_force_en = 1; -#if !defined(CONFIG_IDF_TARGET_ESP32S2) +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) i2s->pdm_conf.rx_pdm_en = 0; i2s->pdm_conf.tx_pdm_en = 0; #endif @@ -342,7 +350,7 @@ void i2sInit(uint8_t bus_num, // enable intr in cpu // int i2sIntSource; -#if !defined(CONFIG_IDF_TARGET_ESP32S2) +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) // (I2S_NUM_MAX == 2) if (bus_num == 1) { i2sIntSource = ETS_I2S1_INTR_SOURCE; @@ -486,5 +494,6 @@ size_t i2sWrite(uint8_t bus_num, uint8_t* data, size_t len, bool copy, bool free return len; } +#endif // !defined(CONFIG_IDF_TARGET_ESP32C3) +#endif // defined(ARDUINO_ARCH_ESP32) -#endif diff --git a/src/internal/Esp32_i2s.h b/src/internal/Esp32_i2s.h index d31c51e..1249d2e 100644 --- a/src/internal/Esp32_i2s.h +++ b/src/internal/Esp32_i2s.h @@ -1,6 +1,7 @@ #pragma once -#if defined(ARDUINO_ARCH_ESP32) +// ESP32C3 I2S is not supported yet due to significant changes to interface +#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3) #ifdef __cplusplus extern "C" { diff --git a/src/internal/NeoBusChannel.h b/src/internal/NeoBusChannel.h index 2743bff..9fc374d 100644 --- a/src/internal/NeoBusChannel.h +++ b/src/internal/NeoBusChannel.h @@ -19,11 +19,12 @@ enum NeoBusChannel NeoBusChannel_3, -#if !defined(CONFIG_IDF_TARGET_ESP32S2) +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) NeoBusChannel_4, NeoBusChannel_5, NeoBusChannel_6, NeoBusChannel_7, -#endif // CONFIG_IDF_TARGET_ESP32S2 +#endif + #endif // ARDUINO_ARCH_ESP32 }; \ No newline at end of file diff --git a/src/internal/NeoEsp32I2sMethod.h b/src/internal/NeoEsp32I2sMethod.h index 2b3b34a..8d1d9db 100644 --- a/src/internal/NeoEsp32I2sMethod.h +++ b/src/internal/NeoEsp32I2sMethod.h @@ -26,7 +26,8 @@ License along with NeoPixel. If not, see #pragma once -#ifdef ARDUINO_ARCH_ESP32 +// ESP32C3 I2S is not supported yet due to significant changes to interface +#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3) extern "C" { @@ -289,7 +290,7 @@ typedef NeoEsp32I2sMethodBase NeoEsp32I2s0400KbpsInvertedMethod; typedef NeoEsp32I2sMethodBase NeoEsp32I2s0Apa106InvertedMethod; -#if !defined(CONFIG_IDF_TARGET_ESP32S2) +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) // (I2S_NUM_MAX == 2) typedef NeoEsp32I2sMethodBase NeoEsp32I2s1Ws2812xMethod; @@ -325,9 +326,10 @@ typedef NeoEsp32I2sMethodBase NeoEs typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3800KbpsMethod; typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3400KbpsMethod; -#if !defined(CONFIG_IDF_TARGET_ESP32S2) +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) // (RMT_CHANNEL_MAX == 8) typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2811Method; @@ -725,7 +725,7 @@ typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3800KbpsInvertedMethod; typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3400KbpsInvertedMethod; -#if !defined(CONFIG_IDF_TARGET_ESP32S2) +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) // (RMT_CHANNEL_MAX == 8) typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2811InvertedMethod; @@ -771,12 +771,12 @@ typedef NeoEsp32RmtMethodBase +// ESP32C3 I2S is not supported yet +#if !defined(CONFIG_IDF_TARGET_ESP32C3) + static inline uint32_t getCycleCount(void) { uint32_t ccount; @@ -151,4 +154,5 @@ void IRAM_ATTR NeoEspBitBangBase_send_pixels_inv(uint8_t* pixels, uint8_t* end, } } -#endif +#endif // !defined(CONFIG_IDF_TARGET_ESP32C3) +#endif // defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) diff --git a/src/internal/NeoEspBitBangMethod.h b/src/internal/NeoEspBitBangMethod.h index 31e3811..d7e8d73 100644 --- a/src/internal/NeoEspBitBangMethod.h +++ b/src/internal/NeoEspBitBangMethod.h @@ -28,6 +28,9 @@ License along with NeoPixel. If not, see #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) +// ESP32C3 I2S is not supported yet +#if !defined(CONFIG_IDF_TARGET_ESP32C3) + #if defined(ARDUINO_ARCH_ESP8266) #include #endif @@ -369,4 +372,6 @@ typedef NeoEsp8266BitBangSk6812InvertedMethod NeoEsp8266BitBangLc8812InvertedMet #endif // ESP bitbang doesn't have defaults and should avoided except for testing -#endif + +#endif // !defined(CONFIG_IDF_TARGET_ESP32C3) +#endif // defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)