Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SONY SPRESENSE board #431

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Adafruit_SPITFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -1219,6 +1230,25 @@ 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;
uint16_t xferLen;

for (uint32_t t = 0; t < bufLen; t++) {
temp[t] = color;
}
// Issue pixels in blocks from temp buffer
while (len) { // While pixels remain
xferLen = (bufLen < len) ? bufLen : len; // How many this pass?
writePixels((uint16_t *)temp, xferLen, true, true);
len -= xferLen;
}
return;
}
#elif defined(ARDUINO_NRF52_ADAFRUIT) && \
defined(NRF52840_XXAA) // Adafruit nRF52840 use SPIM3 DMA at 32Mhz
// at most 2 scan lines
Expand Down Expand Up @@ -2426,6 +2456,8 @@ void Adafruit_SPITFT::SPI_WRITE16(uint16_t w) {
spi_inst_t *pi_spi = hwspi._spi == &SPI ? spi0 : spi1;
w = __builtin_bswap16(w);
spi_write_blocking(pi_spi, (uint8_t *)&w, 2);
#elif defined(ARDUINO_ARCH_SPRESENSE)
hwspi._spi->transfer16(w);
#else
// MSB, LSB because TFTs are generally big-endian
hwspi._spi->transfer(w >> 8);
Expand Down