From ef24544bfd574a4ef0bf9ab23645fa72af16c979 Mon Sep 17 00:00:00 2001 From: Zingo Andersen Date: Mon, 25 Dec 2023 23:41:08 +0100 Subject: [PATCH] Support for esp-idf 5.3.0 This fix some compiler problem due to some macro changes in the include files in esp-idf 5.3.0 Signed-off-by: Zingo Andersen --- src/lgfx/v1/panel/Panel_M5HDMI.hpp | 1 + src/lgfx/v1/platforms/esp32/Bus_SPI.cpp | 8 ++++-- src/lgfx/v1/platforms/esp32/common.cpp | 28 ++++++++++++------- src/lgfx/v1/platforms/esp32/common.hpp | 9 ++++-- .../v1/platforms/esp32s3/Bus_Parallel16.cpp | 22 +++++++++------ .../v1/platforms/esp32s3/Bus_Parallel8.cpp | 20 ++++++++----- 6 files changed, 58 insertions(+), 30 deletions(-) diff --git a/src/lgfx/v1/panel/Panel_M5HDMI.hpp b/src/lgfx/v1/panel/Panel_M5HDMI.hpp index 28bc5f0f..d66ab9fc 100644 --- a/src/lgfx/v1/panel/Panel_M5HDMI.hpp +++ b/src/lgfx/v1/panel/Panel_M5HDMI.hpp @@ -16,6 +16,7 @@ Original Source: [tobozo](https://github.com/tobozo) /----------------------------------------------------------------------------*/ #pragma once +#include #include "Panel_Device.hpp" #include "../platforms/common.hpp" diff --git a/src/lgfx/v1/platforms/esp32/Bus_SPI.cpp b/src/lgfx/v1/platforms/esp32/Bus_SPI.cpp index 8e798e45..1db6eccb 100644 --- a/src/lgfx/v1/platforms/esp32/Bus_SPI.cpp +++ b/src/lgfx/v1/platforms/esp32/Bus_SPI.cpp @@ -18,15 +18,17 @@ Original Source: #if defined (ESP_PLATFORM) #include +#include "Bus_SPI.hpp" + /// ESP32-S3をターゲットにした際にREG_SPI_BASEが定義されていなかったので応急処置 ; #if defined ( CONFIG_IDF_TARGET_ESP32S3 ) - #define REG_SPI_BASE(i) (DR_REG_SPI1_BASE + (((i)>1) ? (((i)* 0x1000) + 0x20000) : (((~(i)) & 1)* 0x1000 ))) + #if ( ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0) ) + #define REG_SPI_BASE(i) (DR_REG_SPI1_BASE + (((i)>1) ? (((i)* 0x1000) + 0x20000) : (((~(i)) & 1)* 0x1000 ))) + #endif #elif defined ( CONFIG_IDF_TARGET_ESP32 ) || !defined ( CONFIG_IDF_TARGET ) #define LGFX_SPIDMA_WORKAROUND #endif -#include "Bus_SPI.hpp" - #include "../../misc/pixelcopy.hpp" #if __has_include () diff --git a/src/lgfx/v1/platforms/esp32/common.cpp b/src/lgfx/v1/platforms/esp32/common.cpp index 3e71dcf8..87942a3c 100644 --- a/src/lgfx/v1/platforms/esp32/common.cpp +++ b/src/lgfx/v1/platforms/esp32/common.cpp @@ -18,11 +18,6 @@ Original Source: #if defined (ESP_PLATFORM) #include -/// ESP32-S3をターゲットにした際にREG_SPI_BASEが定義されていなかったので応急処置 ; -#if defined ( CONFIG_IDF_TARGET_ESP32S3 ) - #define REG_SPI_BASE(i) (DR_REG_SPI1_BASE + (((i)>1) ? (((i)* 0x1000) + 0x20000) : (((~(i)) & 1)* 0x1000 ))) -#endif - #include "common.hpp" #include @@ -40,7 +35,11 @@ Original Source: #include #include #include -#include +#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) + #include +#else + #include +#endif #include #include @@ -111,6 +110,10 @@ Original Source: #endif #endif +#if (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)) + #define SOC_GDMA_PAIRS_PER_GROUP_MAX SOC_GDMA_PAIRS_PER_GROUP +#endif + #if defined ( ARDUINO ) #if __has_include () #include @@ -213,7 +216,7 @@ namespace lgfx // SOC_GDMA_TRIG_PERIPH_SPI3 // SOC_GDMA_TRIG_PERIPH_LCD0 // GDMAペリフェラルレジスタの配列を順に調べてペリフェラル番号が一致するDMAチャンネルを特定する; - for (int i = 0; i < SOC_GDMA_PAIRS_PER_GROUP; ++i) + for (int i = 0; i < SOC_GDMA_PAIRS_PER_GROUP_MAX; ++i) { // ESP_LOGD("DBG","GDMA.channel:%d peri_sel:%d", i, GDMA.channel[i].out.peri_sel.sel); if ((*reg(DMA_OUT_PERI_SEL_CH0_REG + i * sizeof(GDMA.channel[0])) & 0x3F) == peripheral_select) @@ -234,7 +237,7 @@ namespace lgfx // SOC_GDMA_TRIG_PERIPH_SPI3 // SOC_GDMA_TRIG_PERIPH_LCD0 // GDMAペリフェラルレジスタの配列を順に調べてペリフェラル番号が一致するDMAチャンネルを特定する; - for (int i = 0; i < SOC_GDMA_PAIRS_PER_GROUP; ++i) + for (int i = 0; i < SOC_GDMA_PAIRS_PER_GROUP_MAX; ++i) { // ESP_LOGD("DBG","GDMA.channel:%d peri_sel:%d", i, GDMA.channel[i].out.peri_sel.sel); if ((*reg(DMA_IN_PERI_SEL_CH0_REG + i * sizeof(GDMA.channel[0])) & 0x3F) == peripheral_select) @@ -483,8 +486,12 @@ namespace lgfx buscfg.flags = SPICOMMON_BUSFLAG_MASTER; buscfg.intr_flags = 0; #if defined (ESP_IDF_VERSION_VAL) - #if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)) + #if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) + buscfg.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO; + #else + #if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)) buscfg.isr_cpu_id = INTR_CPU_ID_AUTO; + #endif #endif #endif if (ESP_OK != spi_bus_initialize(static_cast(spi_host), &buscfg, dma_channel)) @@ -823,7 +830,8 @@ namespace lgfx } #if defined (CONFIG_IDF_TARGET_ESP32S3) #if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 3) && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 1, 0)) \ - || (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 1) && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)) + || (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 1) && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)) \ + || (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) (&dev->comd[0])[index].val = cmd_val; #else (&dev->comd0)[index].val = cmd_val; diff --git a/src/lgfx/v1/platforms/esp32/common.hpp b/src/lgfx/v1/platforms/esp32/common.hpp index 2e7dba51..23d5c1bc 100644 --- a/src/lgfx/v1/platforms/esp32/common.hpp +++ b/src/lgfx/v1/platforms/esp32/common.hpp @@ -35,8 +35,13 @@ Original Source: #include #if !defined ( REG_SPI_BASE ) -//#define REG_SPI_BASE(i) (DR_REG_SPI0_BASE - (i) * 0x1000) -#define REG_SPI_BASE(i) (DR_REG_SPI2_BASE) + /// ESP32-S3をターゲットにした際にREG_SPI_BASEが定義されていなかったので応急処置 5.3まで; + #if defined ( CONFIG_IDF_TARGET_ESP32S3 ) + #define REG_SPI_BASE(i) (DR_REG_SPI1_BASE + (((i)>1) ? (((i)* 0x1000) + 0x20000) : (((~(i)) & 1)* 0x1000 ))) + #else + //#define REG_SPI_BASE(i) (DR_REG_SPI0_BASE - (i) * 0x1000) + #define REG_SPI_BASE(i) (DR_REG_SPI2_BASE) + #endif #endif #if defined ( ESP_IDF_VERSION_VAL ) diff --git a/src/lgfx/v1/platforms/esp32s3/Bus_Parallel16.cpp b/src/lgfx/v1/platforms/esp32s3/Bus_Parallel16.cpp index a5e9bf43..dc8c59b7 100644 --- a/src/lgfx/v1/platforms/esp32s3/Bus_Parallel16.cpp +++ b/src/lgfx/v1/platforms/esp32s3/Bus_Parallel16.cpp @@ -40,6 +40,12 @@ Original Source: #define DMA_OUTFIFO_EMPTY_CH0 GDMA_OUTFIFO_EMPTY_L3_CH0 #endif +#if ( ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0) ) + #if !defined (LCD_CAM_LCD_UPDATE) + #define LCD_CAM_LCD_UPDATE LCD_CAM_LCD_UPDATE_REG + #endif +#endif + namespace lgfx { inline namespace v1 @@ -178,7 +184,7 @@ namespace lgfx // dev->lcd_user.lcd_bit_order = false; // dev->lcd_user.lcd_8bits_order = false; - dev->lcd_user.val = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG; + dev->lcd_user.val = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE; _cache_flip = _cache[0]; } @@ -210,7 +216,7 @@ namespace lgfx dev->lcd_cmd_val.lcd_cmd_value = _align_data; auto reg_lcd_user = &(dev->lcd_user.val); while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE | LCD_CAM_LCD_START; } bool Bus_Parallel16::writeCommand(uint32_t data, uint_fast8_t bit_length) @@ -227,12 +233,12 @@ namespace lgfx if (bit_length <= 16) { while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE | LCD_CAM_LCD_START; return true; } while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + *reg_lcd_user = LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE | LCD_CAM_LCD_START; return true; } @@ -247,7 +253,7 @@ namespace lgfx _has_align_data = false; dev->lcd_cmd_val.val = _align_data | (data << 8); while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE | LCD_CAM_LCD_START; if (--bytes == 0) { return; } data >>= 8; } @@ -258,11 +264,11 @@ namespace lgfx if (bytes == 4) { while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + *reg_lcd_user = LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE | LCD_CAM_LCD_START; return; } while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE | LCD_CAM_LCD_START; if (bytes == 2) { return; } data >>= 16; } @@ -414,7 +420,7 @@ namespace lgfx while (*_dma_outstatus_reg & DMA_OUTFIFO_EMPTY_CH0 ) {} - *reg_lcd_user = LCD_CAM_LCD_ALWAYS_OUT_EN | LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_DOUT | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + *reg_lcd_user = LCD_CAM_LCD_ALWAYS_OUT_EN | LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_DOUT | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE | LCD_CAM_LCD_START; } while (length & ~1u); } if (length) diff --git a/src/lgfx/v1/platforms/esp32s3/Bus_Parallel8.cpp b/src/lgfx/v1/platforms/esp32s3/Bus_Parallel8.cpp index d694fd5f..fa57560b 100644 --- a/src/lgfx/v1/platforms/esp32s3/Bus_Parallel8.cpp +++ b/src/lgfx/v1/platforms/esp32s3/Bus_Parallel8.cpp @@ -40,6 +40,12 @@ Original Source: #define DMA_OUTFIFO_EMPTY_CH0 GDMA_OUTFIFO_EMPTY_L3_CH0 #endif +#if ( ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0) ) + #if !defined (LCD_CAM_LCD_UPDATE) + #define LCD_CAM_LCD_UPDATE LCD_CAM_LCD_UPDATE_REG + #endif +#endif + namespace lgfx { inline namespace v1 @@ -183,7 +189,7 @@ namespace lgfx // dev->lcd_user.lcd_bit_order = false; // dev->lcd_user.lcd_8bits_order = false; - dev->lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG; + dev->lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE; _cache_flip = _cache[0]; } @@ -217,7 +223,7 @@ namespace lgfx dev->lcd_cmd_val.lcd_cmd_value = data; data >>= 8; while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE | LCD_CAM_LCD_START; } while (--bytes); return true; } @@ -234,20 +240,20 @@ namespace lgfx dev->lcd_cmd_val.lcd_cmd_value = data; data >>= 8; while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE | LCD_CAM_LCD_START; if (0 == --bytes) { return; } } dev->lcd_cmd_val.lcd_cmd_value = (data & 0xFF) | (data << 8); while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_UPDATE | LCD_CAM_LCD_START; bytes >>= 1; if (--bytes) { data >>= 16; dev->lcd_cmd_val.lcd_cmd_value = (data & 0xFF) | (data << 8); while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_UPDATE | LCD_CAM_LCD_START; } } @@ -351,7 +357,7 @@ namespace lgfx dev->lcd_cmd_val.lcd_cmd_value = data[0] | data[1] << 16; uint32_t cmd_val = data[2] | data[3] << 16; while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_UPDATE | LCD_CAM_LCD_START; if (use_dma) { @@ -376,7 +382,7 @@ namespace lgfx } dev->lcd_cmd_val.lcd_cmd_value = cmd_val; dev->lcd_misc.lcd_cd_data_set = !dc; - *reg_lcd_user = LCD_CAM_LCD_ALWAYS_OUT_EN | LCD_CAM_LCD_DOUT | LCD_CAM_LCD_CMD | LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_UPDATE_REG; + *reg_lcd_user = LCD_CAM_LCD_ALWAYS_OUT_EN | LCD_CAM_LCD_DOUT | LCD_CAM_LCD_CMD | LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_UPDATE; while (*reg_lcd_user & LCD_CAM_LCD_START) {} *reg_lcd_user = LCD_CAM_LCD_ALWAYS_OUT_EN | LCD_CAM_LCD_DOUT | LCD_CAM_LCD_CMD | LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_START; } while (length);