From cd68e5819f164362f582ae16067042bacf44e25d Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Tue, 15 Sep 2020 16:42:26 +0200 Subject: [PATCH] drivers: display: ili9340: remove old hardcoded configurations Remove Adafruit/Seeed TFT hardcoded settings. Note that undocumented ILI9340/1 settings have been removed (maybe Seeed is using another ILI variant?). Signed-off-by: Gerard Marull-Paretas --- drivers/display/CMakeLists.txt | 7 -- drivers/display/Kconfig.ili9340 | 20 +--- drivers/display/display_ili9340.c | 76 +++++++-------- drivers/display/display_ili9340.h | 34 ------- .../display/display_ili9340_adafruit_1480.c | 12 --- drivers/display/display_ili9340_seeed_tftv2.c | 94 ------------------- samples/display/lvgl/boards/hsdk.conf | 1 - 7 files changed, 36 insertions(+), 208 deletions(-) delete mode 100644 drivers/display/display_ili9340_adafruit_1480.c delete mode 100644 drivers/display/display_ili9340_seeed_tftv2.c diff --git a/drivers/display/CMakeLists.txt b/drivers/display/CMakeLists.txt index 9a6542c59f4a51..aeb8a6e2e1415e 100644 --- a/drivers/display/CMakeLists.txt +++ b/drivers/display/CMakeLists.txt @@ -15,10 +15,3 @@ zephyr_sources_ifdef(CONFIG_MICROBIT_DISPLAY mb_display.c mb_font.c ) -zephyr_sources_ifdef(CONFIG_ILI9340_LCD_ADAFRUIT_1480 - display_ili9340_adafruit_1480.c -) - -zephyr_sources_ifdef(CONFIG_ILI9340_LCD_SEEED_TFTV2 - display_ili9340_seeed_tftv2.c -) diff --git a/drivers/display/Kconfig.ili9340 b/drivers/display/Kconfig.ili9340 index 58cfe321e872df..87fbd62c10011b 100644 --- a/drivers/display/Kconfig.ili9340 +++ b/drivers/display/Kconfig.ili9340 @@ -3,26 +3,8 @@ # Copyright (c) 2017 Jan Van Winkel # SPDX-License-Identifier: Apache-2.0 -menuconfig ILI9340 +config ILI9340 bool "ILI9340 display driver" depends on SPI help Enable driver for ILI9340 display driver. - -if ILI9340 - -choice - prompt "LCD" - default ILI9340_LCD_ADAFRUIT_1480 - help - Specify the type of LCD connected to the ILI9340 display controller. - -config ILI9340_LCD_ADAFRUIT_1480 - bool "Adafruit 2.2\" TFT 1480" - -config ILI9340_LCD_SEEED_TFTV2 - bool "Seeed 2.8\" TFT v2.0" - -endchoice - -endif # ILI9340 diff --git a/drivers/display/display_ili9340.c b/drivers/display/display_ili9340.c index 520e729234ffce..3810c4df202d05 100644 --- a/drivers/display/display_ili9340.c +++ b/drivers/display/display_ili9340.c @@ -58,6 +58,41 @@ struct ili9340_data { enum display_orientation orientation; }; +static int ili9340_transmit(const struct device *dev, uint8_t cmd, + const void *tx_data, size_t tx_len) +{ + const struct ili9340_config *config = (struct ili9340_config *)dev->config; + struct ili9340_data *data = (struct ili9340_data *)dev->data; + + int r; + struct spi_buf tx_buf; + struct spi_buf_set tx_bufs = { .buffers = &tx_buf, .count = 1U }; + + /* send command */ + tx_buf.buf = &cmd; + tx_buf.len = 1U; + + gpio_pin_set(data->command_data_gpio, config->cmd_data_pin, ILI9340_CMD); + r = spi_write(data->spi_dev, &data->spi_config, &tx_bufs); + if (r < 0) { + return r; + } + + /* send data (if any) */ + if (tx_data != NULL) { + tx_buf.buf = (void *)tx_data; + tx_buf.len = tx_len; + + gpio_pin_set(data->command_data_gpio, config->cmd_data_pin, ILI9340_DATA); + r = spi_write(data->spi_dev, &data->spi_config, &tx_bufs); + if (r < 0) { + return r; + } + } + + return 0; +} + static int ili9340_exit_sleep(const struct device *dev) { int r; @@ -298,41 +333,6 @@ static void ili9340_get_capabilities(const struct device *dev, capabilities->current_orientation = data->orientation; } -int ili9340_transmit(const struct device *dev, uint8_t cmd, const void *tx_data, - size_t tx_len) -{ - const struct ili9340_config *config = (struct ili9340_config *)dev->config; - struct ili9340_data *data = (struct ili9340_data *)dev->data; - - int r; - struct spi_buf tx_buf; - struct spi_buf_set tx_bufs = { .buffers = &tx_buf, .count = 1U }; - - /* send command */ - tx_buf.buf = &cmd; - tx_buf.len = 1U; - - gpio_pin_set(data->command_data_gpio, config->cmd_data_pin, ILI9340_CMD); - r = spi_write(data->spi_dev, &data->spi_config, &tx_bufs); - if (r < 0) { - return r; - } - - /* send data (if any) */ - if (tx_data != NULL) { - tx_buf.buf = (void *)tx_data; - tx_buf.len = tx_len; - - gpio_pin_set(data->command_data_gpio, config->cmd_data_pin, ILI9340_DATA); - r = spi_write(data->spi_dev, &data->spi_config, &tx_bufs); - if (r < 0) { - return r; - } - } - - return 0; -} - static int ili9340_configure(const struct device *dev) { const struct ili9340_config *config = (struct ili9340_config *)dev->config; @@ -501,12 +501,6 @@ static int ili9340_init(const struct device *dev) return r; } - r = ili9340_lcd_init(dev); - if (r < 0) { - LOG_ERR("Could not initialize LCD (%d)", r); - return r; - } - r = ili9340_exit_sleep(dev); if (r < 0) { LOG_ERR("Could not exit sleep mode (%d)", r); diff --git a/drivers/display/display_ili9340.h b/drivers/display/display_ili9340.h index 2094e922115280..31609a1686da0b 100644 --- a/drivers/display/display_ili9340.h +++ b/drivers/display/display_ili9340.h @@ -8,8 +8,6 @@ #ifndef ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_ #define ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_ -#include - #define ILI9340_CMD_SOFTWARE_RESET 0x01 #define ILI9340_CMD_ENTER_SLEEP 0x10 #define ILI9340_CMD_EXIT_SLEEP 0x11 @@ -30,15 +28,6 @@ #define ILI9340_CMD_POSITIVE_GAMMA_CORRECTION 0xE0 #define ILI9340_CMD_NEGATIVE_GAMMA_CORRECTION 0xE1 -#define ILI9341_CMD_POWER_CTRL_A 0xCB -#define ILI9341_CMD_POWER_CTRL_B 0xCF -#define ILI9341_CMD_DRVR_TIMING_CTRL_A_I 0xE8 -#define ILI9341_CMD_DRVR_TIMING_CTRL_A_E 0xE9 -#define ILI9341_CMD_DRVR_TIMING_CTRL_B 0xEA -#define ILI9341_CMD_POWER_ON_SEQ_CTRL 0xED -#define ILI9341_CMD_ENABLE_3G 0xF2 -#define ILI9341_CMD_PUMP_RATIO_CTRL 0xF7 - #define ILI9340_GAMSET_LEN 1U #define ILI9340_FRMCTR1_LEN 2U #define ILI9340_DISCTRL_LEN 3U @@ -81,27 +70,4 @@ /** Y resolution (pixels). */ #define ILI9340_Y_RES 320U -/** - * Send data to ILI9340 display controller - * - * @param data Device data structure - * @param cmd Command to send to display controller - * @param tx_data Data to transmit to the display controller - * In case no data should be transmitted pass a NULL pointer - * @param tx_len Number of bytes in tx_data buffer - * - * @return 0 on success, errno otherwise. - */ -int ili9340_transmit(const struct device *dev, uint8_t cmd, const void *tx_data, - size_t tx_len); - -/** - * Perform LCD specific initialization - * - * @param data Device data structure - * - * @return 0 on success, errno otherwise. - */ -int ili9340_lcd_init(const struct device *dev); - #endif /* ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_ */ diff --git a/drivers/display/display_ili9340_adafruit_1480.c b/drivers/display/display_ili9340_adafruit_1480.c deleted file mode 100644 index 8327e1a25db7d2..00000000000000 --- a/drivers/display/display_ili9340_adafruit_1480.c +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2017 Jan Van Winkel - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "display_ili9340.h" - -int ili9340_lcd_init(const struct device *dev) -{ - return 0; -} diff --git a/drivers/display/display_ili9340_seeed_tftv2.c b/drivers/display/display_ili9340_seeed_tftv2.c deleted file mode 100644 index af960f0f582e1f..00000000000000 --- a/drivers/display/display_ili9340_seeed_tftv2.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2018 - 2019 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include "display_ili9340.h" - -/* - * Derived from Seeed 2.8 inch TFT Touch Shield v2.0 sample code. - * - * https://github.com/Seeed-Studio/TFT_Touch_Shield_V2 - */ - -int ili9340_lcd_init(const struct device *dev) -{ - int r; - uint8_t cmd; - uint8_t data[15]; - - /* Software reset */ - cmd = ILI9340_CMD_SOFTWARE_RESET; - r = ili9340_transmit(dev, cmd, NULL, 0); - if (r < 0) { - return r; - } - - k_sleep(K_MSEC(5)); - - cmd = ILI9341_CMD_POWER_CTRL_B; - data[0] = 0x00U; - data[1] = 0x8BU; - data[2] = 0x30U; - r = ili9340_transmit(dev, cmd, data, 3); - if (r < 0) { - return r; - } - - cmd = ILI9341_CMD_POWER_ON_SEQ_CTRL; - data[0] = 0x67U; - data[1] = 0x03U; - data[2] = 0x12U; - data[3] = 0x81U; - r = ili9340_transmit(dev, cmd, data, 4); - if (r < 0) { - return r; - } - - cmd = ILI9341_CMD_DRVR_TIMING_CTRL_A_I; - data[0] = 0x85U; - data[1] = 0x10U; - data[2] = 0x7AU; - r = ili9340_transmit(dev, cmd, data, 3); - if (r < 0) { - return r; - } - - cmd = ILI9341_CMD_POWER_CTRL_A; - data[0] = 0x39U; - data[1] = 0x2CU; - data[2] = 0x00U; - data[3] = 0x34U; - data[4] = 0x02U; - r = ili9340_transmit(dev, cmd, data, 5); - if (r < 0) { - return r; - } - - cmd = ILI9341_CMD_PUMP_RATIO_CTRL; - data[0] = 0x20U; - r = ili9340_transmit(dev, cmd, data, 1); - if (r < 0) { - return r; - } - - cmd = ILI9341_CMD_DRVR_TIMING_CTRL_B; - data[0] = 0x00U; - data[1] = 0x00U; - r = ili9340_transmit(dev, cmd, data, 2); - if (r < 0) { - return r; - } - - /* 3Gamma Function Disable */ - cmd = ILI9341_CMD_ENABLE_3G; - data[0] = 0x00U; - r = ili9340_transmit(dev, cmd, data, 1); - if (r < 0) { - return r; - } - - return 0; -} diff --git a/samples/display/lvgl/boards/hsdk.conf b/samples/display/lvgl/boards/hsdk.conf index 0e38e991b7f61e..1e49b646a8b500 100644 --- a/samples/display/lvgl/boards/hsdk.conf +++ b/samples/display/lvgl/boards/hsdk.conf @@ -1,5 +1,4 @@ CONFIG_ILI9340=y -CONFIG_ILI9340_LCD_SEEED_TFTV2=y CONFIG_LVGL=y CONFIG_LVGL_HOR_RES_MAX=320