From 5ba53c92944214b8593dc5a24e5a2c9d91cbc975 Mon Sep 17 00:00:00 2001 From: morris Date: Mon, 8 May 2023 14:47:54 +0800 Subject: [PATCH] rgb_lcd: make pclk gpio setting optional PCLK may not be necessary in VGA use case. Closes https://github.com/espressif/esp-idf/issues/11298 --- components/esp_lcd/include/esp_lcd_panel_rgb.h | 2 +- components/esp_lcd/src/esp_lcd_panel_rgb.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/esp_lcd/include/esp_lcd_panel_rgb.h b/components/esp_lcd/include/esp_lcd_panel_rgb.h index 082ce45f96b1..a2a88d45e2bf 100644 --- a/components/esp_lcd/include/esp_lcd_panel_rgb.h +++ b/components/esp_lcd/include/esp_lcd_panel_rgb.h @@ -126,7 +126,7 @@ typedef struct { int hsync_gpio_num; /*!< GPIO used for HSYNC signal */ int vsync_gpio_num; /*!< GPIO used for VSYNC signal */ int de_gpio_num; /*!< GPIO used for DE signal, set to -1 if it's not used */ - int pclk_gpio_num; /*!< GPIO used for PCLK signal */ + int pclk_gpio_num; /*!< GPIO used for PCLK signal, set to -1 if it's not used */ int disp_gpio_num; /*!< GPIO used for display control signal, set to -1 if it's not used */ int data_gpio_nums[SOC_LCD_RGB_DATA_WIDTH]; /*!< GPIOs used for data lines */ struct { diff --git a/components/esp_lcd/src/esp_lcd_panel_rgb.c b/components/esp_lcd/src/esp_lcd_panel_rgb.c index 49dcfd57ee74..454900b76557 100644 --- a/components/esp_lcd/src/esp_lcd_panel_rgb.c +++ b/components/esp_lcd/src/esp_lcd_panel_rgb.c @@ -866,7 +866,7 @@ static esp_err_t lcd_rgb_panel_configure_gpio(esp_rgb_panel_t *panel, const esp_ { int panel_id = panel->panel_id; // check validation of GPIO number - bool valid_gpio = (panel_config->pclk_gpio_num >= 0); + bool valid_gpio = true; if (panel_config->de_gpio_num < 0) { // Hsync and Vsync are required in HV mode valid_gpio = valid_gpio && (panel_config->hsync_gpio_num >= 0) && (panel_config->vsync_gpio_num >= 0); @@ -896,10 +896,13 @@ static esp_err_t lcd_rgb_panel_configure_gpio(esp_rgb_panel_t *panel, const esp_ esp_rom_gpio_connect_out_signal(panel_config->vsync_gpio_num, lcd_periph_signals.panels[panel_id].vsync_sig, false, false); } - gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[panel_config->pclk_gpio_num], PIN_FUNC_GPIO); - gpio_set_direction(panel_config->pclk_gpio_num, GPIO_MODE_OUTPUT); - esp_rom_gpio_connect_out_signal(panel_config->pclk_gpio_num, - lcd_periph_signals.panels[panel_id].pclk_sig, false, false); + // PCLK may not be necessary in some cases (i.e. VGA output) + if (panel_config->pclk_gpio_num >= 0) { + gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[panel_config->pclk_gpio_num], PIN_FUNC_GPIO); + gpio_set_direction(panel_config->pclk_gpio_num, GPIO_MODE_OUTPUT); + esp_rom_gpio_connect_out_signal(panel_config->pclk_gpio_num, + lcd_periph_signals.panels[panel_id].pclk_sig, false, false); + } // DE signal might not be necessary for some RGB LCD if (panel_config->de_gpio_num >= 0) { gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[panel_config->de_gpio_num], PIN_FUNC_GPIO);