Optional ESP32 DMA engine control of TFT_CS

This change has no impact on examples
See also #850
This commit is contained in:
Bodmer
2020-12-11 21:10:12 +00:00
parent 53c3fcaa05
commit 1b54ce87e9
3 changed files with 13 additions and 5 deletions

View File

@@ -665,7 +665,7 @@ void IRAM_ATTR dc_callback(spi_transaction_t *spi_tx)
** Function name: initDMA ** Function name: initDMA
** Description: Initialise the DMA engine - returns true if init OK ** Description: Initialise the DMA engine - returns true if init OK
***************************************************************************************/ ***************************************************************************************/
bool TFT_eSPI::initDMA(void) bool TFT_eSPI::initDMA(bool ctrl_cs)
{ {
if (DMA_Enabled) return false; if (DMA_Enabled) return false;
@@ -680,6 +680,10 @@ bool TFT_eSPI::initDMA(void)
.flags = 0, .flags = 0,
.intr_flags = 0 .intr_flags = 0
}; };
int8_t pin = -1;
if (ctrl_cs) pin = TFT_CS;
spi_device_interface_config_t devcfg = { spi_device_interface_config_t devcfg = {
.command_bits = 0, .command_bits = 0,
.address_bits = 0, .address_bits = 0,
@@ -690,7 +694,7 @@ bool TFT_eSPI::initDMA(void)
.cs_ena_posttrans = 0, .cs_ena_posttrans = 0,
.clock_speed_hz = SPI_FREQUENCY, .clock_speed_hz = SPI_FREQUENCY,
.input_delay_ns = 0, .input_delay_ns = 0,
.spics_io_num = TFT_CS, .spics_io_num = pin,
.flags = SPI_DEVICE_NO_DUMMY, //0, .flags = SPI_DEVICE_NO_DUMMY, //0,
.queue_size = 1, .queue_size = 1,
.pre_cb = 0, //dc_callback, //Callback to handle D/C line .pre_cb = 0, //dc_callback, //Callback to handle D/C line

View File

@@ -538,8 +538,10 @@ void TFT_eSPI::pushImageDMA(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t
// This initialisation is for STM32F2xx/4xx/7xx processors and may not work on others // This initialisation is for STM32F2xx/4xx/7xx processors and may not work on others
// Dual core H7xx series not supported yet, they are different and have a DMA MUX: // Dual core H7xx series not supported yet, they are different and have a DMA MUX:
// https://electronics.stackexchange.com/questions/379813/configuring-the-dma-request-multiplexer-on-a-stm32h7-mcu // https://electronics.stackexchange.com/questions/379813/configuring-the-dma-request-multiplexer-on-a-stm32h7-mcu
bool TFT_eSPI::initDMA(void) bool TFT_eSPI::initDMA(bool ctrl_cs)
{ {
ctrl_cs = ctrl_cs; // Not used for STM32, so stop compiler warning
#if (TFT_SPI_PORT == 1) #if (TFT_SPI_PORT == 1)
__HAL_RCC_DMA2_CLK_ENABLE(); // Enable DMA2 clock __HAL_RCC_DMA2_CLK_ENABLE(); // Enable DMA2 clock
dmaHal.Init.Channel = DMA_CHANNEL_3; // DMA channel 3 is for SPI1 TX dmaHal.Init.Channel = DMA_CHANNEL_3; // DMA channel 3 is for SPI1 TX

View File

@@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_ #ifndef _TFT_eSPIH_
#define _TFT_eSPIH_ #define _TFT_eSPIH_
#define TFT_ESPI_VERSION "2.3.52" #define TFT_ESPI_VERSION "2.3.53"
// Bit level feature flags // Bit level feature flags
// Bit 0 set: viewport capability // Bit 0 set: viewport capability
@@ -618,7 +618,9 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
// function will wait for the DMA to complete, so this may defeat any DMA performance benefit. // function will wait for the DMA to complete, so this may defeat any DMA performance benefit.
// //
bool initDMA(void); // Initialise the DMA engine and attach to SPI bus - typically used in setup() bool initDMA(bool ctrl_cs = false); // Initialise the DMA engine and attach to SPI bus - typically used in setup()
// Parameter "true" enables DMA engine control of TFT chip select (ESP32 only)
// For ESP32 only, TFT reads will not work if parameter is true
void deInitDMA(void); // De-initialise the DMA engine and detach from SPI bus - typically not used void deInitDMA(void); // De-initialise the DMA engine and detach from SPI bus - typically not used
// Push an image to the TFT using DMA, buffer is optional and grabs (double buffers) a copy of the image // Push an image to the TFT using DMA, buffer is optional and grabs (double buffers) a copy of the image