From d292a3c49773417bcd192a322d4a17337e6c7a0a Mon Sep 17 00:00:00 2001 From: Alexander Drozdov Date: Sun, 25 Jun 2023 22:21:38 +1000 Subject: [PATCH] Fixed SPI displays work with LGT8fx based boards Tested with BSP and ILI9341 SPI based display: * LGT8fx: https://github.com/dbuezas/lgt8fx * Nulllab: https://github.com/nulllaborg/arduino_nulllab Issue: SPI based displays work well with BitBang mode, but does not work with HW SPI. Root cause: AVR_WRITESPI() macrosses uses direct access to the HW but LGT8fx has a little bit different implementation. Also, standard implementation sounds like good for default use. --- Adafruit_SPITFT.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Adafruit_SPITFT.cpp b/Adafruit_SPITFT.cpp index 2c8ef01b..6ff273d4 100644 --- a/Adafruit_SPITFT.cpp +++ b/Adafruit_SPITFT.cpp @@ -1362,7 +1362,7 @@ void Adafruit_SPITFT::writeColor(uint16_t color, uint32_t len) { spi_write_blocking(pi_spi, (uint8_t *)&color, 2); #else // !ESP8266 && !ARDUINO_ARCH_RP2040 while (len--) { -#if defined(__AVR__) +#if defined(__AVR__) && !defined(__LGT8F__) AVR_WRITESPI(hi); AVR_WRITESPI(lo); #elif defined(ESP32) @@ -2109,7 +2109,7 @@ inline void Adafruit_SPITFT::SPI_END_TRANSACTION(void) { */ void Adafruit_SPITFT::spiWrite(uint8_t b) { if (connection == TFT_HARD_SPI) { -#if defined(__AVR__) +#if defined(__AVR__) && !defined(__LGT8F__) AVR_WRITESPI(b); #elif defined(ESP8266) || defined(ESP32) hwspi._spi->write(b); @@ -2417,7 +2417,7 @@ inline bool Adafruit_SPITFT::SPI_MISO_READ(void) { */ void Adafruit_SPITFT::SPI_WRITE16(uint16_t w) { if (connection == TFT_HARD_SPI) { -#if defined(__AVR__) +#if defined(__AVR__) && !defined(__LGT8F__) AVR_WRITESPI(w >> 8); AVR_WRITESPI(w); #elif defined(ESP8266) || defined(ESP32) @@ -2471,7 +2471,7 @@ void Adafruit_SPITFT::SPI_WRITE16(uint16_t w) { */ void Adafruit_SPITFT::SPI_WRITE32(uint32_t l) { if (connection == TFT_HARD_SPI) { -#if defined(__AVR__) +#if defined(__AVR__) && !defined(__LGT8F__) AVR_WRITESPI(l >> 24); AVR_WRITESPI(l >> 16); AVR_WRITESPI(l >> 8);