Skip to content
Permalink
Browse files

display: ili9340: Make reset gpio definition optional.

ILI9340 may not need a reset signal pin for certain LCD shields.

Signed-off-by: Bernard Lee <bernard.lee@nordicsemi.no>
  • Loading branch information...
leewkb4567 authored and nashif committed Mar 6, 2019
1 parent 35ecdf8 commit 7ab3bc57b5d79138162855143affd0c09268a71d
Showing with 6 additions and 0 deletions.
  1. +6 −0 drivers/display/display_ili9340.c
@@ -17,7 +17,9 @@ LOG_MODULE_REGISTER(display_ili9340);
#include <string.h>

struct ili9340_data {
#ifdef DT_ILITEK_ILI9340_0_RESET_GPIOS_CONTROLLER
struct device *reset_gpio;
#endif
struct device *command_data_gpio;
struct device *spi_dev;
struct spi_config spi_config;
@@ -61,6 +63,7 @@ static int ili9340_init(struct device *dev)
data->spi_config.cs = NULL;
#endif

#ifdef DT_ILITEK_ILI9340_0_RESET_GPIOS_CONTROLLER
data->reset_gpio =
device_get_binding(DT_ILITEK_ILI9340_0_RESET_GPIOS_CONTROLLER);
if (data->reset_gpio == NULL) {
@@ -70,6 +73,7 @@ static int ili9340_init(struct device *dev)

gpio_pin_configure(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN,
GPIO_DIR_OUT);
#endif

data->command_data_gpio =
device_get_binding(DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_CONTROLLER);
@@ -81,13 +85,15 @@ static int ili9340_init(struct device *dev)
gpio_pin_configure(data->command_data_gpio, DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN,
GPIO_DIR_OUT);

#ifdef DT_ILITEK_ILI9340_0_RESET_GPIOS_CONTROLLER
LOG_DBG("Resetting display driver");
gpio_pin_write(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 1);
k_sleep(1);
gpio_pin_write(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 0);
k_sleep(1);
gpio_pin_write(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 1);
k_sleep(5);
#endif

LOG_DBG("Initializing LCD");
ili9340_lcd_init(data);

0 comments on commit 7ab3bc5

Please sign in to comment.
You can’t perform that action at this time.