Skip to content

Commit a103ad2

Browse files
Restore hwspi._mode at the end of all DMA transfers
1 parent 5fa33d0 commit a103ad2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Adafruit_SPITFT.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ void Adafruit_SPITFT::initSPI(uint32_t freq, uint8_t spiMode) {
528528
hwspi.settings = SPISettings(freq, MSBFIRST, spiMode);
529529
#else
530530
hwspi._freq = freq; // Save freq value for later
531-
hwspi._mode = spiMode; // Save spiMode value for later
532531
#endif
532+
hwspi._mode = spiMode; // Save spiMode value for later
533533
// Call hwspi._spi->begin() ONLY if this is among the 'established'
534534
// SPI interfaces in variant.h. For DIY roll-your-own SERCOM SPIs,
535535
// begin() and pinPeripheral() calls MUST be made in one's calling
@@ -1033,7 +1033,7 @@ void Adafruit_SPITFT::writePixels(uint16_t *colors, uint32_t len,
10331033
#if defined(__SAMD51__) || defined(_SAMD21_)
10341034
if(connection == TFT_HARD_SPI) {
10351035
// See SAMD51/21 note in writeColor()
1036-
hwspi._spi->setDataMode(SPI_MODE0);
1036+
hwspi._spi->setDataMode(hwspi._mode);
10371037
} else {
10381038
pinPeripheral(tft8._wr, PIO_OUTPUT); // Switch WR back to GPIO
10391039
}
@@ -1062,7 +1062,7 @@ void Adafruit_SPITFT::dmaWait(void) {
10621062
#if defined(__SAMD51__) || defined(_SAMD21_)
10631063
if(connection == TFT_HARD_SPI) {
10641064
// See SAMD51/21 note in writeColor()
1065-
hwspi._spi->setDataMode(SPI_MODE0);
1065+
hwspi._spi->setDataMode(hwspi._mode);
10661066
} else {
10671067
pinPeripheral(tft8._wr, PIO_OUTPUT); // Switch WR back to GPIO
10681068
}
@@ -1188,7 +1188,7 @@ void Adafruit_SPITFT::writeColor(uint16_t color, uint32_t len) {
11881188
// state on completion. Workaround is to explicitly set it back...
11891189
// (5/17/2019: apparently SAMD21 too, in certain cases, observed
11901190
// with ST7789 display.)
1191-
hwspi._spi->setDataMode(SPI_MODE0);
1191+
hwspi._spi->setDataMode(hwspi._mode);
11921192
} else {
11931193
pinPeripheral(tft8._wr, PIO_OUTPUT); // Switch WR back to GPIO
11941194
}

Adafruit_SPITFT.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ class Adafruit_SPITFT : public Adafruit_GFX {
395395
SPISettings settings; ///< SPI transaction settings
396396
#else
397397
uint32_t _freq; ///< SPI bitrate (if no SPI transactions)
398-
uint32_t _mode; ///< SPI data mode (if no SPI transactions)
399398
#endif
399+
uint32_t _mode; ///< SPI data mode (transactions or no)
400400
} hwspi; ///< Hardware SPI values
401401
struct { // Values specific to SOFTWARE SPI:
402402
#if defined(USE_FAST_PINIO)

0 commit comments

Comments
 (0)