Skip to content

Commit

Permalink
Fixed an issue where the SPI peripheral would conflict with devices t…
Browse files Browse the repository at this point in the history
…hat controlled the CS pin when used with LGFX.
  • Loading branch information
lovyan03 committed Aug 22, 2024
1 parent b255484 commit afffd0d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/lgfx/v1/platforms/esp32/Bus_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
21 changes: 20 additions & 1 deletion src/lgfx/v1/platforms/esp32/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit afffd0d

Please sign in to comment.