diff --git a/include/fix_esp32c3.h b/include/fix_esp32c3.h index 1964eb354..96e994159 100644 --- a/include/fix_esp32c3.h +++ b/include/fix_esp32c3.h @@ -38,3 +38,17 @@ #define __UINT32_TYPE__ unsigned int #endif // __riscv + +// fix a bug in esp-idf 4.4 for esp32c3 +#ifndef REG_SPI_BASE +#define REG_SPI_BASE(i) (DR_REG_SPI1_BASE + (((i)>1) ? (((i)* 0x1000) + 0x20000) : (((~(i)) & 1)* 0x1000 ))) +#endif + +#if CONFIG_IDF_TARGET_ESP32C3 +// SPI_MOSI_DLEN_REG is not defined anymore in esp32c3, instead use SPI_MS_DLEN_REG +#define SPI_MOSI_DLEN_REG(x) SPI_MS_DLEN_REG(x) +//alias for different chips, deprecated for the chips after esp32s2 +#define SPI_HOST SPI1_HOST +#define HSPI_HOST SPI2_HOST +#define VSPI_HOST SPI3_HOST +#endif \ No newline at end of file diff --git a/lib/lib_basic/NeoPixelBus/src/internal/DotStarEsp32DmaSpiMethod.h b/lib/lib_basic/NeoPixelBus/src/internal/DotStarEsp32DmaSpiMethod.h index d71cf79d8..a9d149b71 100644 --- a/lib/lib_basic/NeoPixelBus/src/internal/DotStarEsp32DmaSpiMethod.h +++ b/lib/lib_basic/NeoPixelBus/src/internal/DotStarEsp32DmaSpiMethod.h @@ -29,9 +29,9 @@ License along with NeoPixel. If not, see #include "driver/spi_master.h" -#if defined(CONFIG_IDF_TARGET_ESP32C3) +#if defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(HSPI_HOST) // HSPI_HOST depreciated in C3 -#define HSPI_HOST SPI3_HOST +#define HSPI_HOST SPI2_HOST #endif #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) diff --git a/lib/lib_display/UDisplay/uDisplay.h b/lib/lib_display/UDisplay/uDisplay.h index 78f96ad6c..42b8f47a3 100755 --- a/lib/lib_display/UDisplay/uDisplay.h +++ b/lib/lib_display/UDisplay/uDisplay.h @@ -54,8 +54,13 @@ enum uColorType { uCOLOR_BW, uCOLOR_COLOR }; #undef GPIO_CLR #undef GPIO_SET_SLOW #undef GPIO_CLR_SLOW +#if CONFIG_IDF_TARGET_ESP32C3 +#define GPIO_CLR(A) GPIO.out_w1tc.val = (1 << A) +#define GPIO_SET(A) GPIO.out_w1ts.val = (1 << A) +#else // plain ESP32 #define GPIO_CLR(A) GPIO.out_w1tc = (1 << A) #define GPIO_SET(A) GPIO.out_w1ts = (1 << A) +#endif #define GPIO_CLR_SLOW(A) digitalWrite(A, LOW) #define GPIO_SET_SLOW(A) digitalWrite(A, HIGH)