-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/dsi_lcd_iram_safe' into 'master'
MIPI DSI IRAM Safe See merge request espressif/esp-idf!30416
- Loading branch information
Showing
13 changed files
with
233 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
components/esp_lcd/test_apps/mipi_dsi_lcd/main/test_mipi_dsi_iram.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <inttypes.h> | ||
#include "freertos/FreeRTOS.h" | ||
#include "freertos/task.h" | ||
#include "unity.h" | ||
#include "unity_test_utils.h" | ||
#include "esp_lcd_mipi_dsi.h" | ||
#include "esp_lcd_panel_ops.h" | ||
#include "esp_lcd_panel_io.h" | ||
#include "esp_random.h" | ||
#include "esp_attr.h" | ||
#include "test_mipi_dsi_board.h" | ||
#include "esp_lcd_ili9881c.h" | ||
|
||
IRAM_ATTR static bool test_rgb_panel_count_in_callback(esp_lcd_panel_handle_t panel, esp_lcd_dpi_panel_event_data_t *edata, void *user_ctx) | ||
{ | ||
uint32_t *count = (uint32_t *)user_ctx; | ||
*count = *count + 1; | ||
return false; | ||
} | ||
|
||
static void IRAM_ATTR test_delay_post_cache_disable(void *args) | ||
{ | ||
esp_rom_delay_us(200000); | ||
} | ||
|
||
#define TEST_IMG_SIZE (100 * 100 * sizeof(uint16_t)) | ||
|
||
TEST_CASE("MIPI DSI draw bitmap (ILI9881C) IRAM Safe", "[mipi_dsi]") | ||
{ | ||
esp_lcd_dsi_bus_handle_t mipi_dsi_bus; | ||
esp_lcd_panel_io_handle_t mipi_dbi_io; | ||
esp_lcd_panel_handle_t mipi_dpi_panel; | ||
esp_lcd_panel_handle_t ili9881c_ctrl_panel; | ||
|
||
test_bsp_enable_dsi_phy_power(); | ||
|
||
uint8_t *img = malloc(TEST_IMG_SIZE); | ||
TEST_ASSERT_NOT_NULL(img); | ||
|
||
esp_lcd_dsi_bus_config_t bus_config = { | ||
.bus_id = 0, | ||
.num_data_lanes = 2, | ||
.phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT, | ||
.lane_bit_rate_mbps = 1000, // 1000 Mbps | ||
}; | ||
TEST_ESP_OK(esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus)); | ||
|
||
esp_lcd_dbi_io_config_t dbi_config = { | ||
.virtual_channel = 0, | ||
.lcd_cmd_bits = 8, | ||
.lcd_param_bits = 8, | ||
}; | ||
TEST_ESP_OK(esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &mipi_dbi_io)); | ||
|
||
esp_lcd_panel_dev_config_t lcd_dev_config = { | ||
.bits_per_pixel = 16, | ||
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB, | ||
.reset_gpio_num = -1, | ||
}; | ||
TEST_ESP_OK(esp_lcd_new_panel_ili9881c(mipi_dbi_io, &lcd_dev_config, &ili9881c_ctrl_panel)); | ||
TEST_ESP_OK(esp_lcd_panel_reset(ili9881c_ctrl_panel)); | ||
TEST_ESP_OK(esp_lcd_panel_init(ili9881c_ctrl_panel)); | ||
// turn on display | ||
TEST_ESP_OK(esp_lcd_panel_disp_on_off(ili9881c_ctrl_panel, true)); | ||
|
||
esp_lcd_dpi_panel_config_t dpi_config = { | ||
.dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT, | ||
.dpi_clock_freq_mhz = MIPI_DSI_DPI_CLK_MHZ, | ||
.virtual_channel = 0, | ||
.pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB565, | ||
.video_timing = { | ||
.h_size = MIPI_DSI_LCD_H_RES, | ||
.v_size = MIPI_DSI_LCD_V_RES, | ||
.hsync_back_porch = MIPI_DSI_LCD_HBP, | ||
.hsync_pulse_width = MIPI_DSI_LCD_HSYNC, | ||
.hsync_front_porch = MIPI_DSI_LCD_HFP, | ||
.vsync_back_porch = MIPI_DSI_LCD_VBP, | ||
.vsync_pulse_width = MIPI_DSI_LCD_VSYNC, | ||
.vsync_front_porch = MIPI_DSI_LCD_VFP, | ||
}, | ||
}; | ||
TEST_ESP_OK(esp_lcd_new_panel_dpi(mipi_dsi_bus, &dpi_config, &mipi_dpi_panel)); | ||
TEST_ESP_OK(esp_lcd_panel_init(mipi_dpi_panel)); | ||
uint32_t callback_calls = 0; | ||
esp_lcd_dpi_panel_event_callbacks_t cbs = { | ||
.on_refresh_done = test_rgb_panel_count_in_callback, | ||
}; | ||
TEST_ESP_OK(esp_lcd_dpi_panel_register_event_callbacks(mipi_dpi_panel, &cbs, &callback_calls)); | ||
|
||
uint8_t color_byte = rand() & 0xFF; | ||
int x_start = rand() % (MIPI_DSI_LCD_H_RES - 100); | ||
int y_start = rand() % (MIPI_DSI_LCD_V_RES - 100); | ||
memset(img, color_byte, TEST_IMG_SIZE); | ||
esp_lcd_panel_draw_bitmap(mipi_dpi_panel, x_start, y_start, x_start + 100, y_start + 100, img); | ||
vTaskDelay(pdMS_TO_TICKS(100)); | ||
|
||
printf("The LCD driver should keep flushing the color block in the background\r\n"); | ||
|
||
// disable the cache for a while, the LCD driver should stay working | ||
printf("disable the cache for a while\r\n"); | ||
unity_utils_run_cache_disable_stub(test_delay_post_cache_disable, NULL); | ||
printf("callback calls: %"PRIu32"\r\n", callback_calls); | ||
TEST_ASSERT(callback_calls > 2); | ||
|
||
TEST_ESP_OK(esp_lcd_panel_del(mipi_dpi_panel)); | ||
TEST_ESP_OK(esp_lcd_panel_del(ili9881c_ctrl_panel)); | ||
TEST_ESP_OK(esp_lcd_panel_io_del(mipi_dbi_io)); | ||
TEST_ESP_OK(esp_lcd_del_dsi_bus(mipi_dsi_bus)); | ||
free(img); | ||
|
||
test_bsp_disable_dsi_phy_power(); | ||
} |
11 changes: 9 additions & 2 deletions
11
components/esp_lcd/test_apps/mipi_dsi_lcd/pytest_mipi_dsi_lcd.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
# SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
import pytest | ||
from pytest_embedded import Dut | ||
|
||
|
||
@pytest.mark.esp32p4 | ||
@pytest.mark.generic | ||
def test_rgb_lcd(dut: Dut) -> None: | ||
@pytest.mark.parametrize( | ||
'config', | ||
[ | ||
'iram_safe', | ||
'release', | ||
], | ||
indirect=True, | ||
) | ||
def test_dsi_lcd(dut: Dut) -> None: | ||
dut.run_all_single_board_cases() |
8 changes: 8 additions & 0 deletions
8
components/esp_lcd/test_apps/mipi_dsi_lcd/sdkconfig.ci.iram_safe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CONFIG_COMPILER_DUMP_RTL_FILES=y | ||
CONFIG_COMPILER_OPTIMIZATION_NONE=y | ||
# silent the error check, as the error string are stored in rodata, causing RTL check failure | ||
CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y | ||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y | ||
# place non-ISR FreeRTOS functions in Flash | ||
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y | ||
CONFIG_LCD_DSI_ISR_IRAM_SAFE=y |
5 changes: 5 additions & 0 deletions
5
components/esp_lcd/test_apps/mipi_dsi_lcd/sdkconfig.ci.release
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CONFIG_PM_ENABLE=y | ||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y | ||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y | ||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y | ||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y |