Skip to content
Permalink
Browse files

display: ili9340: Add support of Seeed 2.8" TFT Touch Shield v2.0.

Add support of Seeed 2.8" TFT Touch Shield v2.0 to ILI9340 driver.
This driver supports color pixel formats of RGB888 and RGB565.

Signed-off-by: Bernard Lee <bernard.lee@nordicsemi.no>
  • Loading branch information...
leewkb4567 authored and nashif committed May 16, 2019
1 parent e934399 commit 0744adf417be66080a0db21e3b19a847bbdce016
@@ -11,6 +11,9 @@ zephyr_sources_ifdef(CONFIG_ILI9340 display_ili9340.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
)
zephyr_sources_ifdef(CONFIG_SSD1306 ssd1306.c)
zephyr_sources_ifdef(CONFIG_SSD1673 ssd1673.c)

@@ -23,6 +23,9 @@ choice
config ILI9340_LCD_ADAFRUIT_1480
bool "Adafruit 2.2\" TFT 1480"

config ILI9340_LCD_SEEED_TFTV2
bool "Seeed 2.8\" TFT v2.0"

endchoice

choice
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017 Jan Van Winkel <jan.van_winkel@dxplore.eu>
* Copyright (c) 2019 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -8,6 +9,7 @@

#include <zephyr.h>

#define ILI9340_CMD_SOFTWARE_RESET 0x01
#define ILI9340_CMD_ENTER_SLEEP 0x10
#define ILI9340_CMD_EXIT_SLEEP 0x11
#define ILI9340_CMD_GAMMA_SET 0x26
@@ -27,6 +29,15 @@
#define ILI9340_CMD_POSITVE_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_DATA_MEM_ACCESS_CTRL_MY 0x80
#define ILI9340_DATA_MEM_ACCESS_CTRL_MX 0x40
#define ILI9340_DATA_MEM_ACCESS_CTRL_MV 0x20
@@ -0,0 +1,174 @@
/*
* Copyright (c) 2018 - 2019 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <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
*/

void ili9340_lcd_init(struct ili9340_data *p_ili9340)
{
u8_t cmd;
u8_t data[15];

/* Software reset */
cmd = ILI9340_CMD_SOFTWARE_RESET;
ili9340_transmit(p_ili9340, cmd, NULL, 0);

k_sleep(5);

cmd = ILI9341_CMD_POWER_CTRL_B;
data[0] = 0x00U;
data[1] = 0x8BU;
data[2] = 0x30U;
ili9340_transmit(p_ili9340, cmd, data, 3);

cmd = ILI9341_CMD_POWER_ON_SEQ_CTRL;
data[0] = 0x67U;
data[1] = 0x03U;
data[2] = 0x12U;
data[3] = 0x81U;
ili9340_transmit(p_ili9340, cmd, data, 4);

cmd = ILI9341_CMD_DRVR_TIMING_CTRL_A_I;
data[0] = 0x85U;
data[1] = 0x10U;
data[2] = 0x7AU;
ili9340_transmit(p_ili9340, cmd, data, 3);

cmd = ILI9341_CMD_POWER_CTRL_A;
data[0] = 0x39U;
data[1] = 0x2CU;
data[2] = 0x00U;
data[3] = 0x34U;
data[4] = 0x02U;
ili9340_transmit(p_ili9340, cmd, data, 5);

cmd = ILI9341_CMD_PUMP_RATIO_CTRL;
data[0] = 0x20U;
ili9340_transmit(p_ili9340, cmd, data, 1);

cmd = ILI9341_CMD_DRVR_TIMING_CTRL_B;
data[0] = 0x00U;
data[1] = 0x00U;
ili9340_transmit(p_ili9340, cmd, data, 2);

/* Power control */
/* VRH[5:0] */
cmd = ILI9340_CMD_POWER_CTRL_1;
data[0] = 0x1BU;
ili9340_transmit(p_ili9340, cmd, data, 1);

/* Power control */
/* SAP[2:0];BT[3:0] */
cmd = ILI9340_CMD_POWER_CTRL_2;
data[0] = 0x10U;
ili9340_transmit(p_ili9340, cmd, data, 1);

/* VCM control */
cmd = ILI9340_CMD_VCOM_CTRL_1;
data[0] = 0x3FU;
data[1] = 0x3CU;
ili9340_transmit(p_ili9340, cmd, data, 2);

/* VCM control2 */
cmd = ILI9340_CMD_VCOM_CTRL_2;
data[0] = 0xB7U;
ili9340_transmit(p_ili9340, cmd, data, 1);

/* Memory Access Control */
cmd = ILI9340_CMD_MEM_ACCESS_CTRL;
data[0] = ILI9340_DATA_MEM_ACCESS_CTRL_MY |
ILI9340_DATA_MEM_ACCESS_CTRL_MV |
ILI9340_DATA_MEM_ACCESS_CTRL_ML |
ILI9340_DATA_MEM_ACCESS_CTRL_BGR;
ili9340_transmit(p_ili9340, cmd, data, 1);

/* Pixel Format Set */
cmd = ILI9340_CMD_PIXEL_FORMAT_SET;
#ifdef CONFIG_ILI9340_RGB565
data[0] = ILI9340_DATA_PIXEL_FORMAT_MCU_16_BIT |
ILI9340_DATA_PIXEL_FORMAT_RGB_16_BIT;
#else
data[0] = ILI9340_DATA_PIXEL_FORMAT_MCU_18_BIT |
ILI9340_DATA_PIXEL_FORMAT_RGB_18_BIT;
#endif
ili9340_transmit(p_ili9340, cmd, data, 1);

/* Frame Rate */
cmd = ILI9340_CMD_FRAME_CTRL_NORMAL_MODE;
data[0] = 0x00U;
data[1] = 0x1BU;
ili9340_transmit(p_ili9340, cmd, data, 2);

/* Display Function Control */
cmd = ILI9340_CMD_DISPLAY_FUNCTION_CTRL;
data[0] = 0x0AU;
data[1] = 0xA2U;
ili9340_transmit(p_ili9340, cmd, data, 2);

/* 3Gamma Function Disable */
cmd = ILI9341_CMD_ENABLE_3G;
data[0] = 0x00U;
ili9340_transmit(p_ili9340, cmd, data, 1);

/* Gamma curve selected */
cmd = ILI9340_CMD_GAMMA_SET;
data[0] = 0x01U;
ili9340_transmit(p_ili9340, cmd, data, 1);

/* Positive Gamma Correction */
cmd = ILI9340_CMD_POSITVE_GAMMA_CORRECTION;
data[0] = 0x0FU;
data[1] = 0x2AU;
data[2] = 0x28U;
data[3] = 0x08U;
data[4] = 0x0EU;
data[5] = 0x08U;
data[6] = 0x54U;
data[7] = 0xA9U;
data[8] = 0x43U;
data[9] = 0x0AU;
data[10] = 0x0FU;
data[11] = 0x00U;
data[12] = 0x00U;
data[13] = 0x00U;
data[14] = 0x00U;
ili9340_transmit(p_ili9340, cmd, data, 15);

/* Negative Gamma Correction */
cmd = ILI9340_CMD_NEGATIVE_GAMMA_CORRECTION;
data[0] = 0x00U;
data[1] = 0x15U;
data[2] = 0x17U;
data[3] = 0x07U;
data[4] = 0x11U;
data[5] = 0x06U;
data[6] = 0x2BU;
data[7] = 0x56U;
data[8] = 0x3CU;
data[9] = 0x05U;
data[10] = 0x10U;
data[11] = 0x0FU;
data[12] = 0x3FU;
data[13] = 0x3FU;
data[14] = 0x0FU;
ili9340_transmit(p_ili9340, cmd, data, 15);

/* Sleep Out */
cmd = ILI9340_CMD_EXIT_SLEEP;
ili9340_transmit(p_ili9340, cmd, NULL, 0);

k_sleep(120);

/* Display Off */
cmd = ILI9340_CMD_DISPLAY_OFF;
ili9340_transmit(p_ili9340, cmd, NULL, 0);
}

0 comments on commit 0744adf

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