Skip to content

Commit b4e356b

Browse files
authored
Merge pull request #18 from Ocean-lhy/fix-lcd-rst
Update firmware version to V0.5 and modify I2C initialization for improved LCD_RST handling
2 parents 68b19d3 + 0e54f8f commit b4e356b

2 files changed

Lines changed: 74 additions & 49 deletions

File tree

app/apps/app_startup_anim/app_startup_anim.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ using namespace mooncake;
1313
using namespace smooth_ui_toolkit;
1414
using namespace smooth_ui_toolkit::lvgl_cpp;
1515

16-
#define FIRMWARE_VERSION "V0.4"
16+
#define FIRMWARE_VERSION "V0.5"
1717

1818
AppStartupAnim::AppStartupAnim()
1919
{

platforms/tab5/components/m5stack_tab5/m5stack_tab5.c

Lines changed: 73 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -260,26 +260,30 @@ void bsp_io_expander_pi4ioe_init(i2c_master_bus_handle_t bus_handle)
260260
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2, I2C_MASTER_TIMEOUT_MS);
261261
write_buf[0] = PI4IO_REG_CHIP_RESET;
262262
i2c_master_transmit_receive(i2c_dev_handle_pi4ioe1, write_buf, 1, read_buf, 1, I2C_MASTER_TIMEOUT_MS);
263-
write_buf[0] = PI4IO_REG_IO_DIR;
264-
write_buf[1] = 0b01111111;
265-
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2, I2C_MASTER_TIMEOUT_MS); // 0: input 1: output
266-
write_buf[0] = PI4IO_REG_OUT_H_IM;
267-
write_buf[1] = 0b00000000;
268-
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2,
269-
I2C_MASTER_TIMEOUT_MS); // 使用到的引脚关闭 High-Impedance
263+
264+
/* 复位后默认 Hi-Z + 下拉。屏端 LCD_RST 无 1.8V 上拉,P4 不能推挽输出 3.3V,用输入上拉释放复位 */
270265
write_buf[0] = PI4IO_REG_PULL_SEL;
271266
write_buf[1] = 0b01111111;
272267
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2,
273268
I2C_MASTER_TIMEOUT_MS); // pull up/down select, 0 down, 1 up
274269
write_buf[0] = PI4IO_REG_PULL_EN;
275270
write_buf[1] = 0b01111111;
271+
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2, I2C_MASTER_TIMEOUT_MS);
276272

277-
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2,
278-
I2C_MASTER_TIMEOUT_MS); // P7 中断使能 0 enable, 1 disable
279-
/* Output Port Register P1(SPK_EN), P2(EXT5V_EN), P4(LCD_RST), P5(TP_RST), P6(CAM)RST 输出高电平 */
280273
write_buf[0] = PI4IO_REG_OUT_SET;
281-
write_buf[1] = 0b01110110;
274+
write_buf[1] = 0b01100110;
275+
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2, I2C_MASTER_TIMEOUT_MS); // P4 锁存 0,拉低复位时不推 3.3V
276+
write_buf[0] = PI4IO_REG_OUT_H_IM;
277+
write_buf[1] = 0b00000000;
282278
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2, I2C_MASTER_TIMEOUT_MS);
279+
write_buf[0] = PI4IO_REG_IO_DIR;
280+
write_buf[1] = 0b01111111;
281+
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2, I2C_MASTER_TIMEOUT_MS); // P4 先输出拉低复位
282+
vTaskDelay(pdMS_TO_TICKS(10));
283+
write_buf[0] = PI4IO_REG_IO_DIR;
284+
write_buf[1] = 0b01101111;
285+
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2, I2C_MASTER_TIMEOUT_MS); // P4 输入上拉释放 RST
286+
vTaskDelay(pdMS_TO_TICKS(50));
283287

284288
/* */
285289
i2c_device_config_t dev_cfg2 = {
@@ -514,21 +518,37 @@ void bsp_reset_tp()
514518
uint8_t write_buf[2] = {0};
515519
uint8_t read_buf[1] = {0};
516520

521+
/* LCD_RST(P4) 锁存保持 0:输出时只拉低,释放时切回输入上拉,避免推挽 3.3V */
517522
write_buf[0] = PI4IO_REG_OUT_SET;
518523
i2c_master_transmit_receive(i2c_dev_handle_pi4ioe1, write_buf, 1, read_buf, 1, I2C_MASTER_TIMEOUT_MS);
519-
520524
write_buf[0] = PI4IO_REG_OUT_SET;
521525
write_buf[1] = read_buf[0];
522526
clrbit(write_buf[1], 4);
523527
clrbit(write_buf[1], 5);
524528
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2, I2C_MASTER_TIMEOUT_MS);
529+
530+
write_buf[0] = PI4IO_REG_IO_DIR;
531+
i2c_master_transmit_receive(i2c_dev_handle_pi4ioe1, write_buf, 1, read_buf, 1, I2C_MASTER_TIMEOUT_MS);
532+
write_buf[0] = PI4IO_REG_IO_DIR;
533+
write_buf[1] = read_buf[0];
534+
setbit(write_buf[1], 4);
535+
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2, I2C_MASTER_TIMEOUT_MS);
525536
vTaskDelay(100 / portTICK_PERIOD_MS);
526537

538+
write_buf[0] = PI4IO_REG_OUT_SET;
539+
i2c_master_transmit_receive(i2c_dev_handle_pi4ioe1, write_buf, 1, read_buf, 1, I2C_MASTER_TIMEOUT_MS);
527540
write_buf[0] = PI4IO_REG_OUT_SET;
528541
write_buf[1] = read_buf[0];
529-
setbit(write_buf[1], 4);
542+
clrbit(write_buf[1], 4);
530543
setbit(write_buf[1], 5);
531544
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2, I2C_MASTER_TIMEOUT_MS);
545+
546+
write_buf[0] = PI4IO_REG_IO_DIR;
547+
i2c_master_transmit_receive(i2c_dev_handle_pi4ioe1, write_buf, 1, read_buf, 1, I2C_MASTER_TIMEOUT_MS);
548+
write_buf[0] = PI4IO_REG_IO_DIR;
549+
write_buf[1] = read_buf[0];
550+
clrbit(write_buf[1], 4);
551+
i2c_master_transmit(i2c_dev_handle_pi4ioe1, write_buf, 2, I2C_MASTER_TIMEOUT_MS);
532552
vTaskDelay(100 / portTICK_PERIOD_MS);
533553
}
534554

@@ -695,14 +715,19 @@ static bsp_codec_config_t g_codec_handle;
695715
static int volume;
696716

697717
/* Can be used for `i2s_std_gpio_config_t` and/or `i2s_std_config_t` initialization */
698-
#define BSP_I2S_GPIO_CFG \
699-
{ \
700-
.mclk = BSP_I2S_MCLK, .bclk = BSP_I2S_SCLK, .ws = BSP_I2S_LCLK, .dout = BSP_I2S_DOUT, .din = BSP_I2S_DSIN, \
701-
.invert_flags = { \
702-
.mclk_inv = false, \
703-
.bclk_inv = false, \
704-
.ws_inv = false, \
705-
}, \
718+
#define BSP_I2S_GPIO_CFG \
719+
{ \
720+
.mclk = BSP_I2S_MCLK, \
721+
.bclk = BSP_I2S_SCLK, \
722+
.ws = BSP_I2S_LCLK, \
723+
.dout = BSP_I2S_DOUT, \
724+
.din = BSP_I2S_DSIN, \
725+
.invert_flags = \
726+
{ \
727+
.mclk_inv = false, \
728+
.bclk_inv = false, \
729+
.ws_inv = false, \
730+
}, \
706731
}
707732

708733
/* This configuration is used by default in `bsp_extra_audio_init()` */
@@ -1502,46 +1527,46 @@ static lv_display_t* bsp_display_lcd_init(const bsp_display_cfg_t* cfg)
15021527

15031528
/* Add LCD screen */
15041529
ESP_LOGD(TAG, "Add LCD screen");
1505-
const lvgl_port_display_cfg_t disp_cfg =
1506-
{.io_handle = lcd_panels.io,
1507-
.panel_handle = lcd_panels.panel,
1508-
.control_handle = lcd_panels.control,
1509-
.buffer_size = cfg->buffer_size,
1510-
.double_buffer = cfg->double_buffer,
1511-
.hres = BSP_LCD_H_RES,
1512-
.vres = BSP_LCD_V_RES,
1513-
.monochrome = false,
1514-
/* Rotation values must be same as used in esp_lcd for initial settings of the screen */
1515-
.rotation =
1516-
{
1517-
.swap_xy = false,
1518-
.mirror_x = false,
1519-
.mirror_y = false,
1520-
},
1530+
const lvgl_port_display_cfg_t disp_cfg = {
1531+
.io_handle = lcd_panels.io,
1532+
.panel_handle = lcd_panels.panel,
1533+
.control_handle = lcd_panels.control,
1534+
.buffer_size = cfg->buffer_size,
1535+
.double_buffer = cfg->double_buffer,
1536+
.hres = BSP_LCD_H_RES,
1537+
.vres = BSP_LCD_V_RES,
1538+
.monochrome = false,
1539+
/* Rotation values must be same as used in esp_lcd for initial settings of the screen */
1540+
.rotation =
1541+
{
1542+
.swap_xy = false,
1543+
.mirror_x = false,
1544+
.mirror_y = false,
1545+
},
15211546
#if LVGL_VERSION_MAJOR >= 9
15221547
#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888
1523-
.color_format = LV_COLOR_FORMAT_RGB888,
1548+
.color_format = LV_COLOR_FORMAT_RGB888,
15241549
#else
1525-
.color_format = LV_COLOR_FORMAT_RGB565,
1550+
.color_format = LV_COLOR_FORMAT_RGB565,
15261551
#endif
15271552
#endif
1528-
.flags = {
1529-
.buff_dma = cfg->flags.buff_dma,
1530-
.buff_spiram = cfg->flags.buff_spiram,
1553+
.flags = {
1554+
.buff_dma = cfg->flags.buff_dma,
1555+
.buff_spiram = cfg->flags.buff_spiram,
15311556
#if LVGL_VERSION_MAJOR >= 9
1532-
.swap_bytes = (BSP_LCD_BIGENDIAN ? true : false),
1557+
.swap_bytes = (BSP_LCD_BIGENDIAN ? true : false),
15331558
#endif
15341559
#if CONFIG_BSP_DISPLAY_LVGL_AVOID_TEAR
1535-
.sw_rotate = false, /* Avoid tearing is not supported for SW rotation */
1560+
.sw_rotate = false, /* Avoid tearing is not supported for SW rotation */
15361561
#else
1537-
.sw_rotate = cfg->flags.sw_rotate, /* Only SW rotation is supported for 90° and 270° */
1562+
.sw_rotate = cfg->flags.sw_rotate, /* Only SW rotation is supported for 90° and 270° */
15381563
#endif
15391564
#if CONFIG_BSP_DISPLAY_LVGL_FULL_REFRESH
1540-
.full_refresh = true,
1565+
.full_refresh = true,
15411566
#elif CONFIG_BSP_DISPLAY_LVGL_DIRECT_MODE
1542-
.direct_mode = true,
1567+
.direct_mode = true,
15431568
#endif
1544-
} };
1569+
}};
15451570

15461571
const lvgl_port_display_dsi_cfg_t dpi_cfg = {.flags = {
15471572
#if CONFIG_BSP_DISPLAY_LVGL_AVOID_TEAR

0 commit comments

Comments
 (0)