esp-iot-solution组件详解:基于esp_lcd的ST77903 QSPI显示屏驱动实战esp-iot-solution Component Explained: ST77903 QSPI Display Driver in Practice with esp_lcd


AI free token/AI免费积分

esp-iot-solution组件详解:基于esp_lcd的ST77903 QSPI显示屏驱动实战

本文来源:http://www.lpqz.cn/news/65179
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。

_qspi_config_t各配置项含义、自定义初始化序列的方法、双任务流水线与 PSRAM 乒乓缓冲原理以及如何借助组件自带的测试用例完成硬件验证与性能调优。一、组件概览ST77903 QSPI 的定位ST77903 是一款常见于小尺寸屏如 400×400 圆屏的 TFT-LCD 控制器。与传统的“单线 SPI 并口”方案不同本组件在 esp_lcd 框架之上实现了QSPI 接口用更少的引脚获得更高的刷新带宽。LCD 控制器通信接口组件名ST77903QSPIesp_lcd_st77903_qspi从 CHANGELOG.md 可以看到该驱动的演进脉络v0.3.0 实现 ST77903 控制器驱动并支持 QSPI/RGB 双接口v0.4.0 起把 RGB 接口驱动移出、本仓库仅保留 QSPI 接口驱动v1.0.0 完成组件化与文档完善v2.0.0 兼容 ESP-IDF v6.0。当前

组件版本为2.0.0~1其 idf_component.yml 声明依赖idf 5.3与cmake_utilities。ST77903 的完整规格书与应用笔记见 README 中给出的两份官方 PDF 链接README.md 表格内建议在实际布线前仔细核对时序。二、QSPI 接口原理内部控制指令编码ST77903 的 QSPI 模式并非标准 SPI NOR Flash 的 QSPI 指令集而是通过8 位 command 24 位 addressparam的 SPI 帧结构来传输“内部指令”。在 esp_lcd_st77903_qspi.c 中定义了三种内部控制指令#define ST77903_INS_DATA (0xDE) // 写数据颜色/参数 #define ST77903_INS_READ (0xDD) // 读寄存器 #define ST77903_INS_CMD (0xD8

) // 写命令0xD8发送 LCD 命令如 0x36 MADCTL、0x3A COLMOD参数随后通过 DATA 指令写入0xDE发送颜色数据SPI 事务使用SPI_TRANS_MODE_QIO标志走四线模式0xDD读取 LCD 寄存器需开启enable_read_reg标志。此外该驱动还直接通过内部指令构造了行同步信号ST77903_CMD_HSYNC (0x60)与ST77903_CMD_VSYNC (0x61)用于在刷新任务中控制行/帧时序见下文双任务流水线一节。lcd_write_cmd()内部通过spi_device_queue_multi_trans()一次性入队整段 segment 事务并在命令间插入LCD_LINE_INTERVAL_MIN_US的间隔保证总线时序稳定。三、快速上手完整初始化流程README 给出的初始化代码是驱动使用的最小完整示例我们原样保留并逐段解析/

ly be called when the refresh task is not running ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true)); // This function can control the display on/off and the refresh task run/stop ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle)); // Start the refresh task初始化过程分为五步含义如下esp_lcd_new_panel_st77903_qspi()创建面板句柄。驱动在此完成 SPI 总线初始化spi_bus_initialize配置SPICOMMON_BUSFLAG_QUAD四线模式、写设备半双工、SPI_DEVICE

anel_disp_on_off(true)发送DISPOFF/DISPON0x28/0x29指令并控制刷新任务启停——关屏时先停任务再发指令开屏时先发指令再启动任务。esp_lcd_panel_init()真正启动刷新任务内部创建lcd_refresh任务并预装载事务池。提示如果开启了mirror_by_cmd上述esp_lcd_panel_mirror/disp_on_off/init的调用顺序不能颠倒否则驱动会因刷新任务已运行而拒绝镜像操作。四、核心配置结构详解所有 QSPI 相关配置都集中在st77903_qspi_config_t定义见 esp_lcd_st77903_qspi.h并通过st77903_vendor_config_t挂到标准esp_lcd_panel_dev_config_t.vendor_config字段。4.1 SPI 引脚与时钟qspi子结构字段默认值宏内说

明host_id由ST77903_QSPI_CONFIG_DEFAULT第一个参数传入SPI host如SPI2_HOSTwrite_pclk_hz40 MHzST77903_QSPI_WRITE_PCLK_HZ_DEFAULT写数据时钟频率read_pclk_hz1 MHzST77903_QSPI_READ_PCLK_HZ_DEFAULT读寄存器时钟频率通常远低于写时钟cs_io_num由宏传入片选引脚设为 -1 表示不使用sclk_io_num由宏传入时钟引脚SCK/SCLdata0_io_num~data3_io_num由宏传入四根数据线 D0(SDA)~D34.2 任务与缓冲task、fb_num、trans_pool字段默认值说明task.refresh_priority23刷新任务优先级ST77903_QSPI_REFRESH_TASK_PRIO_DEFAULTtask.ref

resh_size3×1024 字节刷新任务栈大小task.refresh_coretskNO_AFFINITY刷新任务绑核不限核task.load_priority/load_size/load_core23 / 3×1024 / 不限核“加载内存”任务PSRAM 拷贝到 bounce buffer的参数fb_num1全屏帧缓冲数量设 0 或 1 时驱动只分配一个帧缓冲trans_pool_size20单个事务池大小行数即一次连续入队的颜色行数trans_pool_num3事务池数量官方建议至少 2、最好 3用于乒乓流水从源码看trans_pool_size * trans_pool_num还会直接参与 SPI 总线max_transfer_sz的估算esp_lcd_st77903_qspi.c因此调大这两个参数时要注意总线 DMA 能力上限。4.3 标志位flags标志默认值含义fb_

in_psram1帧缓冲优先从 PSRAM 分配板上无 PSRAM 时自动回退到 SRAM源码中会检查esp_psram_is_initialized()skip_init_host0置 1 时驱动跳过 SPI 总线初始化由用户在外部提前完成enable_read_reg0置 1 时启用寄存器读取会额外创建一个半双工 3-wire 读设备enable_cal_fps0置 1 时刷新任务每 100 帧计算一次 FPS可通过esp_lcd_st77903_qspi_get_fps()获取ST77903_QSPI_CONFIG_DEFAULT(spi_host, cs, sck, d0, d1, d2, d3, fbs, h_res, v_res)宏会一次性填充上述所有字段其中fbs即帧缓冲数量、h_res/v_res为分辨率示例中 400×400 屏传1, 400, 400。五、自定义初始化序

列与冲突检测不同面板厂商的 ST77903 初始化序列可能不同。驱动默认使用内置的vendor_specific_init_default[]见 esp_lcd_st77903_qspi.c包含解锁命令0xF0→C3/96/A5、gamma 校正0xE0/0xE1 等、显示开关0x11 后跟 120ms 延时等。若需覆盖可通过st77903_lcd_init_cmd_t数组传入typedef struct { int cmd; /*! 具体 LCD 命令 */ const void *data; /*! 命令参数缓冲区 */ size_t data_bytes; /*! data 字节数 */ unsigned int delay_ms; /*! 该命令发送后的延时毫秒 */ } st77903_lcd_init_cmd_t;使用自定义序列时数组必须声明为static const并放在函数

esp-iot-solution Component Explained: ST77903 QSPI Display Driver in Practice with esp_lcd

本文来源:http://www.lpqz.cn/news/65179
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。

esp-iot-solution component explained: a practical guide to the ST77903 QSPI display driver based on esp_lcd. [Free download] esp-iot-solution — Espressif IoT Library: IoT device drivers, documentation, and solutions. Project URL: https://gitcode.com/GitHub_Trending/es/esp-iot-solution. This article takes a deep look at the esp_lcd_st77903_qspi component, built on Espressif’s official esp_lcd framework.

It covers the meaning of each field in the qspi_config_t structure, how to define a custom initialization sequence, the dual-task pipeline and PSRAM ping-pong buffer principle, and how to use the component’s own test cases for hardware verification and performance tuning. 1. Component overview: the role of ST77903 QSPI. The ST77903 is a TFT-LCD controller commonly found in small displays such as 400x400 round screens. Unlike traditional "single-line SPI plus parallel" schemes, this component implements a QSPI interface on top of the esp_lcd framework, achieving higher refresh bandwidth with fewer pins. Display controller: ST77903; interface: QSPI; component: esp_lcd_st77903_qspi. The CHANGELOG.md shows the driver’s evolution.

The component version is 2.0.0~1; its idf_component.yml declares dependencies on IDF 5.3 and cmake_utilities. The full ST77903 datasheet and application notes are linked as two official PDFs in the README, which also advises carefully checking timing before actual routing. 2. QSPI interface principles and internal command encoding. The ST77903’s QSPI mode is not the standard SPI NOR Flash QSPI command set; instead it transmits "internal commands" through an SPI frame structured as 8-bit command + 24-bit address/parameter.

In esp_lcd_st77903_qspi.c, three internal control instructions are defined: (0xDE) for writing data/color parameters, (0xDD) for reading registers, and (0xD8) for writing commands — 0xD8 sends LCD commands such as 0x36 MADCTL and 0x3A COLMOD, whose parameters are then written via the 0xDE DATA instruction; colors are sent as DATA via 0xDE. SPI transactions use the SPI_TRANS_MODE_QIO flag for four-wire mode, and reading LCD registers via 0xDD requires the enable_read_reg flag. The driver also constructs row-sync signals directly through internal commands — ST77903_CMD_HSYNC (0x60) and ST77903_CMD_VSYNC (0x61) — to control row/frame timing in the refresh task. lcd_write_cmd() internally uses spi_device_queue_multi_trans() to enqueue a whole segment of transactions at once, inserting LCD_LINE_INTERVAL_MIN_US gaps between commands to keep bus timing stable.

暂无评论,快来发表第一条评论吧!No comments yet. Be the first!

📮 需求咨询📮 Inquiry