From 5ae6f626fcd3d1a7a0c9a89c35fbd2dacb7d471f Mon Sep 17 00:00:00 2001 From: "C.S.M" Date: Wed, 11 Jun 2025 15:48:59 +0800 Subject: [PATCH] refactor(lcd_i2c): Remove legacy driver version used in lcd driver --- components/esp_lcd/CMakeLists.txt | 4 +- ...nel_io_i2c_v2.c => esp_lcd_panel_io_i2c.c} | 2 +- .../esp_lcd/i2c/esp_lcd_panel_io_i2c_v1.c | 212 ------------------ components/esp_lcd/include/esp_lcd_io_i2c.h | 70 +----- .../esp_lcd/test_apps/.build-test-rules.yml | 12 - .../test_apps/i2c_lcd_legacy/CMakeLists.txt | 9 - .../test_apps/i2c_lcd_legacy/README.md | 4 - .../i2c_lcd_legacy/main/CMakeLists.txt | 8 - .../i2c_lcd_legacy/main/test_app_main.c | 51 ----- .../i2c_lcd_legacy/main/test_i2c_board.h | 26 --- .../main/test_i2c_lcd_legacy_panel.c | 70 ------ .../i2c_lcd_legacy/pytest_i2c_lcd_legacy.py | 18 -- .../i2c_lcd_legacy/sdkconfig.ci.release | 3 - .../i2c_lcd_legacy/sdkconfig.defaults | 5 - .../release-6.x/6.0/peripherals.rst | 1 + .../release-6.x/6.0/peripherals.rst | 1 + 16 files changed, 6 insertions(+), 490 deletions(-) rename components/esp_lcd/i2c/{esp_lcd_panel_io_i2c_v2.c => esp_lcd_panel_io_i2c.c} (98%) delete mode 100644 components/esp_lcd/i2c/esp_lcd_panel_io_i2c_v1.c delete mode 100644 components/esp_lcd/test_apps/i2c_lcd_legacy/CMakeLists.txt delete mode 100644 components/esp_lcd/test_apps/i2c_lcd_legacy/README.md delete mode 100644 components/esp_lcd/test_apps/i2c_lcd_legacy/main/CMakeLists.txt delete mode 100644 components/esp_lcd/test_apps/i2c_lcd_legacy/main/test_app_main.c delete mode 100644 components/esp_lcd/test_apps/i2c_lcd_legacy/main/test_i2c_board.h delete mode 100644 components/esp_lcd/test_apps/i2c_lcd_legacy/main/test_i2c_lcd_legacy_panel.c delete mode 100644 components/esp_lcd/test_apps/i2c_lcd_legacy/pytest_i2c_lcd_legacy.py delete mode 100644 components/esp_lcd/test_apps/i2c_lcd_legacy/sdkconfig.ci.release delete mode 100644 components/esp_lcd/test_apps/i2c_lcd_legacy/sdkconfig.defaults diff --git a/components/esp_lcd/CMakeLists.txt b/components/esp_lcd/CMakeLists.txt index 1e93505077..9f91680891 100644 --- a/components/esp_lcd/CMakeLists.txt +++ b/components/esp_lcd/CMakeLists.txt @@ -12,14 +12,14 @@ set(srcs "src/esp_lcd_common.c" "src/esp_lcd_panel_ops.c") set(includes "include" "interface") set(priv_requires "esp_mm" "esp_psram" "esp_pm" "esp_driver_i2s") -set(public_requires "driver" "esp_driver_gpio" "esp_driver_i2c" "esp_driver_spi") +set(public_requires "esp_driver_gpio" "esp_driver_i2c" "esp_driver_spi" "esp_driver_parlio") if(CONFIG_SOC_DMA2D_SUPPORTED) list(APPEND srcs "src/esp_async_fbcpy.c") endif() if(CONFIG_SOC_I2C_SUPPORTED) - list(APPEND srcs "i2c/esp_lcd_panel_io_i2c_v1.c" "i2c/esp_lcd_panel_io_i2c_v2.c") + list(APPEND srcs "i2c/esp_lcd_panel_io_i2c.c") endif() if(CONFIG_SOC_GPSPI_SUPPORTED) diff --git a/components/esp_lcd/i2c/esp_lcd_panel_io_i2c_v2.c b/components/esp_lcd/i2c/esp_lcd_panel_io_i2c.c similarity index 98% rename from components/esp_lcd/i2c/esp_lcd_panel_io_i2c_v2.c rename to components/esp_lcd/i2c/esp_lcd_panel_io_i2c.c index 5303a13300..2757df5fc1 100644 --- a/components/esp_lcd/i2c/esp_lcd_panel_io_i2c_v2.c +++ b/components/esp_lcd/i2c/esp_lcd_panel_io_i2c.c @@ -48,7 +48,7 @@ typedef struct { void *user_ctx; // User's private data, passed directly to callback on_color_trans_done() } lcd_panel_io_i2c_t; -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) +esp_err_t esp_lcd_new_panel_io_i2c(i2c_master_bus_handle_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io) { #if CONFIG_LCD_ENABLE_DEBUG_LOG esp_log_level_set(TAG, ESP_LOG_DEBUG); diff --git a/components/esp_lcd/i2c/esp_lcd_panel_io_i2c_v1.c b/components/esp_lcd/i2c/esp_lcd_panel_io_i2c_v1.c deleted file mode 100644 index b50814dd67..0000000000 --- a/components/esp_lcd/i2c/esp_lcd_panel_io_i2c_v1.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include "sdkconfig.h" -#if CONFIG_LCD_ENABLE_DEBUG_LOG -// The local log level must be defined before including esp_log.h -// Set the maximum log level for this source file -#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG -#endif -#include "esp_lcd_panel_io_interface.h" -#include "esp_lcd_panel_io.h" -#include "driver/i2c.h" -#include "driver/gpio.h" -#include "esp_log.h" -#include "esp_check.h" -#include "esp_compiler.h" - -static const char *TAG = "lcd_panel.io.i2c"; - -#define CMD_HANDLER_BUFFER_SIZE I2C_LINK_RECOMMENDED_SIZE(2) // only 2 operations will be queued in the handler ATTOW -#define BYTESHIFT(VAR, IDX) (((VAR) >> ((IDX) * 8)) & 0xFF) - -static esp_err_t panel_io_i2c_del(esp_lcd_panel_io_t *io); -static esp_err_t panel_io_i2c_rx_param(esp_lcd_panel_io_t *io, int lcd_cmd, void *param, size_t param_size); -static esp_err_t panel_io_i2c_tx_param(esp_lcd_panel_io_t *io, int lcd_cmd, const void *param, size_t param_size); -static esp_err_t panel_io_i2c_tx_color(esp_lcd_panel_io_t *io, int lcd_cmd, const void *color, size_t color_size); -static esp_err_t panel_io_i2c_register_event_callbacks(esp_lcd_panel_io_handle_t io, const esp_lcd_panel_io_callbacks_t *cbs, void *user_ctx); - -typedef struct { - esp_lcd_panel_io_t base; // Base class of generic lcd panel io - uint32_t i2c_bus_id; // I2C bus id, indicating which I2C port - uint32_t dev_addr; // Device address - int lcd_cmd_bits; // Bit width of LCD command - int lcd_param_bits; // Bit width of LCD parameter - bool control_phase_enabled; // Is control phase enabled - uint32_t control_phase_cmd; // control byte when transferring command - uint32_t control_phase_data; // control byte when transferring data - esp_lcd_panel_io_color_trans_done_cb_t on_color_trans_done; // User register's callback, invoked when color data trans done - void *user_ctx; // User's private data, passed directly to callback on_color_trans_done() - uint8_t cmdlink_buffer[]; // pre-alloc I2C command link buffer, to be reused in all transactions -} lcd_panel_io_i2c_t; - -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) -{ - // leak detection of i2c_panel_io because saving i2c_panel_io->base address - ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-malloc-leak") -#if CONFIG_LCD_ENABLE_DEBUG_LOG - esp_log_level_set(TAG, ESP_LOG_DEBUG); -#endif - esp_err_t ret = ESP_OK; - lcd_panel_io_i2c_t *i2c_panel_io = NULL; - ESP_GOTO_ON_FALSE(io_config && ret_io, ESP_ERR_INVALID_ARG, err, TAG, "invalid argument"); - ESP_GOTO_ON_FALSE(io_config->control_phase_bytes * 8 > io_config->dc_bit_offset, ESP_ERR_INVALID_ARG, err, TAG, "D/C bit exceeds control bytes"); - ESP_GOTO_ON_FALSE(io_config->scl_speed_hz == 0, ESP_ERR_INVALID_ARG, err, TAG, "scl_speed_hz is not need to set in legacy i2c_lcd driver"); - i2c_panel_io = calloc(1, sizeof(lcd_panel_io_i2c_t) + CMD_HANDLER_BUFFER_SIZE); // expand zero-length array cmdlink_buffer - ESP_GOTO_ON_FALSE(i2c_panel_io, ESP_ERR_NO_MEM, err, TAG, "no mem for i2c panel io"); - - i2c_panel_io->i2c_bus_id = bus; - i2c_panel_io->lcd_cmd_bits = io_config->lcd_cmd_bits; - i2c_panel_io->lcd_param_bits = io_config->lcd_param_bits; - i2c_panel_io->on_color_trans_done = io_config->on_color_trans_done; - i2c_panel_io->user_ctx = io_config->user_ctx; - i2c_panel_io->control_phase_enabled = (!io_config->flags.disable_control_phase); - i2c_panel_io->control_phase_data = (!io_config->flags.dc_low_on_data) << (io_config->dc_bit_offset); - i2c_panel_io->control_phase_cmd = (io_config->flags.dc_low_on_data) << (io_config->dc_bit_offset); - i2c_panel_io->dev_addr = io_config->dev_addr; - i2c_panel_io->base.del = panel_io_i2c_del; - i2c_panel_io->base.rx_param = panel_io_i2c_rx_param; - i2c_panel_io->base.tx_param = panel_io_i2c_tx_param; - i2c_panel_io->base.tx_color = panel_io_i2c_tx_color; - i2c_panel_io->base.register_event_callbacks = panel_io_i2c_register_event_callbacks; - *ret_io = &(i2c_panel_io->base); - ESP_LOGD(TAG, "new i2c lcd panel io @%p", i2c_panel_io); - - return ESP_OK; -err: - return ret; - ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-malloc-leak") -} - -static esp_err_t panel_io_i2c_del(esp_lcd_panel_io_t *io) -{ - esp_err_t ret = ESP_OK; - lcd_panel_io_i2c_t *i2c_panel_io = __containerof(io, lcd_panel_io_i2c_t, base); - - ESP_LOGD(TAG, "del lcd panel i2c @%p", i2c_panel_io); - free(i2c_panel_io); - return ret; -} - -static esp_err_t panel_io_i2c_register_event_callbacks(esp_lcd_panel_io_handle_t io, const esp_lcd_panel_io_callbacks_t *cbs, void *user_ctx) -{ - lcd_panel_io_i2c_t *i2c_panel_io = __containerof(io, lcd_panel_io_i2c_t, base); - - if (i2c_panel_io->on_color_trans_done != NULL) { - ESP_LOGW(TAG, "Callback on_color_trans_done was already set and now it was overwritten!"); - } - - i2c_panel_io->on_color_trans_done = cbs->on_color_trans_done; - i2c_panel_io->user_ctx = user_ctx; - - return ESP_OK; -} - -static esp_err_t panel_io_i2c_rx_buffer(esp_lcd_panel_io_t *io, int lcd_cmd, void *buffer, size_t buffer_size) -{ - esp_err_t ret = ESP_OK; - lcd_panel_io_i2c_t *i2c_panel_io = __containerof(io, lcd_panel_io_i2c_t, base); - bool send_param = (lcd_cmd >= 0); - - i2c_cmd_handle_t cmd_link = i2c_cmd_link_create_static(i2c_panel_io->cmdlink_buffer, CMD_HANDLER_BUFFER_SIZE); - ESP_GOTO_ON_FALSE(cmd_link, ESP_ERR_NO_MEM, err, TAG, "no mem for i2c cmd link"); - ESP_GOTO_ON_ERROR(i2c_master_start(cmd_link), err, TAG, "issue start failed"); // start phase - ESP_GOTO_ON_ERROR(i2c_master_write_byte(cmd_link, (i2c_panel_io->dev_addr << 1) | I2C_MASTER_WRITE, true), err, TAG, "write address failed"); // address phase - if (send_param) { - if (i2c_panel_io->control_phase_enabled) { - ESP_GOTO_ON_ERROR(i2c_master_write_byte(cmd_link, i2c_panel_io->control_phase_cmd, true), - err, TAG, "write control phase failed"); // control phase - } - uint8_t cmds[4] = {BYTESHIFT(lcd_cmd, 3), BYTESHIFT(lcd_cmd, 2), BYTESHIFT(lcd_cmd, 1), BYTESHIFT(lcd_cmd, 0)}; - size_t cmds_size = i2c_panel_io->lcd_cmd_bits / 8; - if (cmds_size > 0 && cmds_size <= sizeof(cmds)) { - ESP_GOTO_ON_ERROR(i2c_master_write(cmd_link, cmds + (sizeof(cmds) - cmds_size), cmds_size, true), err, TAG, "write LCD cmd failed"); - } - } - - if (buffer) { - ESP_GOTO_ON_ERROR(i2c_master_start(cmd_link), err, TAG, "issue start failed"); // start phase - ESP_GOTO_ON_ERROR(i2c_master_write_byte(cmd_link, (i2c_panel_io->dev_addr << 1) | I2C_MASTER_READ, true), err, TAG, "write address failed"); // address phase - ESP_GOTO_ON_ERROR(i2c_master_read(cmd_link, buffer, buffer_size, I2C_MASTER_LAST_NACK), err, TAG, "read data failed"); - } - - ESP_GOTO_ON_ERROR(i2c_master_stop(cmd_link), err, TAG, "issue stop failed"); // stop phase - ESP_GOTO_ON_ERROR(i2c_master_cmd_begin(i2c_panel_io->i2c_bus_id, cmd_link, portMAX_DELAY), err, TAG, "i2c transaction failed"); - - i2c_cmd_link_delete_static(cmd_link); - - return ESP_OK; -err: - if (cmd_link) { - i2c_cmd_link_delete_static(cmd_link); - } - return ret; -} - -static esp_err_t panel_io_i2c_tx_buffer(esp_lcd_panel_io_t *io, int lcd_cmd, const void *buffer, size_t buffer_size, bool is_param) -{ - esp_err_t ret = ESP_OK; - lcd_panel_io_i2c_t *i2c_panel_io = __containerof(io, lcd_panel_io_i2c_t, base); - bool send_param = (lcd_cmd >= 0); - - i2c_cmd_handle_t cmd_link = i2c_cmd_link_create_static(i2c_panel_io->cmdlink_buffer, CMD_HANDLER_BUFFER_SIZE); - ESP_GOTO_ON_FALSE(cmd_link, ESP_ERR_NO_MEM, err, TAG, "no mem for i2c cmd link"); - ESP_GOTO_ON_ERROR(i2c_master_start(cmd_link), err, TAG, "issue start failed"); // start phase - ESP_GOTO_ON_ERROR(i2c_master_write_byte(cmd_link, (i2c_panel_io->dev_addr << 1) | I2C_MASTER_WRITE, true), err, TAG, "write address failed"); // address phase - if (i2c_panel_io->control_phase_enabled) { - ESP_GOTO_ON_ERROR(i2c_master_write_byte(cmd_link, is_param ? i2c_panel_io->control_phase_cmd : i2c_panel_io->control_phase_data, true), - err, TAG, "write control phase failed"); // control phase - } - - // some displays don't want any additional commands on data transfers - if (send_param) { - uint8_t cmds[4] = {BYTESHIFT(lcd_cmd, 3), BYTESHIFT(lcd_cmd, 2), BYTESHIFT(lcd_cmd, 1), BYTESHIFT(lcd_cmd, 0)}; - size_t cmds_size = i2c_panel_io->lcd_cmd_bits / 8; - if (cmds_size > 0 && cmds_size <= sizeof(cmds)) { - ESP_GOTO_ON_ERROR(i2c_master_write(cmd_link, cmds + (sizeof(cmds) - cmds_size), cmds_size, true), err, TAG, "write LCD cmd failed"); - } - } - - if (buffer) { - ESP_GOTO_ON_ERROR(i2c_master_write(cmd_link, buffer, buffer_size, true), err, TAG, "write data failed"); - } - - ESP_GOTO_ON_ERROR(i2c_master_stop(cmd_link), err, TAG, "issue stop failed"); // stop phase - ESP_GOTO_ON_ERROR(i2c_master_cmd_begin(i2c_panel_io->i2c_bus_id, cmd_link, portMAX_DELAY), err, TAG, "i2c transaction failed"); - i2c_cmd_link_delete_static(cmd_link); - - if (!is_param) { - // trans done callback - if (i2c_panel_io->on_color_trans_done) { - i2c_panel_io->on_color_trans_done(&(i2c_panel_io->base), NULL, i2c_panel_io->user_ctx); - } - } - - return ESP_OK; -err: - if (cmd_link) { - i2c_cmd_link_delete_static(cmd_link); - } - return ret; -} - -static esp_err_t panel_io_i2c_rx_param(esp_lcd_panel_io_t *io, int lcd_cmd, void *param, size_t param_size) -{ - return panel_io_i2c_rx_buffer(io, lcd_cmd, param, param_size); -} - -static esp_err_t panel_io_i2c_tx_param(esp_lcd_panel_io_t *io, int lcd_cmd, const void *param, size_t param_size) -{ - return panel_io_i2c_tx_buffer(io, lcd_cmd, param, param_size, true); -} - -static esp_err_t panel_io_i2c_tx_color(esp_lcd_panel_io_t *io, int lcd_cmd, const void *color, size_t color_size) -{ - return panel_io_i2c_tx_buffer(io, lcd_cmd, color, color_size, false); -} diff --git a/components/esp_lcd/include/esp_lcd_io_i2c.h b/components/esp_lcd/include/esp_lcd_io_i2c.h index ec18378a8e..4a0c2bac0d 100644 --- a/components/esp_lcd/include/esp_lcd_io_i2c.h +++ b/components/esp_lcd/include/esp_lcd_io_i2c.h @@ -14,8 +14,6 @@ extern "C" { #endif -typedef uint32_t esp_lcd_i2c_bus_handle_t; /*!< Type of LCD I2C bus handle */ - /** * @brief Panel IO configuration structure, for I2C interface * @@ -35,22 +33,6 @@ typedef struct { } flags; /*!< Extra flags to fine-tune the I2C device */ } esp_lcd_panel_io_i2c_config_t; -/** - * @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 * @@ -65,58 +47,8 @@ esp_err_t esp_lcd_new_panel_io_i2c_v1(uint32_t bus, const esp_lcd_panel_io_i2c_c * - 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); +esp_err_t esp_lcd_new_panel_io_i2c(i2c_master_bus_handle_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io); #ifdef __cplusplus } #endif - -#ifdef __cplusplus -/** - * @brief Create LCD panel IO handle - * - * @param[in] bus I2C bus ID, indicates which I2C port to use - * @param[in] io_config IO configuration, for I2C interface - * @param[out] ret_io Returned IO handle - * @return - * - ESP_ERR_INVALID_ARG if parameter is invalid - * - ESP_ERR_NO_MEM if out of memory - * - ESP_OK on success - */ -static inline esp_err_t esp_lcd_new_panel_io_i2c(uint32_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io) -{ - return esp_lcd_new_panel_io_i2c_v1(bus, io_config, ret_io); -} - -/** - * @brief Create LCD panel IO handle - * - * @param[in] bus I2C bus handle, returned from `i2c_new_master_bus` - * @param[in] io_config IO configuration, for I2C interface - * @param[out] ret_io Returned IO handle - * @return - * - ESP_ERR_INVALID_ARG if parameter is invalid - * - ESP_ERR_NO_MEM if out of memory - * - ESP_OK on success - */ -static inline esp_err_t esp_lcd_new_panel_io_i2c(i2c_master_bus_handle_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io) -{ - return esp_lcd_new_panel_io_i2c_v2(bus, io_config, ret_io); -} -#else -/** - * @brief Create LCD panel IO handle - * - * @param[in] bus I2C bus handle - * @param[in] io_config IO configuration, for I2C interface - * @param[out] ret_io Returned IO handle - * @return - * - ESP_ERR_INVALID_ARG if parameter is invalid - * - ESP_ERR_NO_MEM if out of memory - * - ESP_OK on success - */ -#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) - -#endif diff --git a/components/esp_lcd/test_apps/.build-test-rules.yml b/components/esp_lcd/test_apps/.build-test-rules.yml index 1c416fefd2..4ee2e8469a 100644 --- a/components/esp_lcd/test_apps/.build-test-rules.yml +++ b/components/esp_lcd/test_apps/.build-test-rules.yml @@ -11,18 +11,6 @@ components/esp_lcd/test_apps/i2c_lcd: temporary: true reason: insufficient runners -components/esp_lcd/test_apps/i2c_lcd_legacy: - disable: - - if: SOC_I2C_SUPPORTED != 1 - depends_components: - - esp_lcd - depends_filepatterns: - - components/driver/i2c/**/* - disable_test: - - if: IDF_TARGET not in ["esp32c3"] - temporary: true - reason: insufficient runners - components/esp_lcd/test_apps/i80_lcd: depends_components: - esp_lcd diff --git a/components/esp_lcd/test_apps/i2c_lcd_legacy/CMakeLists.txt b/components/esp_lcd/test_apps/i2c_lcd_legacy/CMakeLists.txt deleted file mode 100644 index 380e7dffe9..0000000000 --- a/components/esp_lcd/test_apps/i2c_lcd_legacy/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# This is the project CMakeLists.txt file for the test subproject -cmake_minimum_required(VERSION 3.22) - -include($ENV{IDF_PATH}/tools/cmake/project.cmake) - -# "Trim" the build. Include the minimal set of components, main, and anything it depends on. -set(COMPONENTS main) - -project(legacy_i2c_lcd_panel_test) diff --git a/components/esp_lcd/test_apps/i2c_lcd_legacy/README.md b/components/esp_lcd/test_apps/i2c_lcd_legacy/README.md deleted file mode 100644 index 434a3d2264..0000000000 --- a/components/esp_lcd/test_apps/i2c_lcd_legacy/README.md +++ /dev/null @@ -1,4 +0,0 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-H21 | ESP32-H4 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | --------- | -------- | -------- | -------- | -------- | - -This test app is used to test LCDs with I2C interface. diff --git a/components/esp_lcd/test_apps/i2c_lcd_legacy/main/CMakeLists.txt b/components/esp_lcd/test_apps/i2c_lcd_legacy/main/CMakeLists.txt deleted file mode 100644 index a168fe90a0..0000000000 --- a/components/esp_lcd/test_apps/i2c_lcd_legacy/main/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(srcs "test_app_main.c" - "test_i2c_lcd_legacy_panel.c") - -# In order for the cases defined by `TEST_CASE` to be linked into the final elf, -# the component can be registered as WHOLE_ARCHIVE -idf_component_register(SRCS ${srcs} - PRIV_REQUIRES unity driver esp_lcd - WHOLE_ARCHIVE) diff --git a/components/esp_lcd/test_apps/i2c_lcd_legacy/main/test_app_main.c b/components/esp_lcd/test_apps/i2c_lcd_legacy/main/test_app_main.c deleted file mode 100644 index 826e43ddb5..0000000000 --- a/components/esp_lcd/test_apps/i2c_lcd_legacy/main/test_app_main.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: CC0-1.0 - */ - -#include "unity.h" -#include "unity_test_runner.h" -#include "esp_heap_caps.h" - -// Some resources are lazy allocated in the LCD driver, the threadhold is left for that case -#define TEST_MEMORY_LEAK_THRESHOLD (-300) - -static size_t before_free_8bit; -static size_t before_free_32bit; - -static void check_leak(size_t before_free, size_t after_free, const char *type) -{ - ssize_t delta = after_free - before_free; - printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta); - TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak"); -} - -void setUp(void) -{ - before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT); - before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT); -} - -void tearDown(void) -{ - size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT); - size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT); - check_leak(before_free_8bit, after_free_8bit, "8BIT"); - check_leak(before_free_32bit, after_free_32bit, "32BIT"); -} - -void app_main(void) -{ - // ___ ____ ____ _ ____ ____ _____ _ - // |_ _|___ \ / ___| | | / ___| _ \ |_ _|__ ___| |_ - // | | __) | | | | | | | | | | | |/ _ \/ __| __| - // | | / __/| |___ | |__| |___| |_| | | | __/\__ \ |_ - // |___|_____|\____| |_____\____|____/ |_|\___||___/\__| - printf(" ___ ____ ____ _ ____ ____ _____ _\r\n"); - printf("|_ _|___ \\ / ___| | | / ___| _ \\ |_ _|__ ___| |_\r\n"); - printf(" | | __) | | | | | | | | | | | |/ _ \\/ __| __|\r\n"); - printf(" | | / __/| |___ | |__| |___| |_| | | | __/\\__ \\ |_\r\n"); - printf("|___|_____|\\____| |_____\\____|____/ |_|\\___||___/\\__|\r\n"); - unity_run_menu(); -} diff --git a/components/esp_lcd/test_apps/i2c_lcd_legacy/main/test_i2c_board.h b/components/esp_lcd/test_apps/i2c_lcd_legacy/main/test_i2c_board.h deleted file mode 100644 index f108031ca9..0000000000 --- a/components/esp_lcd/test_apps/i2c_lcd_legacy/main/test_i2c_board.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#define TEST_LCD_H_RES 128 -#define TEST_LCD_V_RES 64 - -#define TEST_I2C_SDA_GPIO 0 -#define TEST_I2C_SCL_GPIO 2 - -#define TEST_I2C_HOST_ID 0 - -#define TEST_I2C_DEV_ADDR 0x3C - -#define TEST_LCD_PIXEL_CLOCK_HZ (400 * 1000) - -#ifdef __cplusplus -} -#endif diff --git a/components/esp_lcd/test_apps/i2c_lcd_legacy/main/test_i2c_lcd_legacy_panel.c b/components/esp_lcd/test_apps/i2c_lcd_legacy/main/test_i2c_lcd_legacy_panel.c deleted file mode 100644 index 4a55b60b25..0000000000 --- a/components/esp_lcd/test_apps/i2c_lcd_legacy/main/test_i2c_lcd_legacy_panel.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#include -#include -#include "unity.h" -#include "driver/i2c.h" -#include "driver/gpio.h" -#include "esp_lcd_panel_io.h" -#include "esp_lcd_panel_vendor.h" -#include "esp_lcd_panel_ops.h" -#include "esp_system.h" -#include "test_i2c_board.h" - -TEST_CASE("lcd_panel_with_i2c_interface legacy_(ssd1306)", "[lcd]") -{ - const uint8_t pattern[][16] = {{ - 0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00, - 0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00 - }, - { - 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81, - 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 - } - }; - - i2c_config_t conf = { - .mode = I2C_MODE_MASTER, - .sda_io_num = TEST_I2C_SDA_GPIO, - .scl_io_num = TEST_I2C_SCL_GPIO, - .sda_pullup_en = GPIO_PULLUP_ENABLE, - .scl_pullup_en = GPIO_PULLUP_ENABLE, - .master.clk_speed = TEST_LCD_PIXEL_CLOCK_HZ, - }; - TEST_ESP_OK(i2c_param_config(TEST_I2C_HOST_ID, &conf)); - TEST_ESP_OK(i2c_driver_install(TEST_I2C_HOST_ID, I2C_MODE_MASTER, 0, 0, 0)); - - esp_lcd_panel_io_handle_t io_handle = NULL; - esp_lcd_panel_io_i2c_config_t io_config = { - .dev_addr = TEST_I2C_DEV_ADDR, - .control_phase_bytes = 1, // According to SSD1306 datasheet - .dc_bit_offset = 6, // According to SSD1306 datasheet - .lcd_cmd_bits = 8, // According to SSD1306 datasheet - .lcd_param_bits = 8, // According to SSD1306 datasheet - }; - TEST_ESP_OK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TEST_I2C_HOST_ID, &io_config, &io_handle)); - - esp_lcd_panel_handle_t panel_handle = NULL; - esp_lcd_panel_dev_config_t panel_config = { - .bits_per_pixel = 1, - .reset_gpio_num = -1, - }; - TEST_ESP_OK(esp_lcd_new_panel_ssd1306(io_handle, &panel_config, &panel_handle)); - TEST_ESP_OK(esp_lcd_panel_reset(panel_handle)); - TEST_ESP_OK(esp_lcd_panel_init(panel_handle)); - // turn on display - TEST_ESP_OK(esp_lcd_panel_disp_on_off(panel_handle, true)); - - for (int i = 0; i < TEST_LCD_H_RES / 16; i++) { - for (int j = 0; j < TEST_LCD_V_RES / 8; j++) { - TEST_ESP_OK(esp_lcd_panel_draw_bitmap(panel_handle, i * 16, j * 8, i * 16 + 16, j * 8 + 8, pattern[i & 0x01])); - } - } - - TEST_ESP_OK(esp_lcd_panel_del(panel_handle)); - TEST_ESP_OK(esp_lcd_panel_io_del(io_handle)); - TEST_ESP_OK(i2c_driver_delete(TEST_I2C_HOST_ID)); -} diff --git a/components/esp_lcd/test_apps/i2c_lcd_legacy/pytest_i2c_lcd_legacy.py b/components/esp_lcd/test_apps/i2c_lcd_legacy/pytest_i2c_lcd_legacy.py deleted file mode 100644 index d0aa353142..0000000000 --- a/components/esp_lcd/test_apps/i2c_lcd_legacy/pytest_i2c_lcd_legacy.py +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD -# SPDX-License-Identifier: CC0-1.0 -import pytest -from pytest_embedded import Dut -from pytest_embedded_idf.utils import idf_parametrize - - -@pytest.mark.i2c_oled -@pytest.mark.parametrize( - 'config', - [ - 'release', - ], - indirect=True, -) -@idf_parametrize('target', ['esp32c3'], indirect=['target']) -def test_i2c_lcd_legacy(dut: Dut) -> None: - dut.run_all_single_board_cases() diff --git a/components/esp_lcd/test_apps/i2c_lcd_legacy/sdkconfig.ci.release b/components/esp_lcd/test_apps/i2c_lcd_legacy/sdkconfig.ci.release deleted file mode 100644 index 3cff15d49e..0000000000 --- a/components/esp_lcd/test_apps/i2c_lcd_legacy/sdkconfig.ci.release +++ /dev/null @@ -1,3 +0,0 @@ -CONFIG_COMPILER_OPTIMIZATION_SIZE=y -CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y -CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y diff --git a/components/esp_lcd/test_apps/i2c_lcd_legacy/sdkconfig.defaults b/components/esp_lcd/test_apps/i2c_lcd_legacy/sdkconfig.defaults deleted file mode 100644 index ccc43c6fdf..0000000000 --- a/components/esp_lcd/test_apps/i2c_lcd_legacy/sdkconfig.defaults +++ /dev/null @@ -1,5 +0,0 @@ -# This file was generated using idf.py save-defconfig. It can be edited manually. -# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration -# -# CONFIG_ESP_TASK_WDT_INIT is not set -CONFIG_FREERTOS_HZ=1000 diff --git a/docs/en/migration-guides/release-6.x/6.0/peripherals.rst b/docs/en/migration-guides/release-6.x/6.0/peripherals.rst index 94a7900483..463aa97185 100644 --- a/docs/en/migration-guides/release-6.x/6.0/peripherals.rst +++ b/docs/en/migration-guides/release-6.x/6.0/peripherals.rst @@ -173,6 +173,7 @@ LCD - The ``color_space`` and ``rgb_endian`` configuration options in the :cpp:type:`esp_lcd_panel_dev_config_t` structure have been replaced by the :cpp:member:`esp_lcd_panel_dev_config_t::rgb_ele_order` member, which sets the RGB element order. The corresponding types ``lcd_color_rgb_endian_t`` and ``esp_lcd_color_space_t`` have also been removed; use :cpp:type:`lcd_rgb_element_order_t` instead. - The ``esp_lcd_panel_disp_off`` function has been removed. Please use the :func:`esp_lcd_panel_disp_on_off` function to control display on/off. - The ``on_bounce_frame_finish`` member in :cpp:type:`esp_lcd_rgb_panel_event_callbacks_t` has been replaced by :cpp:member:`esp_lcd_rgb_panel_event_callbacks_t::on_frame_buf_complete`, which indicates that a complete frame buffer has been sent to the LCD controller. +- The legacy I2C driver ``driver/i2c.h`` is deprecated since version 5.2. Starting from version 6.0, LCD driver based on legacy I2C is removed and LCD driver would only based on new I2C driver ``driver/i2c_master.h``. SPI --- diff --git a/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst b/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst index 705e5e4e6e..347cebc778 100644 --- a/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst +++ b/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst @@ -173,6 +173,7 @@ LCD - :cpp:type:`esp_lcd_panel_dev_config_t` 结构体中的 ``color_space`` 和 ``rgb_endian`` 配置均已被 :cpp:member:`esp_lcd_panel_dev_config_t::rgb_ele_order` 成员取代,用来设置 RGB 元素的排列顺序。对应的类型 ``lcd_color_rgb_endian_t`` 和 ``esp_lcd_color_space_t`` 也已被移除,请使用 :cpp:type:`lcd_rgb_element_order_t` 替代。 - ``esp_lcd_panel_disp_off`` 函数已被移除。请使用 :func:`esp_lcd_panel_disp_on_off` 函数来控制显示内容的开关。 - :cpp:type:`esp_lcd_rgb_panel_event_callbacks_t` 中的 ``on_bounce_frame_finish`` 成员已被 :cpp:member:`esp_lcd_rgb_panel_event_callbacks_t::on_frame_buf_complete` 成员取代,用于指示一个完整的帧缓冲区已被发送给 LCD 控制器。 +- 基于旧版 I2C 的 LCD 驱动 ``driver/lcd.h`` 在 5.2 的版本中就已经被弃用。从 6.0 版本开始,基于旧版 I2C 的 LCD 驱动被完全移除并只使用基于 ``driver/i2c_master.h`` 的新驱动。 SPI ---