|
libxr
1.0
Want to be the best embedded framework
|
STM32 UART 驱动实现 / STM32 UART driver implementation. More...
#include <stm32_uart.hpp>
Public Member Functions | |
| 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 | |
| void | SetRxDMA () |
| void | OnRxDataAvailable (bool in_isr) |
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 ErrorCode | WriteFun (WritePort &port, bool in_isr) |
| static ErrorCode | ReadFun (ReadPort &port, bool in_isr) |
Data Fields | |
| ReadPort | _read_port |
| WritePort | _write_port |
| LatestSnapshot< UART::Configuration > | requested_config_ |
| UartRxConfigGate | rx_config_gate_ |
| UartCircularDmaRxModel | rx_dma_model_ |
| UartDmaTxModel< STM32UART > | tx_dma_model_ |
| UART_HandleTypeDef * | uart_handle_ |
| stm32_uart_id_t | id_ = STM32_UART_ID_ERROR |
Data Fields inherited from LibXR::UART | |
| ReadPort * | read_port_ |
| 读取端口 / Read port | |
| WritePort * | write_port_ |
| 写入端口 / Write port | |
Static Public Attributes | |
| static STM32UART * | map [STM32_UART_NUMBER] = {nullptr} |
Private Member Functions | |
| void | OnConfigRequested () |
| bool | ApplyPendingConfig (bool in_isr) |
| bool | OnConfigApplied (bool) |
| void | StartCircularDmaRx (uint8_t *data, size_t size) |
| 通过 STM32 HAL 配置并启动 UART 循环 RX DMA / Configure and start circular UART RX DMA through STM32 HAL | |
| size_t | GetCircularDmaRxRemaining () const |
| 获取 STM32 RX DMA 剩余传输计数 / Get the STM32 RX DMA remaining count | |
| 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 | |
Friends | |
| class | UartCircularDmaRxModel |
| class | UartDmaTxModel< STM32UART > |
Additional Inherited Members | |
Public Types inherited from LibXR::UART | |
| enum class | Parity : uint8_t { NO_PARITY = 0 , EVEN = 1 , ODD = 2 } |
| 奇偶校验模式 / Parity mode More... | |
STM32 UART 驱动实现 / STM32 UART driver implementation.
UartRxConfigGate. Definition at line 128 of file stm32_uart.hpp.
| STM32UART::STM32UART | ( | UART_HandleTypeDef * | uart_handle, |
| RawData | dma_buff_rx, | ||
| RawData | dma_buff_tx, | ||
| uint32_t | tx_queue_size = 5 ) |
构造 UART 对象 / Construct UART object
Definition at line 220 of file stm32_uart.cpp.
|
private |
Definition at line 261 of file stm32_uart.cpp.
|
inlinenodiscardprivate |
获取 STM32 RX DMA 剩余传输计数 / Get the STM32 RX DMA remaining count
Definition at line 189 of file stm32_uart.hpp.
|
inlineprivate |
Definition at line 166 of file stm32_uart.hpp.
|
inlineprivate |
Definition at line 164 of file stm32_uart.hpp.
| void STM32UART::OnRxDataAvailable | ( | bool | in_isr | ) |
Definition at line 334 of file stm32_uart.cpp.
|
inlineprivate |
使循环 DMA RX 数据对 CPU 可见 / Make circular DMA RX data visible to the CPU
| data | DMA 接收缓冲区起始地址 / DMA receive buffer start address |
| size | 接收缓冲区字节数 / Receive buffer capacity in bytes |
Definition at line 199 of file stm32_uart.hpp.
Definition at line 201 of file stm32_uart.cpp.
|
virtual |
设置 UART 配置 / Sets the UART configuration
ErrorCode::OK,否则返回相应错误码 / Returns the operation status, ErrorCode::OK if successful, otherwise an error code该方法为纯虚函数,子类必须实现具体的 UART 配置逻辑。 This is a pure virtual function. Subclasses must implement the specific UART configuration logic.
Implements LibXR::UART.
Definition at line 244 of file stm32_uart.cpp.
| void STM32UART::SetRxDMA | ( | ) |
Definition at line 316 of file stm32_uart.cpp.
|
inlineprivate |
通过 STM32 HAL 配置并启动 UART 循环 RX DMA / Configure and start circular UART RX DMA through STM32 HAL
| data | DMA 可写的接收缓冲区 / DMA-writable receive buffer |
| size | 接收缓冲区字节数 / Receive buffer capacity in bytes |
Definition at line 178 of file stm32_uart.hpp.
|
private |
通过 STM32 HAL 启动一个 active UART TX DMA 载荷 / Start one active UART TX DMA payload through STM32 HAL
| data | DMA 可读的载荷缓冲区 / DMA-readable payload buffer |
| size | 载荷字节数 / Payload size in bytes |
| block | active 双缓冲块索引,STM32 HAL 不使用 / Active double-buffer block index, unused by STM32 HAL |
Definition at line 377 of file stm32_uart.cpp.
Definition at line 195 of file stm32_uart.cpp.
|
friend |
Definition at line 130 of file stm32_uart.hpp.
|
friend |
Definition at line 130 of file stm32_uart.hpp.
| ReadPort LibXR::STM32UART::_read_port |
Definition at line 149 of file stm32_uart.hpp.
| WritePort LibXR::STM32UART::_write_port |
Definition at line 150 of file stm32_uart.hpp.
| stm32_uart_id_t LibXR::STM32UART::id_ = STM32_UART_ID_ERROR |
Definition at line 159 of file stm32_uart.hpp.
|
static |
Definition at line 161 of file stm32_uart.hpp.
| LatestSnapshot<UART::Configuration> LibXR::STM32UART::requested_config_ |
Definition at line 152 of file stm32_uart.hpp.
| UartRxConfigGate LibXR::STM32UART::rx_config_gate_ |
Definition at line 153 of file stm32_uart.hpp.
| UartCircularDmaRxModel LibXR::STM32UART::rx_dma_model_ |
Definition at line 154 of file stm32_uart.hpp.
| UartDmaTxModel<STM32UART> LibXR::STM32UART::tx_dma_model_ |
Definition at line 155 of file stm32_uart.hpp.
| UART_HandleTypeDef* LibXR::STM32UART::uart_handle_ |
Definition at line 157 of file stm32_uart.hpp.