5#ifdef HAL_UART_MODULE_ENABLED
11#include "libxr_def.hpp"
12#include "libxr_rw.hpp"
108stm32_uart_id_t STM32_UART_GetID(USART_TypeDef *addr);
121 if (
port.queue_info_->Peek(
info) != ErrorCode::OK)
123 return ErrorCode::EMPTY;
126 if (
port.queue_data_->PopBatch(
131 return ErrorCode::EMPTY;
140 info.op.UpdateStatus(
false, ErrorCode::FAILED);
141 return ErrorCode::FAILED;
143 info.op.MarkAsRunning();
149 return ErrorCode::OK;
158 if (
port.queue_block_->Peek(
block) != ErrorCode::OK)
160 return ErrorCode::EMPTY;
165 if (
port.queue_data_->Size() >=
block.data_.size_)
168 port.queue_block_->Pop();
170 block.op_.UpdateStatus(
false, ErrorCode::OK);
171 return ErrorCode::OK;
175 return ErrorCode::EMPTY;
185 id_(STM32_UART_GetID(uart_handle_->Instance))
187 ASSERT(id_ != STM32_UART_ID_ERROR);
193 ASSERT(uart_handle_->hdmatx !=
NULL);
210 uart_handle_->Init.BaudRate =
config.baudrate;
244 return ErrorCode::INIT_ERR;
246 return ErrorCode::OK;
249 RawData dma_buff_rx_, dma_buff_tx_;
253 stm32_uart_id_t id_ = STM32_UART_ID_ERROR;
255 static STM32UART *map[STM32_UART_NUMBER];
void MarkAsRunning()
标记操作为运行状态。 Marks the operation as running.
原始数据封装类。 A class for encapsulating raw data.
size_t size_
数据大小(字节)。 The size of the data (in bytes).
void * addr_
数据存储地址。 The storage address of the data.
Read information block structure.
ReadOperation op_
Read operation instance. 读取操作实例。
ReadPort class for handling read operations.
ErrorCode SetConfig(UART::Configuration config)
设置 UART 配置 / Sets the UART configuration
通用异步收发传输(UART)基类 / Abstract base class for Universal Asynchronous Receiver-Transmitter (UART)
@ NO_PARITY
无校验 / No parity
WritePort write_port_
写入端口 / Write port
ReadPort read_port_
读取端口 / Read port
WritePort class for handling write operations.
LibXR Color Control Library / LibXR终端颜色控制库
ErrorCode(* ReadFun)(ReadPort &port)
Function pointer type for read operations.
ErrorCode(* WriteFun)(WritePort &port)
Function pointer type for write operations.
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值
UART 配置结构体 / UART configuration structure.