diff --git a/boards/shields/st7789v_generic/st7789v_tl019fqv01.overlay b/boards/shields/st7789v_generic/st7789v_tl019fqv01.overlay index 78c3bca73ef..b869e6bde81 100644 --- a/boards/shields/st7789v_generic/st7789v_tl019fqv01.overlay +++ b/boards/shields/st7789v_generic/st7789v_tl019fqv01.overlay @@ -13,8 +13,8 @@ label = "ST7789V"; spi-max-frequency = <20000000>; reg = <0>; - cmd-data-gpios = <&arduino_header 15 0>; /* D9 */ - reset-gpios = <&arduino_header 14 0>; /* D8 */ + cmd-data-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */ + reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>; /* D8 */ width = <320>; height = <170>; x-offset = <0>; diff --git a/boards/shields/st7789v_generic/st7789v_waveshare_240x240.overlay b/boards/shields/st7789v_generic/st7789v_waveshare_240x240.overlay index cddeb0a0f35..756471070dd 100644 --- a/boards/shields/st7789v_generic/st7789v_waveshare_240x240.overlay +++ b/boards/shields/st7789v_generic/st7789v_waveshare_240x240.overlay @@ -14,8 +14,8 @@ label = "ST7789V"; spi-max-frequency = <20000000>; reg = <0>; - cmd-data-gpios = <&arduino_header 15 0>; /* D9 */ - reset-gpios = <&arduino_header 14 0>; /* D8 */ + cmd-data-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */ + reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>; /* D8 */ width = <240>; height = <240>; x-offset = <0>; diff --git a/drivers/display/display_st7789v.c b/drivers/display/display_st7789v.c index 980872c4cd1..bfd4cc25bc4 100644 --- a/drivers/display/display_st7789v.c +++ b/drivers/display/display_st7789v.c @@ -21,7 +21,9 @@ LOG_MODULE_REGISTER(display_st7789v); #define ST7789V_CS_PIN DT_INST_0_SITRONIX_ST7789V_CS_GPIOS_PIN #define ST7789V_CMD_DATA_PIN DT_INST_0_SITRONIX_ST7789V_CMD_DATA_GPIOS_PIN +#define ST7789V_CMD_DATA_FLAGS DT_INST_0_SITRONIX_ST7789V_CMD_DATA_GPIOS_FLAGS #define ST7789V_RESET_PIN DT_INST_0_SITRONIX_ST7789V_RESET_GPIOS_PIN +#define ST7789V_RESET_FLAGS DT_INST_0_SITRONIX_ST7789V_RESET_GPIOS_FLAGS static u8_t st7789v_porch_param[] = DT_INST_0_SITRONIX_ST7789V_PORCH_PARAM; static u8_t st7789v_cmd2en_param[] = DT_INST_0_SITRONIX_ST7789V_CMD2EN_PARAM; @@ -64,7 +66,7 @@ static void st7789v_set_lcd_margins(struct st7789v_data *data, static void st7789v_set_cmd(struct st7789v_data *data, int is_cmd) { - gpio_pin_write(data->cmd_data_gpio, ST7789V_CMD_DATA_PIN, !is_cmd); + gpio_pin_set(data->cmd_data_gpio, ST7789V_CMD_DATA_PIN, is_cmd); } static void st7789v_transmit(struct st7789v_data *data, u8_t cmd, @@ -73,13 +75,13 @@ static void st7789v_transmit(struct st7789v_data *data, u8_t cmd, struct spi_buf tx_buf = { .buf = &cmd, .len = 1 }; struct spi_buf_set tx_bufs = { .buffers = &tx_buf, .count = 1 }; - st7789v_set_cmd(data, true); + st7789v_set_cmd(data, 1); spi_write(data->spi_dev, &data->spi_config, &tx_bufs); if (tx_data != NULL) { tx_buf.buf = tx_data; tx_buf.len = tx_count; - st7789v_set_cmd(data, false); + st7789v_set_cmd(data, 0); spi_write(data->spi_dev, &data->spi_config, &tx_bufs); } } @@ -94,11 +96,10 @@ static void st7789v_reset_display(struct st7789v_data *data) { LOG_DBG("Resetting display"); #ifdef DT_INST_0_SITRONIX_ST7789V_RESET_GPIOS_CONTROLLER - gpio_pin_write(data->reset_gpio, ST7789V_RESET_PIN, 1); k_sleep(K_MSEC(1)); - gpio_pin_write(data->reset_gpio, ST7789V_RESET_PIN, 0); + gpio_pin_set(data->reset_gpio, ST7789V_RESET_PIN, 1); k_sleep(K_MSEC(6)); - gpio_pin_write(data->reset_gpio, ST7789V_RESET_PIN, 1); + gpio_pin_set(data->reset_gpio, ST7789V_RESET_PIN, 0); k_sleep(K_MSEC(20)); #else st7789v_transmit(p_st7789v, ST7789V_CMD_SW_RESET, NULL, 0); @@ -360,7 +361,7 @@ static int st7789v_init(struct device *dev) } if (gpio_pin_configure(data->reset_gpio, ST7789V_RESET_PIN, - GPIO_DIR_OUT)) { + GPIO_OUTPUT_INACTIVE | ST7789V_RESET_FLAGS)) { LOG_ERR("Couldn't configure reset pin"); return -EIO; } @@ -373,7 +374,7 @@ static int st7789v_init(struct device *dev) return -EPERM; } if (gpio_pin_configure(data->cmd_data_gpio, ST7789V_CMD_DATA_PIN, - GPIO_DIR_OUT)) { + GPIO_OUTPUT | ST7789V_CMD_DATA_FLAGS)) { LOG_ERR("Couldn't configure cmd/DATA pin"); return -EIO; } diff --git a/dts/bindings/display/sitronix,st7789v.yaml b/dts/bindings/display/sitronix,st7789v.yaml index 290f9670e59..0ed836ce9f4 100644 --- a/dts/bindings/display/sitronix,st7789v.yaml +++ b/dts/bindings/display/sitronix,st7789v.yaml @@ -12,10 +12,20 @@ properties: reset-gpios: type: phandle-array required: true + description: RESET pin. + + The RESET pin of ST7789V is active low. + If connected directly the MCU pin should be configured + as active low. cmd-data-gpios: type: phandle-array required: true + description: D/CX pin. + + The D/CX pin of ST7789V is active low (transmission command byte). + If connected directly the MCU pin should be configured + as active low. height: type: int