From df23e14675c6d7c0ac87d1b6a48a832bf0f2ac78 Mon Sep 17 00:00:00 2001 From: Bodmer Date: Thu, 19 Nov 2020 00:36:59 +0000 Subject: [PATCH] Make DMA wait handling consistent for ESP32 and STM32 --- Processors/TFT_eSPI_ESP32.c | 8 ++++++-- Processors/TFT_eSPI_STM32.c | 9 +++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Processors/TFT_eSPI_ESP32.c b/Processors/TFT_eSPI_ESP32.c index ff28242..1b519bf 100644 --- a/Processors/TFT_eSPI_ESP32.c +++ b/Processors/TFT_eSPI_ESP32.c @@ -538,13 +538,14 @@ void TFT_eSPI::dmaWait(void) /*************************************************************************************** -** Function name: pushImageDMA +** Function name: pushPixelsDMA ** Description: Push pixels to TFT (len must be less than 32767) ***************************************************************************************/ // This will byte swap the original image if setSwapBytes(true) was called by sketch. void TFT_eSPI::pushPixelsDMA(uint16_t* image, uint32_t len) { if ((len == 0) || (!DMA_Enabled)) return; + dmaWait(); if(_swapBytes) { @@ -592,7 +593,10 @@ void TFT_eSPI::pushImageDMA(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t uint32_t len = dw*dh; - if (buffer == nullptr) { buffer = image; dmaWait(); } + if (buffer == nullptr) { + buffer = image; + dmaWait(); + } // If image is clipped, copy pixels into a contiguous block if ( (dw != w) || (dh != h) ) { diff --git a/Processors/TFT_eSPI_STM32.c b/Processors/TFT_eSPI_STM32.c index aa77e77..bb1147b 100644 --- a/Processors/TFT_eSPI_STM32.c +++ b/Processors/TFT_eSPI_STM32.c @@ -421,7 +421,7 @@ void TFT_eSPI::dmaWait(void) /*************************************************************************************** -** Function name: pushImageDMA +** Function name: pushPixelsDMA ** Description: Push pixels to TFT (len must be less than 32767) ***************************************************************************************/ // This will byte swap the original image if setSwapBytes(true) was called by sketch. @@ -462,11 +462,12 @@ void TFT_eSPI::pushImageDMA(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t if (dw < 1 || dh < 1) return; - if (buffer == nullptr) buffer = image; - uint32_t len = dw*dh; - while (spiHal.State == HAL_SPI_STATE_BUSY_TX); // Check if SPI Tx is busy + if (buffer == nullptr) { + buffer = image; + while (spiHal.State == HAL_SPI_STATE_BUSY_TX); // Check if SPI Tx is busy + } // If image is clipped, copy pixels into a contiguous block if ( (dw != w) || (dh != h) ) {