feat(lcd): Add new version LCD implementation to adapt new I2C APIs

This commit is contained in:
Cao Sen Miao
2023-08-03 12:31:36 +08:00
parent 4ef94fc0dc
commit b6cbeeae01
15 changed files with 463 additions and 19 deletions

View File

@@ -10,13 +10,15 @@
#include "esp_lcd_types.h"
#include "soc/soc_caps.h"
#include "hal/lcd_types.h"
#include "hal/i2c_types.h"
#include "driver/i2c_types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void *esp_lcd_spi_bus_handle_t; /*!< Type of LCD SPI bus handle */
typedef void *esp_lcd_i2c_bus_handle_t; /*!< Type of LCD I2C bus handle */
typedef uint32_t esp_lcd_i2c_bus_handle_t; /*!< Type of LCD I2C bus handle */
typedef struct esp_lcd_i80_bus_t *esp_lcd_i80_bus_handle_t; /*!< Type of LCD intel 8080 bus handle */
/**
@@ -171,10 +173,43 @@ typedef struct {
unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */
unsigned int disable_control_phase: 1; /*!< If this flag is enabled, the control phase isn't used */
} flags; /*!< Extra flags to fine-tune the I2C device */
uint32_t scl_speed_hz; /*!< I2C LCD SCL frequency (hz) */
} esp_lcd_panel_io_i2c_config_t;
/**
* @brief Create LCD panel IO handle, for I2C interface
* @brief Create LCD panel IO handle, for I2C interface in legacy implementation
*
* @param[in] bus I2C bus handle, (in uint32_t)
* @param[in] io_config IO configuration, for I2C interface
* @param[out] ret_io Returned IO handle
*
* @note Please don't call this function in your project directly. Please call `esp_lcd_new_panel_to_i2c` instead.
*
* @return
* - ESP_ERR_INVALID_ARG if parameter is invalid
* - ESP_ERR_NO_MEM if out of memory
* - ESP_OK on success
*/
esp_err_t esp_lcd_new_panel_io_i2c_v1(uint32_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io);
/**
* @brief Create LCD panel IO handle, for I2C interface in new implementation
*
* @param[in] bus I2C bus handle, (in i2c_master_dev_handle_t)
* @param[in] io_config IO configuration, for I2C interface
* @param[out] ret_io Returned IO handle
*
* @note Please don't call this function in your project directly. Please call `esp_lcd_new_panel_to_i2c` instead.
*
* @return
* - ESP_ERR_INVALID_ARG if parameter is invalid
* - ESP_ERR_NO_MEM if out of memory
* - ESP_OK on success
*/
esp_err_t esp_lcd_new_panel_io_i2c_v2(i2c_master_bus_handle_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io);
/**
* @brief Create LCD panel IO handle
*
* @param[in] bus I2C bus handle
* @param[in] io_config IO configuration, for I2C interface
@@ -184,7 +219,9 @@ typedef struct {
* - ESP_ERR_NO_MEM if out of memory
* - ESP_OK on success
*/
esp_err_t esp_lcd_new_panel_io_i2c(esp_lcd_i2c_bus_handle_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io);
#define esp_lcd_new_panel_io_i2c(bus, io_config, ret_io) _Generic((bus), \
i2c_master_bus_handle_t : esp_lcd_new_panel_io_i2c_v2, \
default : esp_lcd_new_panel_io_i2c_v1) (bus, io_config, ret_io) \
#if SOC_LCD_I80_SUPPORTED
/**