mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 05:04:33 +02:00
refactor(spi_lcd): detect the bus mode automatically
This commit is contained in:
@@ -35,8 +35,8 @@ typedef struct {
|
||||
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 octal_mode: 1 __attribute__((deprecated("This bitfield is deprecated"))); /*!< Deprecated, driver will detect the bus mode automatically */
|
||||
unsigned int quad_mode: 1 __attribute__((deprecated("This bitfield is deprecated"))); /*!< Deprecated, driver will detect the bus mode automatically */
|
||||
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 */
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include "driver/spi_master.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_private/gpio.h"
|
||||
#include "esp_private/spi_common_internal.h"
|
||||
#include "hal/gpio_ll.h"
|
||||
#include "hal/gpio_hal.h"
|
||||
#include "esp_log.h"
|
||||
@@ -100,11 +101,17 @@ esp_err_t esp_lcd_new_panel_io_spi(esp_lcd_spi_bus_handle_t bus, const esp_lcd_p
|
||||
gpio_output_enable(io_config->dc_gpio_num);
|
||||
}
|
||||
|
||||
const spi_bus_attr_t* bus_attr = spi_bus_get_attr((spi_host_device_t)bus);
|
||||
uint32_t flags = bus_attr->bus_cfg.flags;
|
||||
if ((flags & SPICOMMON_BUSFLAG_QUAD) == SPICOMMON_BUSFLAG_QUAD) {
|
||||
spi_panel_io->flags.quad_mode = 1;
|
||||
} else if ((flags & SPICOMMON_BUSFLAG_OCTAL) == SPICOMMON_BUSFLAG_OCTAL) {
|
||||
spi_panel_io->flags.octal_mode = 1;
|
||||
}
|
||||
|
||||
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;
|
||||
spi_panel_io->user_ctx = io_config->user_ctx;
|
||||
spi_panel_io->lcd_cmd_bits = io_config->lcd_cmd_bits;
|
||||
|
@@ -66,7 +66,6 @@ void test_spi_lcd_common_initialize(esp_lcd_panel_io_handle_t *io_handle, esp_lc
|
||||
};
|
||||
#if SOC_SPI_SUPPORT_OCT
|
||||
if (oct_mode) {
|
||||
io_config.flags.octal_mode = 1;
|
||||
io_config.spi_mode = 3;
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user