drivers: ili9340: convert to new GPIO API
Convert ILI9340 display driver to new GPIO API. Signed-off-by: Johann Fischer <j.fischer@phytec.de>
This commit is contained in:
parent
c671b75e13
commit
64f5e23b47
2 changed files with 17 additions and 13 deletions
|
@ -14,6 +14,6 @@
|
|||
label = "ILI9340";
|
||||
spi-max-frequency = <15151515>;
|
||||
reg = <0>;
|
||||
cmd-data-gpios = <&arduino_header 15 0>; /* D9 */
|
||||
cmd-data-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */
|
||||
};
|
||||
};
|
||||
|
|
|
@ -29,8 +29,8 @@ struct ili9340_data {
|
|||
#endif
|
||||
};
|
||||
|
||||
#define ILI9340_CMD_DATA_PIN_COMMAND 0
|
||||
#define ILI9340_CMD_DATA_PIN_DATA 1
|
||||
#define ILI9340_CMD_DATA_PIN_COMMAND 1
|
||||
#define ILI9340_CMD_DATA_PIN_DATA 0
|
||||
|
||||
/* The number of bytes taken by a RGB pixel */
|
||||
#ifdef CONFIG_ILI9340_RGB565
|
||||
|
@ -80,7 +80,8 @@ static int ili9340_init(struct device *dev)
|
|||
}
|
||||
|
||||
gpio_pin_configure(data->reset_gpio, DT_INST_0_ILITEK_ILI9340_RESET_GPIOS_PIN,
|
||||
GPIO_DIR_OUT);
|
||||
GPIO_OUTPUT_INACTIVE |
|
||||
DT_INST_0_ILITEK_ILI9340_RESET_GPIOS_FLAGS);
|
||||
#endif
|
||||
|
||||
data->command_data_gpio =
|
||||
|
@ -91,15 +92,17 @@ static int ili9340_init(struct device *dev)
|
|||
}
|
||||
|
||||
gpio_pin_configure(data->command_data_gpio, DT_INST_0_ILITEK_ILI9340_CMD_DATA_GPIOS_PIN,
|
||||
GPIO_DIR_OUT);
|
||||
GPIO_OUTPUT |
|
||||
DT_INST_0_ILITEK_ILI9340_CMD_DATA_GPIOS_FLAGS);
|
||||
|
||||
#ifdef DT_INST_0_ILITEK_ILI9340_RESET_GPIOS_CONTROLLER
|
||||
LOG_DBG("Resetting display driver");
|
||||
gpio_pin_write(data->reset_gpio, DT_INST_0_ILITEK_ILI9340_RESET_GPIOS_PIN, 1);
|
||||
k_sleep(K_MSEC(1));
|
||||
gpio_pin_write(data->reset_gpio, DT_INST_0_ILITEK_ILI9340_RESET_GPIOS_PIN, 0);
|
||||
gpio_pin_set(data->reset_gpio,
|
||||
DT_INST_0_ILITEK_ILI9340_RESET_GPIOS_PIN, 1);
|
||||
k_sleep(K_MSEC(1));
|
||||
gpio_pin_write(data->reset_gpio, DT_INST_0_ILITEK_ILI9340_RESET_GPIOS_PIN, 1);
|
||||
gpio_pin_set(data->reset_gpio,
|
||||
DT_INST_0_ILITEK_ILI9340_RESET_GPIOS_PIN, 0);
|
||||
k_sleep(K_MSEC(5));
|
||||
#endif
|
||||
|
||||
|
@ -266,16 +269,17 @@ void ili9340_transmit(struct ili9340_data *data, u8_t cmd, void *tx_data,
|
|||
struct spi_buf tx_buf = { .buf = &cmd, .len = 1 };
|
||||
struct spi_buf_set tx_bufs = { .buffers = &tx_buf, .count = 1 };
|
||||
|
||||
gpio_pin_write(data->command_data_gpio, DT_INST_0_ILITEK_ILI9340_CMD_DATA_GPIOS_PIN,
|
||||
ILI9340_CMD_DATA_PIN_COMMAND);
|
||||
gpio_pin_set(data->command_data_gpio,
|
||||
DT_INST_0_ILITEK_ILI9340_CMD_DATA_GPIOS_PIN,
|
||||
ILI9340_CMD_DATA_PIN_COMMAND);
|
||||
spi_write(data->spi_dev, &data->spi_config, &tx_bufs);
|
||||
|
||||
if (tx_data != NULL) {
|
||||
tx_buf.buf = tx_data;
|
||||
tx_buf.len = tx_len;
|
||||
gpio_pin_write(data->command_data_gpio,
|
||||
DT_INST_0_ILITEK_ILI9340_CMD_DATA_GPIOS_PIN,
|
||||
ILI9340_CMD_DATA_PIN_DATA);
|
||||
gpio_pin_set(data->command_data_gpio,
|
||||
DT_INST_0_ILITEK_ILI9340_CMD_DATA_GPIOS_PIN,
|
||||
ILI9340_CMD_DATA_PIN_DATA);
|
||||
spi_write(data->spi_dev, &data->spi_config, &tx_bufs);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue