17eb416ef8
* [lvgl_helpers] Cleanup and misc code cleanup Checks for SPI_HOST_MAX symbol before using it. Rename lvgl_driver_init to lvgl_interface_init because it now only initialize the interface bus for display drivers, we still need to remove the indev drivers from here. Use types defined in spi_types.h for spi host (spi_host_device_t) and spi dma channels (spi_dma_chan_t). Also add a couple of symbols to avoid using magic numbers * [lvgl_helpers] Reduce usage of if defined in lvgl_interface_init * [lvgl_helpers] Fix spi dma channel for ESP-IDF versions <= 4.2 * [examples] Update hello_world to call lvgl_interface_init * Add lvgl_get_display_buffer_size helper This helper will allow us to get the calculated display buffer size instead of using a global symbol. * Implement lvgl_get_display_buffer_size This API will be used to get the calculation of display buffer size. * Delete DISP_BUF_SIZE symbols The same functionality is handled by lvgl_get_display_buffer_size * Move SPI max transfer size calculation to helper Use calculate_spi_max_transfer_size to calculate the SPI max transfer size for the SPI master configuration * Remove SPI_BUS_MAX_TRANSFER_SZ definition Same functionality is now handled in calculate_spi_max_transfer_size * Update display buffer size calculation Use lvgl_get_display_buffer_size helper instead of DISP_BUF_SIZE symbol * Update example to LVGL v8 Add comments about changes from: - LVGL v7 to LVGL v8 - Configuration helpers and display drivers * Update lvgl_helpers.c * Update sh1107 driver * Update EVE driver Check for symbols used in previous implementations before trying to use them and add a fallback temporary implementation when not found. The falback implementation isn't tested with hardware. Symbols: - DISP_BUF_SIZE - SPI_TRANSFER_SIZE * Update uc8151d driver * Update jd79653a driver * Update ra8875 driver * Update il3820.h Check for LV_HOR_RES_MAX and LV_VER_RES_MAX before trying to use them * Update lvgl_helpers.c Check for ESP-IDF version before trying to use spi_dma_chan_t type
179 lines
4.9 KiB
C
179 lines
4.9 KiB
C
/**
|
|
* @file lvgl_spi_conf.h
|
|
*
|
|
*/
|
|
|
|
#ifndef LVGL_SPI_CONF_H
|
|
#define LVGL_SPI_CONF_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*********************
|
|
* INCLUDES
|
|
*********************/
|
|
|
|
/*********************
|
|
* DEFINES
|
|
*********************/
|
|
// DISPLAY PINS
|
|
#define DISP_SPI_MOSI CONFIG_LV_DISP_SPI_MOSI
|
|
#if defined (CONFIG_LV_DISPLAY_USE_SPI_MISO)
|
|
#define DISP_SPI_MISO CONFIG_LV_DISP_SPI_MISO
|
|
#define DISP_SPI_INPUT_DELAY_NS CONFIG_LV_DISP_SPI_INPUT_DELAY_NS
|
|
#else
|
|
#define DISP_SPI_MISO (-1)
|
|
#define DISP_SPI_INPUT_DELAY_NS (0)
|
|
#endif
|
|
#if defined(CONFIG_LV_DISP_SPI_IO2)
|
|
#define DISP_SPI_IO2 CONFIG_LV_DISP_SPI_IO2
|
|
#else
|
|
#define DISP_SPI_IO2 (-1)
|
|
#endif
|
|
#if defined(CONFIG_LV_DISP_SPI_IO3)
|
|
#define DISP_SPI_IO3 CONFIG_LV_DISP_SPI_IO3
|
|
#else
|
|
#define DISP_SPI_IO3 (-1)
|
|
#endif
|
|
#define DISP_SPI_CLK CONFIG_LV_DISP_SPI_CLK
|
|
#if defined (CONFIG_LV_DISPLAY_USE_SPI_CS)
|
|
#define DISP_SPI_CS CONFIG_LV_DISP_SPI_CS
|
|
#else
|
|
#define DISP_SPI_CS (-1)
|
|
#endif
|
|
|
|
/* Define TOUCHPAD PINS when selecting a touch controller */
|
|
#if !defined (CONFIG_LV_TOUCH_CONTROLLER_NONE)
|
|
|
|
/* Handle FT81X special case */
|
|
#if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X) && \
|
|
defined (CONFIG_LV_TOUCH_CONTROLLER_FT81X)
|
|
|
|
#define TP_SPI_MOSI CONFIG_LV_DISP_SPI_MOSI
|
|
#define TP_SPI_MISO CONFIG_LV_DISP_SPI_MISO
|
|
#define TP_SPI_CLK CONFIG_LV_DISP_SPI_CLK
|
|
#define TP_SPI_CS CONFIG_LV_DISP_SPI_CS
|
|
#else
|
|
#define TP_SPI_MOSI CONFIG_LV_TOUCH_SPI_MOSI
|
|
#define TP_SPI_MISO CONFIG_LV_TOUCH_SPI_MISO
|
|
#define TP_SPI_CLK CONFIG_LV_TOUCH_SPI_CLK
|
|
#define TP_SPI_CS CONFIG_LV_TOUCH_SPI_CS
|
|
#endif
|
|
#endif
|
|
|
|
#define ENABLE_TOUCH_INPUT CONFIG_LV_ENABLE_TOUCH
|
|
|
|
#if defined (CONFIG_LV_TFT_DISPLAY_SPI2_HOST)
|
|
#define TFT_SPI_HOST SPI2_HOST
|
|
#elif defined (CONFIG_LV_TFT_DISPLAY_SPI3_HOST)
|
|
#define TFT_SPI_HOST SPI3_HOST
|
|
#endif
|
|
|
|
#if defined (CONFIG_LV_TFT_DISPLAY_SPI_HALF_DUPLEX)
|
|
#define DISP_SPI_HALF_DUPLEX
|
|
#else
|
|
#define DISP_SPI_FULL_DUPLEX
|
|
#endif
|
|
|
|
#if defined (CONFIG_LV_TFT_DISPLAY_SPI_TRANS_MODE_DIO)
|
|
#define DISP_SPI_TRANS_MODE_DIO
|
|
#elif defined (CONFIG_LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO)
|
|
#define DISP_SPI_TRANS_MODE_QIO
|
|
#else
|
|
#define DISP_SPI_TRANS_MODE_SIO
|
|
#endif
|
|
|
|
#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
|
|
|
|
/* Handle the FT81X Special case */
|
|
#if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X)
|
|
|
|
#if defined (CONFIG_LV_TOUCH_CONTROLLER_FT81X)
|
|
#define SHARED_SPI_BUS
|
|
#else
|
|
/* Empty */
|
|
#endif
|
|
|
|
#else
|
|
// Detect the use of a shared SPI Bus and verify the user specified the same SPI bus for both touch and tft
|
|
#if defined (CONFIG_LV_TOUCH_DRIVER_PROTOCOL_SPI) && TP_SPI_MOSI == DISP_SPI_MOSI && TP_SPI_CLK == DISP_SPI_CLK
|
|
#if TFT_SPI_HOST != TOUCH_SPI_HOST
|
|
#error You must specify the same SPI host (SPIx_HOST) for both display and touch driver
|
|
#endif
|
|
|
|
#define SHARED_SPI_BUS
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/**********************
|
|
* TYPEDEFS
|
|
**********************/
|
|
#if defined (CONFIG_LV_TFT_USE_CUSTOM_SPI_CLK_DIVIDER)
|
|
#define SPI_TFT_CLOCK_SPEED_HZ ((80 * 1000 * 1000) / CONFIG_LV_TFT_CUSTOM_SPI_CLK_DIVIDER)
|
|
#else
|
|
#if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789)
|
|
#define SPI_TFT_CLOCK_SPEED_HZ (20*1000*1000)
|
|
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S)
|
|
#define SPI_TFT_CLOCK_SPEED_HZ (40*1000*1000)
|
|
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357)
|
|
#define SPI_TFT_CLOCK_SPEED_HZ (26*1000*1000)
|
|
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_SH1107)
|
|
#define SPI_TFT_CLOCK_SPEED_HZ (8*1000*1000)
|
|
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481)
|
|
#define SPI_TFT_CLOCK_SPEED_HZ (16*1000*1000)
|
|
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9486)
|
|
#define SPI_TFT_CLOCK_SPEED_HZ (20*1000*1000)
|
|
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9488)
|
|
#define SPI_TFT_CLOCK_SPEED_HZ (40*1000*1000)
|
|
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9341)
|
|
#define SPI_TFT_CLOCK_SPEED_HZ (40*1000*1000)
|
|
#elif defined(CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9163C)
|
|
#define SPI_TFT_CLOCK_SPEED_HZ (40 * 1000 * 1000)
|
|
#elif defined(CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X)
|
|
#define SPI_TFT_CLOCK_SPEED_HZ (32*1000*1000)
|
|
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_PCD8544)
|
|
#define SPI_TFT_CLOCK_SPEED_HZ (4*1000*1000)
|
|
#else
|
|
#define SPI_TFT_CLOCK_SPEED_HZ (40*1000*1000)
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
#if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789)
|
|
#define SPI_TFT_SPI_MODE (2)
|
|
#else
|
|
#define SPI_TFT_SPI_MODE (0)
|
|
#endif
|
|
|
|
/* Touch driver */
|
|
#if (CONFIG_LV_TOUCH_CONTROLLER == TOUCH_CONTROLLER_STMPE610)
|
|
#define SPI_TOUCH_CLOCK_SPEED_HZ (1*1000*1000)
|
|
#define SPI_TOUCH_SPI_MODE (1)
|
|
#else
|
|
#define SPI_TOUCH_CLOCK_SPEED_HZ (2*1000*1000)
|
|
#define SPI_TOUCH_SPI_MODE (0)
|
|
#endif
|
|
|
|
/**********************
|
|
* GLOBAL PROTOTYPES
|
|
**********************/
|
|
|
|
|
|
/**********************
|
|
* MACROS
|
|
**********************/
|
|
|
|
|
|
#ifdef __cplusplus
|
|
} /* extern "C" */
|
|
#endif
|
|
|
|
#endif /*LVGL_SPI_CONF_H*/
|