|
libxr
1.0
Want to be the best embedded framework
|
CH32 UART 驱动实现 / CH32 UART driver implementation. More...
#include <ch32_uart.hpp>
Public Member Functions | |
| CH32UART (ch32_uart_id_t id, RawData dma_rx, RawData dma_tx, GPIO_TypeDef *tx_gpio_port, uint16_t tx_gpio_pin, GPIO_TypeDef *rx_gpio_port, uint16_t rx_gpio_pin, uint32_t pin_remap=0, uint32_t tx_queue_size=5, UART::Configuration config={115200, UART::Parity::NO_PARITY, 8, 1}) | |
| 构造 UART 对象 / Construct UART object | |
| ErrorCode | SetConfig (UART::Configuration config) |
| 设置 UART 配置 / Sets the UART configuration | |
| void | TxDmaIRQHandler () |
| void | RxDmaIRQHandler () |
| DMA中断处理函数 | |
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 | |
| ch32_uart_id_t | id_ |
| uint16_t | uart_mode_ |
| ReadPort | _read_port |
| WritePort | _write_port |
| RawData | dma_buff_rx_ |
| DoubleBuffer | dma_buff_tx_ |
| WriteInfoBlock | write_info_active_ |
| size_t | last_rx_pos_ = 0 |
| USART_TypeDef * | instance_ |
| DMA_Channel_TypeDef * | dma_rx_channel_ |
| DMA_Channel_TypeDef * | dma_tx_channel_ |
| Flag::Plain | in_tx_isr |
| Flag::Plain | tx_busy_ |
Data Fields inherited from LibXR::UART | |
| ReadPort * | read_port_ |
| 读取端口 / Read port | |
| WritePort * | write_port_ |
| 写入端口 / Write port | |
Static Public Attributes | |
| static CH32UART * | map_ [CH32_UART_NUMBER] = {nullptr} |
Additional Inherited Members | |
Public Types inherited from LibXR::UART | |
| enum class | Parity : uint8_t { NO_PARITY = 0 , EVEN = 1 , ODD = 2 } |
| 奇偶校验模式 / Parity mode More... | |
CH32 UART 驱动实现 / CH32 UART driver implementation.
Definition at line 18 of file ch32_uart.hpp.
| CH32UART::CH32UART | ( | ch32_uart_id_t | id, |
| RawData | dma_rx, | ||
| RawData | dma_tx, | ||
| GPIO_TypeDef * | tx_gpio_port, | ||
| uint16_t | tx_gpio_pin, | ||
| GPIO_TypeDef * | rx_gpio_port, | ||
| uint16_t | rx_gpio_pin, | ||
| uint32_t | pin_remap = 0, | ||
| uint32_t | tx_queue_size = 5, | ||
| UART::Configuration | config = {115200, UART::Parity::NO_PARITY, 8, 1} ) |
构造 UART 对象 / Construct UART object
Definition at line 15 of file ch32_uart.cpp.
|
static |
Definition at line 310 of file ch32_uart.cpp.
| void CH32UART::RxDmaIRQHandler | ( | ) |
DMA中断处理函数
如果DMA中断触发,且中断状态为半满或传输完成,清除中断标志, 并调用对应的中断处理函数
| [in] | id | UART的ID |
Definition at line 439 of file ch32_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 186 of file ch32_uart.cpp.
| void CH32UART::TxDmaIRQHandler | ( | ) |
Definition at line 418 of file ch32_uart.cpp.
|
static |
Definition at line 240 of file ch32_uart.cpp.
| ReadPort LibXR::CH32UART::_read_port |
Definition at line 40 of file ch32_uart.hpp.
| WritePort LibXR::CH32UART::_write_port |
Definition at line 41 of file ch32_uart.hpp.
| RawData LibXR::CH32UART::dma_buff_rx_ |
Definition at line 43 of file ch32_uart.hpp.
| DoubleBuffer LibXR::CH32UART::dma_buff_tx_ |
Definition at line 44 of file ch32_uart.hpp.
| DMA_Channel_TypeDef* LibXR::CH32UART::dma_rx_channel_ |
Definition at line 50 of file ch32_uart.hpp.
| DMA_Channel_TypeDef* LibXR::CH32UART::dma_tx_channel_ |
Definition at line 51 of file ch32_uart.hpp.
| ch32_uart_id_t LibXR::CH32UART::id_ |
Definition at line 37 of file ch32_uart.hpp.
| Flag::Plain LibXR::CH32UART::in_tx_isr |
Definition at line 53 of file ch32_uart.hpp.
| USART_TypeDef* LibXR::CH32UART::instance_ |
Definition at line 49 of file ch32_uart.hpp.
| size_t LibXR::CH32UART::last_rx_pos_ = 0 |
Definition at line 47 of file ch32_uart.hpp.
|
static |
Definition at line 55 of file ch32_uart.hpp.
| Flag::Plain LibXR::CH32UART::tx_busy_ |
Definition at line 53 of file ch32_uart.hpp.
| uint16_t LibXR::CH32UART::uart_mode_ |
Definition at line 38 of file ch32_uart.hpp.
| WriteInfoBlock LibXR::CH32UART::write_info_active_ |
Definition at line 45 of file ch32_uart.hpp.