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 <gerard@teslabs.com>
This commit is contained in:
parent
afc63664f2
commit
cd68e5819f
7 changed files with 36 additions and 208 deletions
|
@ -15,10 +15,3 @@ zephyr_sources_ifdef(CONFIG_MICROBIT_DISPLAY
|
||||||
mb_display.c
|
mb_display.c
|
||||||
mb_font.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
|
|
||||||
)
|
|
||||||
|
|
|
@ -3,26 +3,8 @@
|
||||||
# Copyright (c) 2017 Jan Van Winkel <jan.van_winkel@dxplore.eu>
|
# Copyright (c) 2017 Jan Van Winkel <jan.van_winkel@dxplore.eu>
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
menuconfig ILI9340
|
config ILI9340
|
||||||
bool "ILI9340 display driver"
|
bool "ILI9340 display driver"
|
||||||
depends on SPI
|
depends on SPI
|
||||||
help
|
help
|
||||||
Enable driver for ILI9340 display driver.
|
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
|
|
||||||
|
|
|
@ -58,6 +58,41 @@ struct ili9340_data {
|
||||||
enum display_orientation orientation;
|
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)
|
static int ili9340_exit_sleep(const struct device *dev)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
@ -298,41 +333,6 @@ static void ili9340_get_capabilities(const struct device *dev,
|
||||||
capabilities->current_orientation = data->orientation;
|
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)
|
static int ili9340_configure(const struct device *dev)
|
||||||
{
|
{
|
||||||
const struct ili9340_config *config = (struct ili9340_config *)dev->config;
|
const struct ili9340_config *config = (struct ili9340_config *)dev->config;
|
||||||
|
@ -501,12 +501,6 @@ static int ili9340_init(const struct device *dev)
|
||||||
return r;
|
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);
|
r = ili9340_exit_sleep(dev);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
LOG_ERR("Could not exit sleep mode (%d)", r);
|
LOG_ERR("Could not exit sleep mode (%d)", r);
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
#ifndef ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_
|
#ifndef ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_
|
||||||
#define 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_SOFTWARE_RESET 0x01
|
||||||
#define ILI9340_CMD_ENTER_SLEEP 0x10
|
#define ILI9340_CMD_ENTER_SLEEP 0x10
|
||||||
#define ILI9340_CMD_EXIT_SLEEP 0x11
|
#define ILI9340_CMD_EXIT_SLEEP 0x11
|
||||||
|
@ -30,15 +28,6 @@
|
||||||
#define ILI9340_CMD_POSITIVE_GAMMA_CORRECTION 0xE0
|
#define ILI9340_CMD_POSITIVE_GAMMA_CORRECTION 0xE0
|
||||||
#define ILI9340_CMD_NEGATIVE_GAMMA_CORRECTION 0xE1
|
#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_GAMSET_LEN 1U
|
||||||
#define ILI9340_FRMCTR1_LEN 2U
|
#define ILI9340_FRMCTR1_LEN 2U
|
||||||
#define ILI9340_DISCTRL_LEN 3U
|
#define ILI9340_DISCTRL_LEN 3U
|
||||||
|
@ -81,27 +70,4 @@
|
||||||
/** Y resolution (pixels). */
|
/** Y resolution (pixels). */
|
||||||
#define ILI9340_Y_RES 320U
|
#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_ */
|
#endif /* ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_ */
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Jan Van Winkel <jan.van_winkel@dxplore.eu>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "display_ili9340.h"
|
|
||||||
|
|
||||||
int ili9340_lcd_init(const struct device *dev)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,94 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2018 - 2019 Nordic Semiconductor ASA
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <drivers/display.h>
|
|
||||||
#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;
|
|
||||||
}
|
|
|
@ -1,5 +1,4 @@
|
||||||
CONFIG_ILI9340=y
|
CONFIG_ILI9340=y
|
||||||
CONFIG_ILI9340_LCD_SEEED_TFTV2=y
|
|
||||||
|
|
||||||
CONFIG_LVGL=y
|
CONFIG_LVGL=y
|
||||||
CONFIG_LVGL_HOR_RES_MAX=320
|
CONFIG_LVGL_HOR_RES_MAX=320
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue