From 5e49369a2c696531b223c23cf48a5e72115fc5be Mon Sep 17 00:00:00 2001 From: morris Date: Mon, 18 Apr 2022 18:30:47 +0800 Subject: [PATCH] lcd: spi lcd support transmit lsb first Closes https://github.com/espressif/esp-idf/issues/8790 --- components/esp_lcd/include/esp_lcd_panel_io.h | 3 ++- components/esp_lcd/src/esp_lcd_panel_io_spi.c | 3 ++- 2 files changed, 4 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 75daae34df..c35cb18cfb 100644 --- a/components/esp_lcd/include/esp_lcd_panel_io.h +++ b/components/esp_lcd/include/esp_lcd_panel_io.h @@ -98,7 +98,8 @@ typedef struct { unsigned int dc_as_cmd_phase: 1; /*!< D/C line value is encoded into SPI transaction command phase */ 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 */ - } flags; + unsigned int lsb_first: 1; /*!< transmit LSB bit first */ + } flags; /*!< Extra flags to fine-tune the SPI device */ } esp_lcd_panel_io_spi_config_t; /** 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 64f8db0730..71a2b6b86b 100644 --- a/components/esp_lcd/src/esp_lcd_panel_io_spi.c +++ b/components/esp_lcd/src/esp_lcd_panel_io_spi.c @@ -65,7 +65,8 @@ esp_err_t esp_lcd_new_panel_io_spi(esp_lcd_spi_bus_handle_t bus, const esp_lcd_p ESP_GOTO_ON_FALSE(spi_panel_io, ESP_ERR_NO_MEM, err, TAG, "no mem for spi panel io"); spi_device_interface_config_t devcfg = { - .flags = SPI_DEVICE_HALFDUPLEX, // only use TX path, so half duplex is enough + // currently the driver only supports TX path, so half duplex is enough + .flags = SPI_DEVICE_HALFDUPLEX | (io_config->flags.lsb_first ? SPI_DEVICE_TXBIT_LSBFIRST : 0), .clock_speed_hz = io_config->pclk_hz, .mode = io_config->spi_mode, .spics_io_num = io_config->cs_gpio_num,