mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'contrib/github_pr_12908' into 'master'
spi_lcd: add flag to control the DC level in cmd/param/data phase separately (GitHub PR) Closes IDFGH-11813 and IDFGH-9249 See merge request espressif/esp-idf!28208
This commit is contained in:
commit
a532a648b1
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -137,10 +137,12 @@ typedef struct {
|
||||
int lcd_cmd_bits; /*!< Bit-width of LCD command */
|
||||
int lcd_param_bits; /*!< Bit-width of LCD parameter */
|
||||
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 dc_high_on_cmd: 1; /*!< If enabled, DC level = 1 indicates command transfer */
|
||||
unsigned int dc_low_on_data: 1; /*!< If enabled, DC level = 0 indicates color data transfer */
|
||||
unsigned int dc_low_on_param: 1; /*!< If enabled, DC level = 0 indicates parameter transfer */
|
||||
unsigned int octal_mode: 1; /*!< transmit with octal mode (8 data lines), this mode is used to simulate Intel 8080 timing */
|
||||
unsigned int quad_mode: 1; /*!< transmit with quad mode (4 data lines), this mode is useful when transmitting LCD parameters (Only use one line for command) */
|
||||
unsigned int sio_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 */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -51,7 +51,9 @@ typedef struct {
|
||||
int lcd_cmd_bits; // Bit width of LCD command
|
||||
int lcd_param_bits; // Bit width of LCD parameter
|
||||
struct {
|
||||
unsigned int dc_data_level: 1; // Indicates the level of DC line when tranfering data
|
||||
unsigned int dc_cmd_level: 1; // Indicates the level of DC line when transferring command
|
||||
unsigned int dc_data_level: 1; // Indicates the level of DC line when transferring color data
|
||||
unsigned int dc_param_level: 1; // Indicates the level of DC line when transferring parameters
|
||||
unsigned int octal_mode: 1; // Indicates whether the transmitting is enabled with octal mode (8 data lines)
|
||||
unsigned int quad_mode: 1; // Indicates whether the transmitting is enabled with quad mode (4 data lines)
|
||||
} flags;
|
||||
@ -93,7 +95,9 @@ esp_err_t esp_lcd_new_panel_io_spi(esp_lcd_spi_bus_handle_t bus, const esp_lcd_p
|
||||
ESP_GOTO_ON_ERROR(gpio_config(&io_conf), err, TAG, "configure GPIO for D/C line failed");
|
||||
}
|
||||
|
||||
spi_panel_io->flags.dc_cmd_level = io_config->flags.dc_high_on_cmd;
|
||||
spi_panel_io->flags.dc_data_level = !io_config->flags.dc_low_on_data;
|
||||
spi_panel_io->flags.dc_param_level = !io_config->flags.dc_low_on_param;
|
||||
spi_panel_io->flags.octal_mode = io_config->flags.octal_mode;
|
||||
spi_panel_io->flags.quad_mode = io_config->flags.quad_mode;
|
||||
spi_panel_io->on_color_trans_done = io_config->on_color_trans_done;
|
||||
@ -224,7 +228,7 @@ static esp_err_t panel_io_spi_tx_param(esp_lcd_panel_io_t *io, int lcd_cmd, cons
|
||||
|
||||
if (send_cmd) {
|
||||
spi_lcd_prepare_cmd_buffer(spi_panel_io, &lcd_cmd);
|
||||
lcd_trans->flags.dc_gpio_level = !spi_panel_io->flags.dc_data_level; // set D/C line to command mode
|
||||
lcd_trans->flags.dc_gpio_level = spi_panel_io->flags.dc_cmd_level; // set D/C level in command phase
|
||||
lcd_trans->base.length = spi_panel_io->lcd_cmd_bits;
|
||||
lcd_trans->base.tx_buffer = &lcd_cmd;
|
||||
// command is short, using polling mode
|
||||
@ -234,7 +238,7 @@ static esp_err_t panel_io_spi_tx_param(esp_lcd_panel_io_t *io, int lcd_cmd, cons
|
||||
|
||||
if (param && param_size) {
|
||||
spi_lcd_prepare_param_buffer(spi_panel_io, param, param_size);
|
||||
lcd_trans->flags.dc_gpio_level = spi_panel_io->flags.dc_data_level; // set D/C line to data mode
|
||||
lcd_trans->flags.dc_gpio_level = spi_panel_io->flags.dc_param_level; // set D/C level in param phase
|
||||
lcd_trans->base.length = param_size * 8; // transaction length is in bits
|
||||
lcd_trans->base.tx_buffer = param;
|
||||
lcd_trans->base.flags &= ~SPI_TRANS_CS_KEEP_ACTIVE;
|
||||
@ -278,7 +282,7 @@ static esp_err_t panel_io_spi_rx_param(esp_lcd_panel_io_t *io, int lcd_cmd, void
|
||||
|
||||
if (send_cmd) {
|
||||
spi_lcd_prepare_cmd_buffer(spi_panel_io, &lcd_cmd);
|
||||
lcd_trans->flags.dc_gpio_level = !spi_panel_io->flags.dc_data_level; // set D/C line to command mode
|
||||
lcd_trans->flags.dc_gpio_level = spi_panel_io->flags.dc_cmd_level; // set D/C level in command phase
|
||||
lcd_trans->base.length = spi_panel_io->lcd_cmd_bits;
|
||||
lcd_trans->base.tx_buffer = &lcd_cmd;
|
||||
// command is short, using polling mode
|
||||
@ -287,7 +291,7 @@ static esp_err_t panel_io_spi_rx_param(esp_lcd_panel_io_t *io, int lcd_cmd, void
|
||||
}
|
||||
|
||||
if (param && param_size) {
|
||||
lcd_trans->flags.dc_gpio_level = spi_panel_io->flags.dc_data_level; // set D/C line to data mode
|
||||
lcd_trans->flags.dc_gpio_level = spi_panel_io->flags.dc_param_level; // set D/C level in param phase
|
||||
lcd_trans->base.length = 0;
|
||||
lcd_trans->base.tx_buffer = NULL;
|
||||
lcd_trans->base.rxlength = param_size * 8; // Read length in bits
|
||||
@ -327,7 +331,7 @@ static esp_err_t panel_io_spi_tx_color(esp_lcd_panel_io_t *io, int lcd_cmd, cons
|
||||
|
||||
spi_lcd_prepare_cmd_buffer(spi_panel_io, &lcd_cmd);
|
||||
lcd_trans->base.user = spi_panel_io;
|
||||
lcd_trans->flags.dc_gpio_level = !spi_panel_io->flags.dc_data_level; // set D/C line to command mode
|
||||
lcd_trans->flags.dc_gpio_level = spi_panel_io->flags.dc_cmd_level; // set D/C level in command phase
|
||||
lcd_trans->base.length = spi_panel_io->lcd_cmd_bits;
|
||||
lcd_trans->base.tx_buffer = &lcd_cmd;
|
||||
if (color && color_size) {
|
||||
@ -370,7 +374,7 @@ static esp_err_t panel_io_spi_tx_color(esp_lcd_panel_io_t *io, int lcd_cmd, cons
|
||||
}
|
||||
|
||||
lcd_trans->base.user = spi_panel_io;
|
||||
lcd_trans->flags.dc_gpio_level = spi_panel_io->flags.dc_data_level; // set D/C line to data mode
|
||||
lcd_trans->flags.dc_gpio_level = spi_panel_io->flags.dc_data_level; // set D/C level in data phase
|
||||
lcd_trans->base.length = chunk_size * 8; // transaction length is in bits
|
||||
lcd_trans->base.tx_buffer = color;
|
||||
if (spi_panel_io->flags.octal_mode) {
|
||||
|
Loading…
Reference in New Issue
Block a user