From de37f88644d965a16fb6431763047a7de1dd1ce8 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 22 Aug 2021 11:49:27 +0200 Subject: [PATCH] S2 compile fix --- include/esp32x_fixes.h | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/include/esp32x_fixes.h b/include/esp32x_fixes.h index 606c87b6e..047a343c8 100644 --- a/include/esp32x_fixes.h +++ b/include/esp32x_fixes.h @@ -20,12 +20,12 @@ /* * Xtensa toolchain declares `int32_t` as `int` but RISC-V toolchain * declares `int32_t` as `long int` which causes compilation errors. - * + * * See: * https://github.com/espressif/esp-idf/issues/6906 * https://github.com/espressif/arduino-esp32/issues/5086 - * - * You need to add the following lines in `build_flags`: + * + * You need to add the following lines in `build_flags`: * -I$PROJECT_DIR/include * -include "esp32x_fixes.h" */ @@ -39,16 +39,27 @@ #endif // __riscv -#if CONFIG_IDF_TARGET_ESP32C3 -// 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 +//alias, deprecated for the chips after esp32s2 +#ifdef CONFIG_IDF_TARGET_ESP32 +#define SPI_HOST SPI1_HOST +#define HSPI_HOST SPI2_HOST +#define VSPI_HOST SPI3_HOST -// 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 +#elif CONFIG_IDF_TARGET_ESP32S2 +// SPI_HOST (SPI1_HOST) is not supported by the SPI Master and SPI Slave driver on ESP32-S2 and later +#define SPI_HOST SPI1_HOST +#define FSPI_HOST SPI2_HOST +#define HSPI_HOST SPI3_HOST +#define VSPI_HOST SPI3_HOST + +#elif CONFIG_IDF_TARGET_ESP32C3 #define SPI_HOST SPI1_HOST #define HSPI_HOST SPI2_HOST #define VSPI_HOST SPI2_HOST /* No SPI3_host on C3 */ -#endif +// 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 ))) +// 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) +#endif // REG_SPI_BASE +#endif // TARGET