nRF52840: only use the SPIM3 DMA path with hardware SPI

writePixels and writeColor used hwspi._spi without checking the connection,
so displays on software SPI hung on the first fill.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mikey SklarandClaude Opus 5.5 committed 2026-10-17 16:27:10 -07:00
1 parent 0e844ad645
commit 98ecc97d39
1 file changed
+7 -4
+7 -4
View File
@@ -1033,6 +1033,7 @@ void Adafruit_SPITFT::writePixels(uint16_t *colors, uint32_t len, bool block,
}
#elif defined(ARDUINO_NRF52_ADAFRUIT) && \
defined(NRF52840_XXAA) // Adafruit nRF52 use SPIM3 DMA at 32Mhz
if (connection == TFT_HARD_SPI) {
if (!bigEndian) {
swapBytes(colors, len); // convert little-to-big endian for display
}
@@ -1040,8 +1041,8 @@ void Adafruit_SPITFT::writePixels(uint16_t *colors, uint32_t len, bool block,
if (!bigEndian) {
swapBytes(colors, len); // big-to-little endian to restore pixel buffer
}
return;
}
#elif defined(ARDUINO_ARCH_RP2040)
spi_inst_t *pi_spi = hwspi._spi == &SPI ? __SPI0_DEVICE : __SPI1_DEVICE;
@@ -1252,10 +1253,12 @@ void Adafruit_SPITFT::writeColor(uint16_t color, uint32_t len) {
defined(NRF52840_XXAA) // Adafruit nRF52840 use SPIM3 DMA at 32Mhz
// at most 2 scan lines
uint32_t const pixbufcount = min(len, ((uint32_t)2 * width()));
uint16_t *pixbuf = (uint16_t *)rtos_malloc(2 * pixbufcount);
uint16_t *pixbuf = (connection == TFT_HARD_SPI)
? (uint16_t *)rtos_malloc(2 * pixbufcount)
: NULL;
// use SPI3 DMA if we could allocate buffer, else fall back to writing each
// pixel loop below
// use SPI3 DMA if hardware SPI and we could allocate buffer, else fall back
// to writing each pixel loop below
if (pixbuf) {
uint16_t const swap_color = __builtin_bswap16(color);