5#ifdef HAL_UART_MODULE_ENABLED
11#include "latest_snapshot.hpp"
12#include "libxr_def.hpp"
13#include "libxr_rw.hpp"
14#include "model/uart_circular_dma_rx_model.hpp"
15#include "model/uart_dma_tx_model.hpp"
16#include "model/uart_rx_config_gate.hpp"
17#include "stm32_dcache.hpp"
113stm32_uart_id_t stm32_uart_get_id(USART_TypeDef* addr);
142 uint32_t tx_queue_size = 5);
147 void OnRxDataAvailable(
bool in_isr);
157 UART_HandleTypeDef* uart_handle_;
159 stm32_uart_id_t id_ = STM32_UART_ID_ERROR;
161 static STM32UART* map[STM32_UART_NUMBER];
164 void OnConfigRequested() { rx_config_gate_.RequestConfig(); }
165 bool ApplyPendingConfig(
bool in_isr);
166 bool OnConfigApplied(
bool)
168 rx_config_gate_.LeaveConfig();
180 uart_handle_->hdmarx->Init.Mode = DMA_CIRCULAR;
181 HAL_DMA_Init(uart_handle_->hdmarx);
182 HAL_UARTEx_ReceiveToIdle_DMA(uart_handle_, data, size);
191 return __HAL_DMA_GET_COUNTER(uart_handle_->hdmarx);
213 bool StartDmaTx(uint8_t* data,
size_t size,
int block);
SPSC mailbox retaining only the latest fully published value.
可写原始数据视图 / Mutable raw data view
ReadPort class for handling read operations.
STM32 UART 驱动实现 / STM32 UART driver implementation.
void StartCircularDmaRx(uint8_t *data, size_t size)
通过 STM32 HAL 配置并启动 UART 循环 RX DMA / Configure and start circular UART RX DMA through STM32 HAL
void PrepareCircularDmaRxForCpu(uint8_t *data, size_t size)
使循环 DMA RX 数据对 CPU 可见 / Make circular DMA RX data visible to the CPU
bool StartDmaTx(uint8_t *data, size_t size, int block)
通过 STM32 HAL 启动一个 active UART TX DMA 载荷 / Start one active UART TX DMA payload through STM32 HAL
STM32UART(UART_HandleTypeDef *uart_handle, RawData dma_buff_rx, RawData dma_buff_tx, uint32_t tx_queue_size=5)
构造 UART 对象 / Construct UART object
ErrorCode SetConfig(UART::Configuration config)
设置 UART 配置 / Sets the UART configuration
size_t GetCircularDmaRxRemaining() const
获取 STM32 RX DMA 剩余传输计数 / Get the STM32 RX DMA remaining count
通用异步收发传输(UART)基类 / Abstract base class for Universal Asynchronous Receiver-Transmitter (UART)
UART 基于位置的循环 DMA 接收模型 / Position-based circular DMA RX model for UART.
UART 单次 DMA 发送执行模型 / UART one-shot DMA TX execution model.
Serialize UART RX hardware callbacks against configuration / 串行化 UART RX 硬件回调与配置事务
WritePort class for handling write operations.
void STM32_InvalidateDCacheByAddr(const void *addr, size_t size)
Invalidates D-Cache lines covering the specified memory range.
ErrorCode(* ReadFun)(ReadPort &port, bool in_isr)
Function pointer type for read notifications.
ErrorCode(* WriteFun)(WritePort &port, bool in_isr)
Function pointer type for write operations.
UART 配置结构体 / UART configuration structure.