From afffd0dbbc2131acf4803be28cf625102b975f38 Mon Sep 17 00:00:00 2001 From: lovyan03 <42724151+lovyan03@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:56:49 +0900 Subject: [PATCH] Fixed an issue where the SPI peripheral would conflict with devices that controlled the CS pin when used with LGFX. --- src/lgfx/v1/platforms/esp32/Bus_SPI.cpp | 22 +++++++++++++++++++++- src/lgfx/v1/platforms/esp32/common.cpp | 21 ++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/lgfx/v1/platforms/esp32/Bus_SPI.cpp b/src/lgfx/v1/platforms/esp32/Bus_SPI.cpp index 2aa114b9..33f480de 100644 --- a/src/lgfx/v1/platforms/esp32/Bus_SPI.cpp +++ b/src/lgfx/v1/platforms/esp32/Bus_SPI.cpp @@ -209,7 +209,27 @@ namespace lgfx } auto spi_mode = _cfg.spi_mode; - uint32_t pin = (spi_mode & 2) ? SPI_CK_IDLE_EDGE : 0; + uint32_t pin = 0 +#if defined ( SPI_CS0_DIS ) + | SPI_CS0_DIS +#endif +#if defined ( SPI_CS1_DIS ) + | SPI_CS1_DIS +#endif +#if defined ( SPI_CS2_DIS ) + | SPI_CS2_DIS +#endif +#if defined ( SPI_CS3_DIS ) + | SPI_CS3_DIS +#endif +#if defined ( SPI_CS4_DIS ) + | SPI_CS4_DIS +#endif +#if defined ( SPI_CS5_DIS ) + | SPI_CS5_DIS +#endif + ; + if (spi_mode & 2) pin = SPI_CK_IDLE_EDGE; if (_cfg.use_lock) spi::beginTransaction(_cfg.spi_host); diff --git a/src/lgfx/v1/platforms/esp32/common.cpp b/src/lgfx/v1/platforms/esp32/common.cpp index ffd53fe7..ff7f7713 100644 --- a/src/lgfx/v1/platforms/esp32/common.cpp +++ b/src/lgfx/v1/platforms/esp32/common.cpp @@ -580,7 +580,26 @@ namespace lgfx uint32_t user = SPI_USR_MOSI | SPI_USR_MISO | SPI_DOUTDIN; if (spi_mode == 1 || spi_mode == 2) user |= SPI_CK_OUT_EDGE; - uint32_t pin = 0; + uint32_t pin = 0 +#if defined ( SPI_CS0_DIS ) + | SPI_CS0_DIS +#endif +#if defined ( SPI_CS1_DIS ) + | SPI_CS1_DIS +#endif +#if defined ( SPI_CS2_DIS ) + | SPI_CS2_DIS +#endif +#if defined ( SPI_CS3_DIS ) + | SPI_CS3_DIS +#endif +#if defined ( SPI_CS4_DIS ) + | SPI_CS4_DIS +#endif +#if defined ( SPI_CS5_DIS ) + | SPI_CS5_DIS +#endif + ; if (spi_mode & 2) pin = SPI_CK_IDLE_EDGE; beginTransaction(spi_host);