From 48ce2037bea832d88b5262ee176496e800c83097 Mon Sep 17 00:00:00 2001 From: Liu Zhongwei Date: Mon, 14 Nov 2022 16:33:36 +0800 Subject: [PATCH 1/3] esp_lcd: support serial interface-I mode for spi LCD --- components/esp_lcd/include/esp_lcd_panel_io.h | 1 + components/esp_lcd/src/esp_lcd_panel_io_spi.c | 1 + 2 files changed, 2 insertions(+) diff --git a/components/esp_lcd/include/esp_lcd_panel_io.h b/components/esp_lcd/include/esp_lcd_panel_io.h index 54a571221a..1a161c40fa 100644 --- a/components/esp_lcd/include/esp_lcd_panel_io.h +++ b/components/esp_lcd/include/esp_lcd_panel_io.h @@ -136,6 +136,7 @@ typedef struct { struct { unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ unsigned int octal_mode: 1; /*!< transmit with octal mode (8 data lines), this mode is used to simulate Intel 8080 timing */ + unsigned int interface_I_mode: 1; /*!< Read and write through a single data line (MOSI) */ unsigned int lsb_first: 1; /*!< transmit LSB bit first */ unsigned int cs_high_active: 1; /*!< CS line is high active */ } flags; /*!< Extra flags to fine-tune the SPI device */ diff --git a/components/esp_lcd/src/esp_lcd_panel_io_spi.c b/components/esp_lcd/src/esp_lcd_panel_io_spi.c index d1904d9330..51d3387243 100644 --- a/components/esp_lcd/src/esp_lcd_panel_io_spi.c +++ b/components/esp_lcd/src/esp_lcd_panel_io_spi.c @@ -73,6 +73,7 @@ esp_err_t esp_lcd_new_panel_io_spi(esp_lcd_spi_bus_handle_t bus, const esp_lcd_p spi_device_interface_config_t devcfg = { .flags = SPI_DEVICE_HALFDUPLEX | (io_config->flags.lsb_first ? SPI_DEVICE_TXBIT_LSBFIRST : 0) | + (io_config->flags.interface_I_mode ? SPI_DEVICE_3WIRE : 0) | (io_config->flags.cs_high_active ? SPI_DEVICE_POSITIVE_CS : 0), .clock_speed_hz = io_config->pclk_hz, .mode = io_config->spi_mode, From 4bdba8bdc60834b676daecca41f7add889162d15 Mon Sep 17 00:00:00 2001 From: Liu Zhongwei Date: Mon, 14 Nov 2022 17:29:24 +0800 Subject: [PATCH 2/3] esp_lcd: modify flag name --- components/esp_lcd/include/esp_lcd_panel_io.h | 2 +- components/esp_lcd/src/esp_lcd_panel_io_spi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esp_lcd/include/esp_lcd_panel_io.h b/components/esp_lcd/include/esp_lcd_panel_io.h index 1a161c40fa..c01fe3e441 100644 --- a/components/esp_lcd/include/esp_lcd_panel_io.h +++ b/components/esp_lcd/include/esp_lcd_panel_io.h @@ -136,7 +136,7 @@ typedef struct { struct { unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ unsigned int octal_mode: 1; /*!< transmit with octal mode (8 data lines), this mode is used to simulate Intel 8080 timing */ - unsigned int interface_I_mode: 1; /*!< Read and write through a single data line (MOSI) */ + unsigned int sio_mode: 1; /*!< Read and write through a single data line (MOSI) */ unsigned int lsb_first: 1; /*!< transmit LSB bit first */ unsigned int cs_high_active: 1; /*!< CS line is high active */ } flags; /*!< Extra flags to fine-tune the SPI device */ diff --git a/components/esp_lcd/src/esp_lcd_panel_io_spi.c b/components/esp_lcd/src/esp_lcd_panel_io_spi.c index 51d3387243..58194aa9bd 100644 --- a/components/esp_lcd/src/esp_lcd_panel_io_spi.c +++ b/components/esp_lcd/src/esp_lcd_panel_io_spi.c @@ -73,7 +73,7 @@ esp_err_t esp_lcd_new_panel_io_spi(esp_lcd_spi_bus_handle_t bus, const esp_lcd_p spi_device_interface_config_t devcfg = { .flags = SPI_DEVICE_HALFDUPLEX | (io_config->flags.lsb_first ? SPI_DEVICE_TXBIT_LSBFIRST : 0) | - (io_config->flags.interface_I_mode ? SPI_DEVICE_3WIRE : 0) | + (io_config->flags.sio_mode ? SPI_DEVICE_3WIRE : 0) | (io_config->flags.cs_high_active ? SPI_DEVICE_POSITIVE_CS : 0), .clock_speed_hz = io_config->pclk_hz, .mode = io_config->spi_mode, From 1a7cdc095b9d33d47a4718291755f65b294b5d93 Mon Sep 17 00:00:00 2001 From: Liu Zhongwei Date: Mon, 14 Nov 2022 17:55:27 +0800 Subject: [PATCH 3/3] esp_lcd: add condition for spi to keep cs low --- components/esp_lcd/src/esp_lcd_panel_io_spi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/esp_lcd/src/esp_lcd_panel_io_spi.c b/components/esp_lcd/src/esp_lcd_panel_io_spi.c index 58194aa9bd..3ff4754c67 100644 --- a/components/esp_lcd/src/esp_lcd_panel_io_spi.c +++ b/components/esp_lcd/src/esp_lcd_panel_io_spi.c @@ -209,7 +209,9 @@ static esp_err_t panel_io_spi_tx_param(esp_lcd_panel_io_t *io, int lcd_cmd, cons memset(lcd_trans, 0, sizeof(lcd_spi_trans_descriptor_t)); lcd_trans->base.user = spi_panel_io; - lcd_trans->base.flags |= SPI_TRANS_CS_KEEP_ACTIVE; + if (param && param_size) { + lcd_trans->base.flags |= SPI_TRANS_CS_KEEP_ACTIVE; + } if (spi_panel_io->flags.octal_mode) { // use 8 lines for transmitting command, address and data lcd_trans->base.flags |= (SPI_TRANS_MULTILINE_CMD | SPI_TRANS_MULTILINE_ADDR | SPI_TRANS_MODE_OCT);