|
libxr
Embedded C++ framework for bare-metal, RTOS and Linux
|
支持 FIFO 和 GDMA 的 ESP UART 后端 / ESP UART backend with FIFO and GDMA. More...
#include <esp_uart.hpp>
Public Member Functions | |
| ESP32UART (uart_port_t uart_num, int tx_pin, int rx_pin, int rts_pin=PIN_NO_CHANGE, int cts_pin=PIN_NO_CHANGE, size_t rx_buffer_size=1024, size_t tx_buffer_size=512, uint32_t tx_queue_size=5, UART::Configuration config={115200, UART::Parity::NO_PARITY, 8, 1}, bool enable_dma=true) | |
| 构造并初始化 ESP UART / Construct and initialize an ESP UART. | |
| ErrorCode | SetConfig (UART::Configuration config, bool in_isr=false) override |
| 提交帧格式和波特率配置 / Submit framing and baud configuration. | |
| ErrorCode | SetLoopback (bool enable) |
| 切换 UART 内部环回模式 / Toggle UART internal loopback. | |
Public Member Functions inherited from LibXR::UART | |
| template<typename ReadPortType = ReadPort, typename WritePortType = WritePort> | |
| UART (ReadPortType *read_port, WritePortType *write_port) | |
| UART 构造函数 / UART constructor. | |
| template<typename OperationType , typename = std::enable_if_t<std::is_base_of_v< WriteOperation, std::decay_t<OperationType>>>> | |
| ErrorCode | Write (ConstRawData data, OperationType &&op, bool in_isr=false) |
| template<typename OperationType , typename = std::enable_if_t<std::is_base_of_v< ReadOperation, std::decay_t<OperationType>>>> | |
| ErrorCode | Read (RawData data, OperationType &&op, bool in_isr=false) |
Static Public Member Functions | |
| static void | WriteFun (WritePort &port, bool in_isr) |
WritePort 使用的队列驱动 TX 入口 / Queue-driven TX entry used by WritePort. | |
Static Public Attributes | |
| static constexpr int | PIN_NO_CHANGE |
| 保持引脚映射不变 / Keep pin mapping unchanged. | |
Friends | |
| class | ESP32UARTReadPort |
Additional Inherited Members | |
Public Types inherited from LibXR::UART | |
| enum class | Parity : uint8_t { NO_PARITY = 0 , EVEN = 1 , ODD = 2 } |
| 奇偶校验模式 / Parity mode More... | |
Public Attributes inherited from LibXR::UART | |
| ReadPort * | read_port_ |
| 读取端口 / Read port | |
| WritePort * | write_port_ |
| 写入端口 / Write port | |
支持 FIFO 和 GDMA 的 ESP UART 后端 / ESP UART backend with FIFO and GDMA.
FIFO 按硬件实际接收量消费 WriteQueue;GDMA 将完整请求复制到发送半区后完成请求, DMA 完成仅释放半区。接收通过 ReadQueue 发布,配置和中断进展由同一处理器串行执行。 FIFO consumes actual accepted prefixes; GDMA completes requests after copying them into TX halves, with DMA completion only releasing storage. RX uses ReadQueue; one service serializes configuration and interrupt progress.
Definition at line 80 of file esp_uart.hpp.
| LibXR::ESP32UART::ESP32UART | ( | uart_port_t | uart_num, |
| int | tx_pin, | ||
| int | rx_pin, | ||
| int | rts_pin = PIN_NO_CHANGE, | ||
| int | cts_pin = PIN_NO_CHANGE, | ||
| size_t | rx_buffer_size = 1024, | ||
| size_t | tx_buffer_size = 512, | ||
| uint32_t | tx_queue_size = 5, | ||
| UART::Configuration | config = {115200, UART::Parity::NO_PARITY, 8, 1}, | ||
| bool | enable_dma = true ) |
构造并初始化 ESP UART / Construct and initialize an ESP UART.
| uart_num | UART 外设编号 / UART peripheral number. |
| tx_pin | 发送 GPIO / TX GPIO. |
| rx_pin | 接收 GPIO / RX GPIO. |
| rts_pin | RTS GPIO,PIN_NO_CHANGE 表示不修改 / RTS GPIO, or PIN_NO_CHANGE. |
| cts_pin | CTS GPIO,PIN_NO_CHANGE 表示不修改 / CTS GPIO, or PIN_NO_CHANGE. |
| rx_buffer_size | 接收软件队列容量 / RX software queue capacity. |
| tx_buffer_size | 发送软件队列和单个 DMA 半区容量 / TX queue and DMA half capacity. |
| tx_queue_size | 写请求队列容量,须大于零 / Positive write request capacity. |
| config | 初始帧格式和波特率 / Initial framing and baud rate. |
| enable_dma | 在芯片支持时使用 GDMA,否则使用 FIFO / Use GDMA if supported, else FIFO. |
Definition at line 146 of file esp_uart.cpp.
|
overridevirtual |
提交帧格式和波特率配置 / Submit framing and baud configuration.
| config | 目标配置 / Requested configuration. |
| in_isr | 当前是否在中断中 / Whether called in an ISR. |
Implements LibXR::UART.
Definition at line 226 of file esp_uart.cpp.
| ErrorCode LibXR::ESP32UART::SetLoopback | ( | bool | enable | ) |
切换 UART 内部环回模式 / Toggle UART internal loopback.
| enable | 是否启用 / Whether to enable loopback. |
Definition at line 460 of file esp_uart.cpp.
|
static |
WritePort 使用的队列驱动 TX 入口 / Queue-driven TX entry used by WritePort.
Definition at line 473 of file esp_uart.cpp.
|
friend |
Definition at line 82 of file esp_uart.hpp.
|
staticconstexpr |
保持引脚映射不变 / Keep pin mapping unchanged.
Definition at line 85 of file esp_uart.hpp.