diff --git a/lvgl_helpers.c b/lvgl_helpers.c index b5d23e2..886d941 100644 --- a/lvgl_helpers.c +++ b/lvgl_helpers.c @@ -82,14 +82,6 @@ void lvgl_interface_init(void) ESP_LOGI(TAG, "Display buffer size: %d", display_buffer_size); - /* SPI DMA Channel selection - * SPI_DMA_CH1 is only defined for ESP32, so let the driver choose which - * channel to use, and use the proven channel 1 on esp32 targets */ - int dma_channel = 3; -#if defined (CONFIG_IDF_TARGET_ESP32) - dma_channel = 1; -#endif - #if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X) init_ft81x(dma_channel); return; @@ -107,8 +99,9 @@ void lvgl_interface_init(void) miso = TP_SPI_MISO; #endif + // We use DMA channel 1 for all cases lvgl_spi_driver_init(TFT_SPI_HOST, miso, DISP_SPI_MOSI, DISP_SPI_CLK, - spi_max_transfer_size, dma_channel, DISP_SPI_IO2, DISP_SPI_IO3); + spi_max_transfer_size, 1, DISP_SPI_IO2, DISP_SPI_IO3); disp_spi_add_device(TFT_SPI_HOST); @@ -267,12 +260,6 @@ bool lvgl_spi_driver_init(int host, int dma_channel, int quadwp_pin, int quadhd_pin) { -#if defined (SPI_HOST_MAX) - assert((SPI1_HOST <= host) && (SPI_HOST_MAX > host)); -#else - assert((SPI1_HOST <= host) && ((SPI3_HOST + 1) > host)); -#endif - const char *spi_names[] = { "SPI1_HOST", "SPI2_HOST", "SPI3_HOST" }; @@ -293,13 +280,7 @@ bool lvgl_spi_driver_init(int host, }; ESP_LOGI(TAG, "Initializing SPI bus..."); - -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0) - esp_err_t ret = spi_bus_initialize((spi_host_device_t) host, &buscfg, (spi_dma_chan_t)dma_channel); -#else - esp_err_t ret = spi_bus_initialize(host, &buscfg, dma_channel); -#endif - + esp_err_t ret = spi_bus_initialize((spi_host_device_t) host, &buscfg, dma_channel); assert(ret == ESP_OK); return ESP_OK != ret; @@ -308,7 +289,7 @@ bool lvgl_spi_driver_init(int host, static int calculate_spi_max_transfer_size(const int display_buffer_size) { int retval = 0; - + #if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481) || \ defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9488) retval = display_buffer_size * 3; @@ -325,7 +306,7 @@ static int calculate_spi_max_transfer_size(const int display_buffer_size) #else retval = display_buffer_size * 2; #endif - + return retval; } diff --git a/lvgl_spi_conf.h b/lvgl_spi_conf.h index 7a333fe..1abf623 100644 --- a/lvgl_spi_conf.h +++ b/lvgl_spi_conf.h @@ -112,7 +112,11 @@ extern "C" { * If the user sets the same MOSI and CLK pins for both display and indev * controllers then we can assume the user is using the same SPI bus * If so verify the user specified the same SPI bus for both */ -#if !defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X) +#if defined (CONFIG_LV_TOUCH_CONTROLLER_SPI2_HOST) +#define TOUCH_SPI_HOST SPI2_HOST +#elif defined (CONFIG_LV_TOUCH_CONTROLLER_SPI3_HOST) +#define TOUCH_SPI_HOST SPI3_HOST +#endif #if defined (CONFIG_LV_TFT_DISPLAY_PROTOCOL_SPI) && \ (CONFIG_LV_TFT_DISPLAY_PROTOCOL_SPI == 1) && \ @@ -170,7 +174,6 @@ extern "C" { #else #define SPI_TFT_SPI_MODE (0U) #endif -#endif /* Touch driver */ #if (CONFIG_LV_TOUCH_CONTROLLER == TOUCH_CONTROLLER_STMPE610) diff --git a/lvgl_tft/Kconfig b/lvgl_tft/Kconfig index 80922ac..78c8534 100644 --- a/lvgl_tft/Kconfig +++ b/lvgl_tft/Kconfig @@ -469,8 +469,9 @@ menu "LVGL TFT Display controller" choice prompt "TFT SPI Bus." if LV_TFT_DISPLAY_PROTOCOL_SPI - default LV_TFT_DISPLAY_SPI2_HOST if LV_PREDEFINED_DISPLAY_TTGO - default LV_TFT_DISPLAY_SPI3_HOST if !LV_PREDEFINED_DISPLAY_TTGO + default LV_TFT_DISPLAY_SPI2_HOST + help + Select the SPI Bus the TFT Display is attached to. config LV_TFT_DISPLAY_SPI2_HOST bool "SPI2_HOST"