drivers: display: ili9340: move frame rate control register to DT

Move FRMCTR1 register settings to DT.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
Gerard Marull-Paretas 2020-09-15 15:29:12 +02:00 committed by Maureen Helm
commit 6a76ae82c0
7 changed files with 19 additions and 16 deletions

View file

@ -19,6 +19,7 @@
cmd-data-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */ cmd-data-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */
pixel-format = <ILI9340_PIXEL_FORMAT_RGB888>; pixel-format = <ILI9340_PIXEL_FORMAT_RGB888>;
rotation = <90>; rotation = <90>;
frmctr1 = [00 18];
pwctrl1 = [23 00]; pwctrl1 = [23 00];
vmctrl1 = [3e 28]; vmctrl1 = [3e 28];
vmctrl2 = [86]; vmctrl2 = [86];

View file

@ -19,6 +19,7 @@
reset-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; /* D10 */ reset-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; /* D10 */
pixel-format = <ILI9340_PIXEL_FORMAT_RGB565>; pixel-format = <ILI9340_PIXEL_FORMAT_RGB565>;
rotation = <0>; rotation = <0>;
frmctr1 = [00 18];
pwctrl1 = [23 00]; pwctrl1 = [23 00];
vmctrl1 = [3e 28]; vmctrl1 = [3e 28];
vmctrl2 = [86]; vmctrl2 = [86];

View file

@ -37,6 +37,7 @@ struct ili9340_config {
uint8_t pixel_format; uint8_t pixel_format;
uint16_t rotation; uint16_t rotation;
uint8_t gamset[ILI9340_GAMSET_LEN]; uint8_t gamset[ILI9340_GAMSET_LEN];
uint8_t frmctr1[ILI9340_FRMCTR1_LEN];
uint8_t pwctrl1[ILI9340_PWCTRL1_LEN]; uint8_t pwctrl1[ILI9340_PWCTRL1_LEN];
uint8_t pwctrl2[ILI9340_PWCTRL2_LEN]; uint8_t pwctrl2[ILI9340_PWCTRL2_LEN];
uint8_t vmctrl1[ILI9340_VMCTRL1_LEN]; uint8_t vmctrl1[ILI9340_VMCTRL1_LEN];
@ -376,6 +377,14 @@ static int ili9340_configure(const struct device *dev)
return r; return r;
} }
LOG_HEXDUMP_DBG(config->frmctr1, ILI9340_FRMCTR1_LEN, "FRMCTR1");
memcpy(tx_data, config->frmctr1, ILI9340_FRMCTR1_LEN);
r = ili9340_transmit(dev, ILI9340_CMD_FRAME_CTRL_NORMAL_MODE, tx_data,
ILI9340_FRMCTR1_LEN);
if (r < 0) {
return r;
}
LOG_HEXDUMP_DBG(config->pwctrl1, ILI9340_PWCTRL1_LEN, "PWCTRL1"); LOG_HEXDUMP_DBG(config->pwctrl1, ILI9340_PWCTRL1_LEN, "PWCTRL1");
memcpy(tx_data, config->pwctrl1, ILI9340_PWCTRL1_LEN); memcpy(tx_data, config->pwctrl1, ILI9340_PWCTRL1_LEN);
r = ili9340_transmit(dev, ILI9340_CMD_POWER_CTRL_1, tx_data, r = ili9340_transmit(dev, ILI9340_CMD_POWER_CTRL_1, tx_data,
@ -543,6 +552,7 @@ static const struct display_driver_api ili9340_api = {
.pixel_format = DT_INST_PROP(index, pixel_format), \ .pixel_format = DT_INST_PROP(index, pixel_format), \
.rotation = DT_INST_PROP(index, rotation), \ .rotation = DT_INST_PROP(index, rotation), \
.gamset = DT_INST_PROP(index, gamset), \ .gamset = DT_INST_PROP(index, gamset), \
.frmctr1 = DT_INST_PROP(index, frmctr1), \
.pwctrl1 = DT_INST_PROP(index, pwctrl1), \ .pwctrl1 = DT_INST_PROP(index, pwctrl1), \
.pwctrl2 = DT_INST_PROP(index, pwctrl2), \ .pwctrl2 = DT_INST_PROP(index, pwctrl2), \
.vmctrl1 = DT_INST_PROP(index, vmctrl1), \ .vmctrl1 = DT_INST_PROP(index, vmctrl1), \

View file

@ -40,6 +40,7 @@
#define ILI9341_CMD_PUMP_RATIO_CTRL 0xF7 #define ILI9341_CMD_PUMP_RATIO_CTRL 0xF7
#define ILI9340_GAMSET_LEN 1U #define ILI9340_GAMSET_LEN 1U
#define ILI9340_FRMCTR1_LEN 2U
#define ILI9340_PWCTRL1_LEN 2U #define ILI9340_PWCTRL1_LEN 2U
#define ILI9340_PWCTRL2_LEN 1U #define ILI9340_PWCTRL2_LEN 1U
#define ILI9340_VMCTRL1_LEN 2U #define ILI9340_VMCTRL1_LEN 2U

View file

@ -11,13 +11,6 @@ int ili9340_lcd_init(const struct device *dev)
int r; int r;
uint8_t tx_data[15]; uint8_t tx_data[15];
tx_data[0] = 0x00;
tx_data[1] = 0x18;
r = ili9340_transmit(dev, ILI9340_CMD_FRAME_CTRL_NORMAL_MODE, tx_data, 2);
if (r < 0) {
return r;
}
tx_data[0] = 0x08; tx_data[0] = 0x08;
tx_data[1] = 0x82; tx_data[1] = 0x82;
tx_data[2] = 0x27; tx_data[2] = 0x27;

View file

@ -82,15 +82,6 @@ int ili9340_lcd_init(const struct device *dev)
return r; return r;
} }
/* Frame Rate */
cmd = ILI9340_CMD_FRAME_CTRL_NORMAL_MODE;
data[0] = 0x00U;
data[1] = 0x1BU;
r = ili9340_transmit(dev, cmd, data, 2);
if (r < 0) {
return r;
}
/* Display Function Control */ /* Display Function Control */
cmd = ILI9340_CMD_DISPLAY_FUNCTION_CTRL; cmd = ILI9340_CMD_DISPLAY_FUNCTION_CTRL;
data[0] = 0x0AU; data[0] = 0x0AU;

View file

@ -54,6 +54,12 @@ properties:
description: description:
Gamma set (GAMSET) register value. Gamma set (GAMSET) register value.
frmctr1:
type: uint8-array
default: [0x00, 0x1b]
description:
Frame rate control (in normal mode / full colors) (FRMCTR1) register value.
pwctrl1: pwctrl1:
type: uint8-array type: uint8-array
default: [0x26, 0x00] default: [0x26, 0x00]