From b70d2dc151db61ec44cb5b7a2a043917a1d181a9 Mon Sep 17 00:00:00 2001 From: C47D Date: Tue, 22 Jun 2021 13:05:58 -0500 Subject: [PATCH] lvgl_helpers: Fix compilation error when using ESP-IDF v4.3 or below --- lvgl_helpers.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lvgl_helpers.c b/lvgl_helpers.c index a215c43..2e78fef 100644 --- a/lvgl_helpers.c +++ b/lvgl_helpers.c @@ -202,14 +202,21 @@ bool lvgl_i2c_driver_init(int port, int sda_pin, int scl_pin, int speed_hz) return ESP_OK != err; } -/* Initialize spi bus master */ +/* Initialize spi bus master + * + * NOTE: dma_chan type and value changed to int instead of spi_dma_chan_t + * for backwards compatibility with ESP-IDF versions prior v4.3. + * + * We could use the ESP_IDF_VERSION_VAL macro available in the "esp_idf_version.h" + * header available since ESP-IDF v4. + */ bool lvgl_spi_driver_init(int host, int miso_pin, int mosi_pin, int sclk_pin, int max_transfer_sz, int dma_channel, int quadwp_pin, int quadhd_pin) { - spi_dma_chan_t dma_chan = SPI_DMA_DISABLED; + int dma_chan = 0 /* SPI_DMA_DISABLED */; #if defined (CONFIG_IDF_TARGET_ESP32) assert((SPI_HOST <= host) && (VSPI_HOST >= host)); @@ -231,7 +238,7 @@ bool lvgl_spi_driver_init(int host, "SPI1_HOST", "SPI2_HOST", "SPI3_HOST" }; - dma_chan = SPI_DMA_CH_AUTO; + dma_chan = 3 /* SPI_DMA_CH_AUTO */; #else #error "Target chip not selected" #endif