drivers: display: ili9340: move VCOM parameters to DT

Move VCOM control 1/2 register values to DT.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
Gerard Marull-Paretas 2020-09-15 15:18:20 +02:00 committed by Maureen Helm
commit 4895620eb0
8 changed files with 40 additions and 30 deletions

View file

@ -39,6 +39,8 @@ struct ili9340_config {
uint8_t gamset[ILI9340_GAMSET_LEN];
uint8_t pwctrl1[ILI9340_PWCTRL1_LEN];
uint8_t pwctrl2[ILI9340_PWCTRL2_LEN];
uint8_t vmctrl1[ILI9340_VMCTRL1_LEN];
uint8_t vmctrl2[ILI9340_VMCTRL2_LEN];
uint8_t pgamctrl[ILI9340_PGAMCTRL_LEN];
uint8_t ngamctrl[ILI9340_NGAMCTRL_LEN];
};
@ -390,6 +392,22 @@ static int ili9340_configure(const struct device *dev)
return r;
}
LOG_HEXDUMP_DBG(config->vmctrl1, ILI9340_VMCTRL1_LEN, "VMCTRL1");
memcpy(tx_data, config->vmctrl1, ILI9340_VMCTRL1_LEN);
r = ili9340_transmit(dev, ILI9340_CMD_VCOM_CTRL_1, tx_data,
ILI9340_VMCTRL1_LEN);
if (r < 0) {
return r;
}
LOG_HEXDUMP_DBG(config->vmctrl2, ILI9340_VMCTRL2_LEN, "VMCTRL2");
memcpy(tx_data, config->vmctrl2, ILI9340_VMCTRL2_LEN);
r = ili9340_transmit(dev, ILI9340_CMD_VCOM_CTRL_2, tx_data,
ILI9340_VMCTRL2_LEN);
if (r < 0) {
return r;
}
LOG_HEXDUMP_DBG(config->pgamctrl, ILI9340_PGAMCTRL_LEN, "PGAMCTRL");
memcpy(tx_data, config->pgamctrl, ILI9340_PGAMCTRL_LEN);
r = ili9340_transmit(dev, ILI9340_CMD_POSITIVE_GAMMA_CORRECTION,
@ -527,6 +545,8 @@ static const struct display_driver_api ili9340_api = {
.gamset = DT_INST_PROP(index, gamset), \
.pwctrl1 = DT_INST_PROP(index, pwctrl1), \
.pwctrl2 = DT_INST_PROP(index, pwctrl2), \
.vmctrl1 = DT_INST_PROP(index, vmctrl1), \
.vmctrl2 = DT_INST_PROP(index, vmctrl2), \
.pgamctrl = DT_INST_PROP(index, pgamctrl), \
.ngamctrl = DT_INST_PROP(index, ngamctrl), \
}; \

View file

@ -42,6 +42,8 @@
#define ILI9340_GAMSET_LEN 1U
#define ILI9340_PWCTRL1_LEN 2U
#define ILI9340_PWCTRL2_LEN 1U
#define ILI9340_VMCTRL1_LEN 2U
#define ILI9340_VMCTRL2_LEN 1U
#define ILI9340_PGAMCTRL_LEN 15U
#define ILI9340_NGAMCTRL_LEN 15U

View file

@ -11,19 +11,6 @@ int ili9340_lcd_init(const struct device *dev)
int r;
uint8_t tx_data[15];
tx_data[0] = 0x3e;
tx_data[1] = 0x28;
r = ili9340_transmit(dev, ILI9340_CMD_VCOM_CTRL_1, tx_data, 2);
if (r < 0) {
return r;
}
tx_data[0] = 0x86;
r = ili9340_transmit(dev, ILI9340_CMD_VCOM_CTRL_2, tx_data, 1);
if (r < 0) {
return r;
}
tx_data[0] = 0x00;
tx_data[1] = 0x18;
r = ili9340_transmit(dev, ILI9340_CMD_FRAME_CTRL_NORMAL_MODE, tx_data, 2);

View file

@ -82,23 +82,6 @@ int ili9340_lcd_init(const struct device *dev)
return r;
}
/* VCM control */
cmd = ILI9340_CMD_VCOM_CTRL_1;
data[0] = 0x3FU;
data[1] = 0x3CU;
r = ili9340_transmit(dev, cmd, data, 2);
if (r < 0) {
return r;
}
/* VCM control2 */
cmd = ILI9340_CMD_VCOM_CTRL_2;
data[0] = 0xB7U;
r = ili9340_transmit(dev, cmd, data, 1);
if (r < 0) {
return r;
}
/* Frame Rate */
cmd = ILI9340_CMD_FRAME_CTRL_NORMAL_MODE;
data[0] = 0x00U;