|
libxr
1.0
Want to be the best embedded framework
|
UART 基于位置的循环 DMA 接收模型 / Position-based circular DMA RX model for UART. More...
#include <uart_circular_dma_rx_model.hpp>
Public Member Functions | |
| UartCircularDmaRxModel (RawData storage) | |
| 使用平台提供的 DMA 存储区构造接收模型 / Construct the RX model with platform-provided DMA storage | |
| template<typename Backend > | |
| void | Start (Backend &backend) |
| 复位读取位置并启动循环 DMA / Reset the read position and start circular DMA | |
| template<typename Backend > | |
| void | OnDataAvailable (Backend &backend, ReadPort &port, bool in_isr) |
| 消费上次 DMA 事件后新产生的数据 / Consume bytes produced since the previous DMA event | |
| void | ResetPosition () |
| 将软件读取位置复位到 DMA 缓冲区起点 / Reset the software read position to the start of the DMA buffer | |
| uint8_t * | Buffer () const |
| 获取 DMA 可写缓冲区起始地址 / Get the DMA-writable buffer start address | |
| size_t | BufferSize () const |
| 获取循环 DMA 缓冲区容量 / Get the circular DMA buffer capacity | |
| size_t | LastPosition () const |
| 获取上次已消费的 DMA 写入位置 / Get the last consumed DMA write position | |
Private Attributes | |
| RawData | storage_ |
| size_t | last_position_ = 0U |
UART 基于位置的循环 DMA 接收模型 / Position-based circular DMA RX model for UART.
模型管理 DMA 存储区视图和软件读取位置。平台后端负责启动循环 DMA、返回剩余传输计数, 并在 CPU 读取前执行所需的缓存维护。 The model owns the DMA storage view and software read position. The platform backend starts circular DMA, reports the remaining transfer count, and performs any cache maintenance required before CPU access.
为保持现有 UART 行为,软件队列写满时仍推进读取位置,无法写入的数据会被丢弃。 To preserve existing UART behavior, the read position advances when the software queue is full, and bytes that cannot be queued are dropped.
OnDataAvailable() 修改读取位置并作为软件队列 producer。 Calls delivering RX events to one model instance must not overlap. When UART IDLE and RX DMA HT/TC use different interrupt sources, the platform driver must configure them with the same preemption priority and target-core affinity so only one OnDataAvailable() call can modify the read position and act as the software-queue producer at a time. Configuration on another core must use a separate hardware-state handoff such as UartRxConfigGate. Definition at line 35 of file uart_circular_dma_rx_model.hpp.
|
inlineexplicit |
使用平台提供的 DMA 存储区构造接收模型 / Construct the RX model with platform-provided DMA storage
| storage | DMA 可写的循环接收缓冲区 / DMA-writable circular receive buffer |
Definition at line 43 of file uart_circular_dma_rx_model.hpp.
|
inlinenodiscard |
获取 DMA 可写缓冲区起始地址 / Get the DMA-writable buffer start address
Definition at line 117 of file uart_circular_dma_rx_model.hpp.
|
inlinenodiscard |
获取循环 DMA 缓冲区容量 / Get the circular DMA buffer capacity
Definition at line 123 of file uart_circular_dma_rx_model.hpp.
|
inlinenodiscard |
获取上次已消费的 DMA 写入位置 / Get the last consumed DMA write position
Definition at line 129 of file uart_circular_dma_rx_model.hpp.
|
inline |
消费上次 DMA 事件后新产生的数据 / Consume bytes produced since the previous DMA event
| Backend | 静态绑定的平台后端类型 / Statically bound platform backend type |
| backend | 提供剩余计数和缓存维护操作的平台后端 / Platform backend providing remaining-count and cache-maintenance operations |
| port | 接收新增数据的读端口 / Read port receiving newly produced bytes |
| in_isr | 是否在中断上下文完成 pending 读取 / Whether pending reads are completed in interrupt context |
Definition at line 72 of file uart_circular_dma_rx_model.hpp.
|
inline |
将软件读取位置复位到 DMA 缓冲区起点 / Reset the software read position to the start of the DMA buffer
Definition at line 111 of file uart_circular_dma_rx_model.hpp.
|
inline |
复位读取位置并启动循环 DMA / Reset the read position and start circular DMA
| Backend | 静态绑定的平台后端类型 / Statically bound platform backend type |
| backend | 提供 StartCircularDmaRx() 的平台后端 / Platform backend providing StartCircularDmaRx() |
Definition at line 52 of file uart_circular_dma_rx_model.hpp.
|
private |
Definition at line 133 of file uart_circular_dma_rx_model.hpp.
|
private |
Definition at line 132 of file uart_circular_dma_rx_model.hpp.