Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bsp(ESP32-P4 EV): Update BSP for HW v1.4 + LCD EK79007 1024x600 #356

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions bsp/esp32_p4_function_ev_board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,31 @@ menu "Board Support Package(ESP32-P4)"
help
LEDC channel is used to generate PWM signal that controls display brightness.
Set LEDC index that should be used.

choice BSP_LCD_COLOR_FORMAT
prompt "Select LCD color format"
default BSP_LCD_COLOR_FORMAT_RGB565
help
Select the LCD color format RGB565/RGB888.

config BSP_LCD_COLOR_FORMAT_RGB565
bool "RGB565"
config BSP_LCD_COLOR_FORMAT_RGB888
bool "RGB888"
endchoice

choice BSP_LCD_TYPE
prompt "Select LCD type"
default BSP_LCD_TYPE_1024_600
help
Select the LCD.

config BSP_LCD_TYPE_1024_600
bool "LCD 7-inch 1024x600 - ek79007"
config BSP_LCD_TYPE_1280_800
bool "LCD 1280x800 - ili9881c"
endchoice

endmenu

endmenu
37 changes: 26 additions & 11 deletions bsp/esp32_p4_function_ev_board/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,32 @@ ESP32-P4 Function EV Board is internal Espressif board for testing features on E
| :--------: | :---------: |
| V1.0 | ^1 |
| V1.2 | ^2 |
| [V1.4](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/user_guide.html) | ^3 |

## Configuration

Configuration in `menuconfig`.

Selection LCD display `Board Support Package(ESP32-P4) --> Display --> Select LCD type`
- LCD 7-inch 1024x600 - ili9881c (default)
- LCD 1280x800 - ek79007

Selection color format `Board Support Package(ESP32-P4) --> Display --> Select LCD color format`
- RGB565 (default)
- RGB888


<!-- Autogenerated start: Dependencies -->
### Capabilities and dependencies
| Capability | Available | Component |Version|
|-------------|------------------|----------------------------------------------------------------------------------------------------------|-------|
| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_ili9881c](https://components.espressif.com/components/espressif/esp_lcd_ili9881c) |>=0.2.0|
| LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 |
| TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_gt911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911)| ^1 |
| BUTTONS | :x: | | |
| AUDIO | :x: | | |
|AUDIO_SPEAKER| :x: | | |
| AUDIO_MIC | :x: | | |
| SDCARD |:heavy_check_mark:| idf | >=5.3 |
| IMU | :x: | | |
| Capability | Available | Component | Version |
|-------------|------------------|----------------------------------------------------------------------------------------------------------|--------------|
| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_ek79007](https://components.espressif.com/components/espressif/esp_lcd_ek79007) |>=0.1.0,<1.0.0|
| LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 |
| TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_gt911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911)| ^1 |
| BUTTONS | :x: | | |
| AUDIO | :x: | | |
|AUDIO_SPEAKER| :x: | | |
| AUDIO_MIC | :x: | | |
| SDCARD |:heavy_check_mark:| idf | >=5.3 |
| IMU | :x: | | |
<!-- Autogenerated end: Dependencies -->
105 changes: 84 additions & 21 deletions bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "sdkconfig.h"
#include "driver/gpio.h"
#include "driver/ledc.h"
#include "esp_err.h"
Expand All @@ -13,10 +14,16 @@
#include "esp_lcd_panel_ops.h"
#include "esp_lcd_mipi_dsi.h"
#include "esp_ldo_regulator.h"
#include "esp_lcd_ili9881c.h"
#include "esp_vfs_fat.h"
#include "usb/usb_host.h"


#if CONFIG_BSP_LCD_TYPE_1024_600
#include "esp_lcd_ek79007.h"
#else
#include "esp_lcd_ili9881c.h"
#endif

#include "bsp/esp32_p4_function_ev_board.h"
#include "bsp/display.h"
#include "bsp/touch.h"
Expand Down Expand Up @@ -244,29 +251,69 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
};
ESP_GOTO_ON_ERROR(esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &io), err, TAG, "New panel IO failed");

esp_lcd_panel_handle_t ctrl_panel = NULL;
esp_lcd_panel_handle_t disp_panel = NULL;
#if CONFIG_BSP_LCD_TYPE_1024_600
// create EK79007 control panel
ESP_LOGI(TAG, "Install EK79007 LCD control panel");

#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888
const esp_lcd_dpi_panel_config_t dpi_config = EK79007_1024_600_PANEL_60HZ_CONFIG(LCD_COLOR_PIXEL_FORMAT_RGB888);
#else
const esp_lcd_dpi_panel_config_t dpi_config = EK79007_1024_600_PANEL_60HZ_CONFIG(LCD_COLOR_PIXEL_FORMAT_RGB565);
#endif
ek79007_vendor_config_t vendor_config = {
.flags = {
.use_mipi_interface = 1,
},
.mipi_config = {
.dsi_bus = mipi_dsi_bus,
.dpi_config = &dpi_config,
},
};
esp_lcd_panel_dev_config_t lcd_dev_config = {
.bits_per_pixel = 16,
.rgb_ele_order = BSP_LCD_COLOR_SPACE,
.reset_gpio_num = BSP_LCD_RST,
.vendor_config = &vendor_config,
};
ESP_GOTO_ON_ERROR(esp_lcd_new_panel_ek79007(io, &lcd_dev_config, &disp_panel), err, TAG, "New LCD panel EK79007 failed");
ESP_GOTO_ON_ERROR(esp_lcd_panel_reset(disp_panel), err, TAG, "LCD panel reset failed");
ESP_GOTO_ON_ERROR(esp_lcd_panel_init(disp_panel), err, TAG, "LCD panel init failed");

/* Return all handles */
ret_handles->io = io;
ret_handles->mipi_dsi_bus = mipi_dsi_bus;
ret_handles->panel = disp_panel;
ret_handles->control = NULL;

#else
// create ILI9881C control panel
esp_lcd_panel_handle_t ili9881c_ctrl_panel;
ESP_LOGI(TAG, "Install ILI9881C LCD control panel");
esp_lcd_panel_dev_config_t lcd_dev_config = {
.bits_per_pixel = 16,
.rgb_ele_order = BSP_LCD_COLOR_SPACE,
.reset_gpio_num = -1,
};
ESP_GOTO_ON_ERROR(esp_lcd_new_panel_ili9881c(io, &lcd_dev_config, &ili9881c_ctrl_panel), err, TAG, "New LCD panel ILI9881C failed");
ESP_GOTO_ON_ERROR(esp_lcd_panel_reset(ili9881c_ctrl_panel), err, TAG, "LCD panel reset failed");
ESP_GOTO_ON_ERROR(esp_lcd_panel_init(ili9881c_ctrl_panel), err, TAG, "LCD panel init failed");
ESP_GOTO_ON_ERROR(esp_lcd_panel_disp_on_off(ili9881c_ctrl_panel, true), err, TAG, "LCD panel ON failed");
esp_lcd_panel_mirror(ili9881c_ctrl_panel, true, true);
ESP_GOTO_ON_ERROR(esp_lcd_new_panel_ili9881c(io, &lcd_dev_config, &ctrl_panel), err, TAG, "New LCD panel ILI9881C failed");
ESP_GOTO_ON_ERROR(esp_lcd_panel_reset(ctrl_panel), err, TAG, "LCD panel reset failed");
ESP_GOTO_ON_ERROR(esp_lcd_panel_init(ctrl_panel), err, TAG, "LCD panel init failed");
ESP_GOTO_ON_ERROR(esp_lcd_panel_disp_on_off(ctrl_panel, true), err, TAG, "LCD panel ON failed");
esp_lcd_panel_mirror(ctrl_panel, true, true);

ESP_LOGI(TAG, "Install MIPI DSI LCD data panel");
esp_lcd_panel_handle_t ili9881c_panel;
esp_lcd_dpi_panel_config_t dpi_config = {
.virtual_channel = 0,
.dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT,
.dpi_clock_freq_mhz = BSP_LCD_PIXEL_CLOCK_MHZ,
#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888
.pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB888,
#else
.pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB565,
#endif
.video_timing = {
.h_size = BSP_LCD_V_RES,
.v_size = BSP_LCD_H_RES,
.h_size = BSP_LCD_H_RES,
.v_size = BSP_LCD_V_RES,
.hsync_back_porch = BSP_LCD_MIPI_DSI_LCD_HBP,
.hsync_pulse_width = BSP_LCD_MIPI_DSI_LCD_HSYNC,
.hsync_front_porch = BSP_LCD_MIPI_DSI_LCD_HFP,
Expand All @@ -276,25 +323,26 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l
},
.flags.use_dma2d = true,
};
ESP_GOTO_ON_ERROR(esp_lcd_new_panel_dpi(mipi_dsi_bus, &dpi_config, &ili9881c_panel), err, TAG, "New panel DPI failed");
ESP_GOTO_ON_ERROR(esp_lcd_panel_init(ili9881c_panel), err, TAG, "New panel DPI init failed");
ESP_GOTO_ON_ERROR(esp_lcd_new_panel_dpi(mipi_dsi_bus, &dpi_config, &disp_panel), err, TAG, "New panel DPI failed");
ESP_GOTO_ON_ERROR(esp_lcd_panel_init(disp_panel), err, TAG, "New panel DPI init failed");

/* Return all handles */
ret_handles->io = io;
ret_handles->mipi_dsi_bus = mipi_dsi_bus;
ret_handles->panel = ili9881c_panel;
ret_handles->control = ili9881c_ctrl_panel;
ret_handles->panel = disp_panel;
ret_handles->control = ctrl_panel;
#endif

ESP_LOGI(TAG, "Display initialized");

return ret;

err:
if (ili9881c_panel) {
esp_lcd_panel_del(ili9881c_panel);
if (disp_panel) {
esp_lcd_panel_del(disp_panel);
}
if (ili9881c_ctrl_panel) {
esp_lcd_panel_del(ili9881c_ctrl_panel);
if (ctrl_panel) {
esp_lcd_panel_del(ctrl_panel);
}
if (io) {
esp_lcd_panel_io_del(io);
Expand All @@ -314,16 +362,21 @@ esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t
const esp_lcd_touch_config_t tp_cfg = {
.x_max = BSP_LCD_H_RES,
.y_max = BSP_LCD_V_RES,
.rst_gpio_num = GPIO_NUM_NC, // Shared with LCD reset
.rst_gpio_num = BSP_LCD_TOUCH_RST, // Shared with LCD reset
.int_gpio_num = BSP_LCD_TOUCH_INT,
.levels = {
.reset = 0,
.interrupt = 0,
},
.flags = {
.swap_xy = 0,
#if CONFIG_BSP_LCD_TYPE_1024_600
.mirror_x = 1,
.mirror_y = 1,
#else
.mirror_x = 0,
.mirror_y = 0,
#endif
},
};
esp_lcd_panel_io_handle_t tp_io_handle = NULL;
Expand All @@ -347,16 +400,22 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg)
.control_handle = lcd_panels.control,
.buffer_size = cfg->buffer_size,
.double_buffer = cfg->double_buffer,
.hres = BSP_LCD_V_RES,
.vres = BSP_LCD_H_RES,
.hres = BSP_LCD_H_RES,
.vres = BSP_LCD_V_RES,
.monochrome = false,
/* Rotation values must be same as used in esp_lcd for initial settings of the screen */
.rotation = {
.swap_xy = false,
.mirror_x = true,
.mirror_y = true,
},
#if LVGL_VERSION_MAJOR >= 9
#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888
.color_format = LV_COLOR_FORMAT_RGB888,
#else
.color_format = LV_COLOR_FORMAT_RGB565,
#endif
#endif
.flags = {
.buff_dma = cfg->flags.buff_dma,
.buff_spiram = cfg->flags.buff_spiram,
Expand Down Expand Up @@ -392,7 +451,11 @@ lv_display_t *bsp_display_start(void)
.buffer_size = BSP_LCD_DRAW_BUFF_SIZE,
.double_buffer = BSP_LCD_DRAW_BUFF_DOUBLE,
.flags = {
#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888
.buff_dma = false,
#else
.buff_dma = true,
#endif
.buff_spiram = false,
.sw_rotate = true,
}
Expand Down
5 changes: 3 additions & 2 deletions bsp/esp32_p4_function_ev_board/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "2.0.0"
version: "3.0.0"
description: Board Support Package (BSP) for ESP32-P4 Function EV Board (preview)
url: https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_p4_function_ev_board

Expand All @@ -10,7 +10,8 @@ tags:

dependencies:
idf: ">=5.3"
esp_lcd_ili9881c: ">=0.2.0"
esp_lcd_ili9881c: ">=0.2.0,<1.0.0"
esp_lcd_ek79007: ">=0.1.0,<1.0.0"
esp_lcd_touch_gt911: "^1"
lvgl/lvgl: ">=8,<10"

Expand Down
25 changes: 22 additions & 3 deletions bsp/esp32_p4_function_ev_board/include/bsp/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,48 @@
#pragma once
#include "esp_lcd_types.h"
#include "esp_lcd_mipi_dsi.h"
#include "sdkconfig.h"

/* LCD color formats */
#define ESP_LCD_COLOR_FORMAT_RGB565 (1)
#define ESP_LCD_COLOR_FORMAT_RGB888 (2)

/* LCD display color format */
#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888
#define BSP_LCD_COLOR_FORMAT (ESP_LCD_COLOR_FORMAT_RGB888)
#else
#define BSP_LCD_COLOR_FORMAT (ESP_LCD_COLOR_FORMAT_RGB565)
#endif
/* LCD display color bytes endianess */
#define BSP_LCD_BIGENDIAN (0)
/* LCD display color bits */
#define BSP_LCD_BITS_PER_PIXEL (16)
/* LCD display color space */
#define BSP_LCD_COLOR_SPACE (ESP_LCD_COLOR_SPACE_RGB)
/* LCD display definition */
#define BSP_LCD_H_RES (1280)
#define BSP_LCD_V_RES (800)

#if CONFIG_BSP_LCD_TYPE_1024_600
/* LCD display definition 1024x600 */
#define BSP_LCD_H_RES (1024)
#define BSP_LCD_V_RES (600)

#define BSP_LCD_MIPI_DSI_LCD_HSYNC (1344)
#define BSP_LCD_MIPI_DSI_LCD_HBP (160)
#define BSP_LCD_MIPI_DSI_LCD_HFP (160)
#define BSP_LCD_MIPI_DSI_LCD_VSYNC (635)
#define BSP_LCD_MIPI_DSI_LCD_VBP (23)
#define BSP_LCD_MIPI_DSI_LCD_VFP (12)
#else
/* LCD display definition 1280x800 */
#define BSP_LCD_H_RES (800)
#define BSP_LCD_V_RES (1280)

#define BSP_LCD_MIPI_DSI_LCD_HSYNC (40)
#define BSP_LCD_MIPI_DSI_LCD_HBP (140)
#define BSP_LCD_MIPI_DSI_LCD_HFP (40)
#define BSP_LCD_MIPI_DSI_LCD_VSYNC (4)
#define BSP_LCD_MIPI_DSI_LCD_VBP (16)
#define BSP_LCD_MIPI_DSI_LCD_VFP (16)
#endif

#define BSP_LCD_MIPI_DSI_LANE_NUM (2) // 2 data lanes
#define BSP_LCD_MIPI_DSI_LANE_BITRATE_MBPS (1000) // 1Gbps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "driver/sdmmc_host.h"
#include "bsp/config.h"
#include "bsp/display.h"
#include "sdkconfig.h"

#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
#include "lvgl.h"
Expand Down Expand Up @@ -44,8 +45,17 @@
#define BSP_I2C_SDA (GPIO_NUM_7)

/* Display */
#if CONFIG_BSP_LCD_TYPE_1024_600
#define BSP_LCD_BACKLIGHT (GPIO_NUM_26)
#define BSP_LCD_RST (GPIO_NUM_27)
#define BSP_LCD_TOUCH_RST (GPIO_NUM_NC)
#define BSP_LCD_TOUCH_INT (GPIO_NUM_NC)
#else
#define BSP_LCD_BACKLIGHT (GPIO_NUM_23)
#define BSP_LCD_RST (GPIO_NUM_NC)
#define BSP_LCD_TOUCH_RST (GPIO_NUM_NC)
#define BSP_LCD_TOUCH_INT (GPIO_NUM_NC)
#endif

/* uSD card */
#define BSP_SD_D0 (GPIO_NUM_39)
Expand Down
Loading