From 9cd23bd371bcdb67bb3527107482198444330443 Mon Sep 17 00:00:00 2001 From: baggio63446333 Date: Mon, 4 Sep 2023 14:30:49 +0900 Subject: [PATCH] Add support for SONY SPRESENSE board Add optimized code for Spresense board using ifdef ARDUINO_ARCH_SPRESENSE. Tested to work on Spresense board. There is no impact on the other boards. --- Adafruit_SPITFT.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Adafruit_SPITFT.cpp b/Adafruit_SPITFT.cpp index 2c8ef01b..d55ad68f 100644 --- a/Adafruit_SPITFT.cpp +++ b/Adafruit_SPITFT.cpp @@ -1037,6 +1037,17 @@ void Adafruit_SPITFT::writePixels(uint16_t *colors, uint32_t len, bool block, spi_write_blocking(pi_spi, (uint8_t *)colors, len * 2); } return; +#elif defined(ARDUINO_ARCH_SPRESENSE) + if(connection == TFT_HARD_SPI) { + if (!bigEndian) { + swapBytes(colors, len); // convert little-to-big endian for display + } + hwspi._spi->send16(colors, len); + if (!bigEndian) { + swapBytes(colors, len); // big-to-little endian to restore pixel buffer + } + return; + } #elif defined(USE_SPI_DMA) && \ (defined(__SAMD51__) || defined(ARDUINO_SAMD_ZERO)) if ((connection == TFT_HARD_SPI) || (connection == TFT_PARALLEL)) { @@ -1219,6 +1230,24 @@ void Adafruit_SPITFT::writeColor(uint16_t color, uint32_t len) { } return; } +#elif defined(ARDUINO_ARCH_SPRESENSE) + if(connection == TFT_HARD_SPI) { +#define SPI_MAX_PIXELS_AT_ONCE 1024 + static uint16_t temp[SPI_MAX_PIXELS_AT_ONCE]; + uint16_t bufLen = (len < SPI_MAX_PIXELS_AT_ONCE) ? len : SPI_MAX_PIXELS_AT_ONCE, + xferLen; + + for(uint32_t t=0; ttransfer16(w); #else // MSB, LSB because TFTs are generally big-endian hwspi._spi->transfer(w >> 8);