From 4255e3005bdd71cb07a40f2181448506816f9e52 Mon Sep 17 00:00:00 2001 From: C47D Date: Wed, 6 Oct 2021 23:17:03 -0500 Subject: [PATCH] feat(lvgl_helpers): Add function to initialize GPIOs Adds helper function to initialize GPIOs, this avoids having to configure and initialize GPIOs in the drivers init function. Closes #128 --- lvgl_helpers.c | 33 +++++++++++++++++++++++++++++++++ lvgl_helpers.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/lvgl_helpers.c b/lvgl_helpers.c index 02f4017..8f927bf 100644 --- a/lvgl_helpers.c +++ b/lvgl_helpers.c @@ -134,6 +134,39 @@ void lvgl_driver_init(void) #endif } +void display_bsp_init_io(void) +{ + esp_err_t err = ESP_OK; + gpio_config_t io_conf; + +#ifdef CONFIG_LV_DISPLAY_USE_DC + io_conf.mode = GPIO_MODE_OUTPUT; + io_conf.pin_bit_mask = (1ULL << CONFIG_LV_DISP_PIN_DC); + err = gpio_config(&io_conf); + ESP_ERROR_CHECK(err); +#endif + +#ifdef CONFIG_LV_DISP_USE_RST + io_conf.mode = GPIO_MODE_OUTPUT; + io_conf.pin_bit_mask = (1ULL << CONFIG_LV_DISP_PIN_RST); + err = gpio_config(&io_conf); + ESP_ERROR_CHECK(err); +#endif + +#ifndef CONFIG_LV_DISP_BACKLIGHT_OFF + io_conf.mode = GPIO_MODE_OUTPUT; + io_conf.pin_bit_mask = (1ULL << CONFIG_LV_DISP_PIN_BCKL); + err = gpio_config(&io_conf); + ESP_ERROR_CHECK(err); +#endif + +#ifdef CONFIG_LV_DISP_PIN_BUSY + io_conf.mode = GPIO_MODE_INPUT; + io_conf.pin_bit_mask = (1ULL << CONFIG_LV_DISP_PIN_BUSY); + err = gpio_config(&io_conf); + ESP_ERROR_CHECK(err); +#endif +} /* Initialize spi bus master * diff --git a/lvgl_helpers.h b/lvgl_helpers.h index 5fd6f09..439bd6b 100644 --- a/lvgl_helpers.h +++ b/lvgl_helpers.h @@ -98,6 +98,8 @@ void lvgl_driver_init(void); bool lvgl_spi_driver_init(int host, int miso_pin, int mosi_pin, int sclk_pin, int max_transfer_sz, int dma_channel, int quadwp_pin, int quadhd_pin); +/* Initialize display GPIOs, e.g. DC and RST pins */ +void display_bsp_init_io(void); /********************** * MACROS **********************/