From 2d5841af9ca3a4bdee532b4c9bbaef833a605249 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Thu, 10 Jun 2021 19:07:20 +0200 Subject: [PATCH 1/3] Esp32c3 fix compilation for SPI and uDisplay --- include/fix_esp32c3.h | 14 ++++++++++++++ .../src/internal/DotStarEsp32DmaSpiMethod.h | 4 ++-- lib/lib_display/UDisplay/uDisplay.h | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) 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) From 22102000ef09b0ce19edc1e8505ade6dbedfb33d Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Thu, 10 Jun 2021 19:15:15 +0200 Subject: [PATCH 2/3] Remove no more needed lib exclusions --- platformio_tasmota_cenv_sample.ini | 4 ---- 1 file changed, 4 deletions(-) diff --git a/platformio_tasmota_cenv_sample.ini b/platformio_tasmota_cenv_sample.ini index 3d7a32bef..37d2e87cd 100644 --- a/platformio_tasmota_cenv_sample.ini +++ b/platformio_tasmota_cenv_sample.ini @@ -74,10 +74,6 @@ lib_extra_dirs = lib/libesp32 lib_ignore = NimBLE-Arduino Micro-RTSP - ILI9488 - SSD3115 - RA8876 - universal display Library ; *** EXPERIMENTAL Tasmota version for ESP32 IDF4.4. [env:tasmota32idf4] From 0e278fe13b830105d37d33d7d65ce4d82de47964 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Thu, 10 Jun 2021 19:35:33 +0200 Subject: [PATCH 3/3] Remove SPI3_HOST that does not exist on esp32c3 --- include/fix_esp32c3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fix_esp32c3.h b/include/fix_esp32c3.h index 96e994159..d1e0bcb80 100644 --- a/include/fix_esp32c3.h +++ b/include/fix_esp32c3.h @@ -50,5 +50,5 @@ //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 +#define VSPI_HOST SPI2_HOST /* No SPI3_host on C3 */ +#endif