libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::UART Class Referenceabstract

通用异步收发传输(UART)基类 / Abstract base class for Universal Asynchronous Receiver-Transmitter (UART) More...

#include <uart.hpp>

Inheritance diagram for LibXR::UART:
Collaboration diagram for LibXR::UART:

Data Structures

struct  Configuration
 UART 配置结构体 / UART configuration structure. More...
 

Public Types

enum class  Parity : uint8_t { NO_PARITY = 0 , EVEN = 1 , ODD = 2 }
 奇偶校验模式 / Parity mode More...
 

Public Member Functions

 UART (size_t rx_queue_size, size_t rx_buffer_size, size_t tx_queue_size, size_t tx_buffer_size)
 UART 构造函数 / UART constructor.
 
virtual ErrorCode SetConfig (Configuration config)=0
 设置 UART 配置 / Sets the UART configuration
 

Data Fields

ReadPort read_port_
 读取端口 / Read port
 
WritePort write_port_
 写入端口 / Write port
 

Detailed Description

通用异步收发传输(UART)基类 / Abstract base class for Universal Asynchronous Receiver-Transmitter (UART)

该类定义了 UART 设备的基本接口,包括配置和数据传输端口。 This class defines the basic interface for a UART device, including configuration and data transmission ports.

Definition at line 18 of file uart.hpp.

Member Enumeration Documentation

◆ Parity

奇偶校验模式 / Parity mode

指定 UART 传输时的奇偶校验模式。 Specifies the parity mode used in UART transmission.

Enumerator
NO_PARITY 

无校验 / No parity

EVEN 

偶校验 / Even parity

ODD 

奇校验 / Odd parity

Definition at line 28 of file uart.hpp.

29 {
30 NO_PARITY = 0,
31 EVEN = 1,
32 ODD = 2
33 };
@ NO_PARITY
无校验 / No parity
@ ODD
奇校验 / Odd parity
@ EVEN
偶校验 / Even parity

Constructor & Destructor Documentation

◆ UART()

LibXR::UART::UART ( size_t  rx_queue_size,
size_t  rx_buffer_size,
size_t  tx_queue_size,
size_t  tx_buffer_size 
)
inline

UART 构造函数 / UART constructor.

Parameters
rx_queue_size接收队列大小 / Receive queue size
rx_buffer_size接收缓冲区大小 / Receive buffer size
tx_queue_size发送队列大小 / Transmit queue size
tx_buffer_size发送缓冲区大小 / Transmit buffer size

该构造函数初始化 UART 的读取和写入端口。 This constructor initializes the read and write ports of the UART.

Definition at line 64 of file uart.hpp.

68 {
69 }
WritePort write_port_
写入端口 / Write port
Definition uart.hpp:52
ReadPort read_port_
读取端口 / Read port
Definition uart.hpp:51
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

Member Function Documentation

◆ SetConfig()

virtual ErrorCode LibXR::UART::SetConfig ( Configuration  config)
pure virtual

设置 UART 配置 / Sets the UART configuration

Parameters
configUART 配置信息 / UART configuration settings
Returns
返回操作状态,成功时返回 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.

Implemented in LibXR::STM32UART, LibXR::STM32VirtualUART, and LibXR::LinuxUART.

Field Documentation

◆ read_port_

ReadPort LibXR::UART::read_port_

读取端口 / Read port

Definition at line 51 of file uart.hpp.

◆ write_port_

WritePort LibXR::UART::write_port_

写入端口 / Write port

Definition at line 52 of file uart.hpp.


The documentation for this class was generated from the following file: