Skip to content

Commit

Permalink
drivers: display: ili9340: remove old hardcoded configurations
Browse files Browse the repository at this point in the history
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 <gerard@teslabs.com>
  • Loading branch information
gmarull authored and MaureenHelm committed Sep 29, 2020
1 parent afc6366 commit cd68e58
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 208 deletions.
7 changes: 0 additions & 7 deletions drivers/display/CMakeLists.txt
Expand Up @@ -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
)
20 changes: 1 addition & 19 deletions drivers/display/Kconfig.ili9340
Expand Up @@ -3,26 +3,8 @@
# Copyright (c) 2017 Jan Van Winkel <jan.van_winkel@dxplore.eu>
# 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
76 changes: 35 additions & 41 deletions drivers/display/display_ili9340.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
34 changes: 0 additions & 34 deletions drivers/display/display_ili9340.h
Expand Up @@ -8,8 +8,6 @@
#ifndef ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_
#define ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_

#include <device.h>

#define ILI9340_CMD_SOFTWARE_RESET 0x01
#define ILI9340_CMD_ENTER_SLEEP 0x10
#define ILI9340_CMD_EXIT_SLEEP 0x11
Expand All @@ -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
Expand Down Expand Up @@ -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_ */
12 changes: 0 additions & 12 deletions drivers/display/display_ili9340_adafruit_1480.c

This file was deleted.

94 changes: 0 additions & 94 deletions drivers/display/display_ili9340_seeed_tftv2.c

This file was deleted.

1 change: 0 additions & 1 deletion 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
Expand Down

0 comments on commit cd68e58

Please sign in to comment.