|
SimpleKernel 1.17.0
|
NS16550A 串口驱动 More...
#include <ns16550a.hpp>

Public Member Functions | |
| auto | PutChar (uint8_t c) const -> void |
| 写入一个字符 | |
| auto | GetChar () const -> uint8_t |
| 阻塞式读取一个字符 | |
| auto | TryGetChar () const -> std::optional< uint8_t > |
| 非阻塞式尝试读取一个字符 | |
| auto | HasData () const -> bool |
| 检查接收缓冲区是否有数据可读(不消耗数据) | |
| auto | GetInterruptId () const -> uint8_t |
| 读取中断标识寄存器(ISR / IIR) | |
| auto | IsInterruptPending () const -> bool |
| 检查是否有中断挂起 | |
构造/析构函数 | |
| Ns16550a ()=default | |
| Ns16550a (const Ns16550a &)=delete | |
| Ns16550a (Ns16550a &&)=default | |
| auto | operator= (const Ns16550a &) -> Ns16550a &=delete |
| auto | operator= (Ns16550a &&) -> Ns16550a &=default |
| ~Ns16550a ()=default | |
Static Public Member Functions | |
| static auto | Create (uint64_t dev_addr) -> Expected< Ns16550a > |
| 工厂方法:创建并初始化 NS16550A 驱动 | |
Private Member Functions | |
| Ns16550a (uint64_t dev_addr) | |
Private Attributes | |
| MmioAccessor | mmio_ {} |
Static Private Attributes | |
| static constexpr uint8_t | kRegRHR = 0 |
| read mode: Receive holding reg | |
| static constexpr uint8_t | kRegTHR = 0 |
| write mode: Transmit Holding Reg | |
| static constexpr uint8_t | kRegIER = 1 |
| write mode: interrupt enable reg | |
| static constexpr uint8_t | kRegFCR = 2 |
| write mode: FIFO control Reg | |
| static constexpr uint8_t | kRegISR = 2 |
| read mode: Interrupt Status Reg | |
| static constexpr uint8_t | kRegLCR = 3 |
| write mode: Line Control Reg | |
| static constexpr uint8_t | kRegMCR = 4 |
| write mode: Modem Control Reg | |
| static constexpr uint8_t | kRegLSR = 5 |
| read mode: Line Status Reg | |
| static constexpr uint8_t | kRegMSR = 6 |
| read mode: Modem Status Reg | |
| static constexpr uint8_t | kUartDLL = 0 |
| LSB of divisor Latch when enabled. | |
| static constexpr uint8_t | kUartDLM = 1 |
| MSB of divisor Latch when enabled. | |
NS16550A 串口驱动
通过 MMIO 访问 NS16550A UART 寄存器,提供字符读写功能。 Header-only 实现,使用 MmioAccessor 进行寄存器访问。
使用工厂方法 Create() 构造,将验证与初始化分离。
Definition at line 23 of file ns16550a.hpp.
|
default |
|
delete |
|
default |
|
default |
|
inlineexplicitprivate |
Definition at line 150 of file ns16550a.hpp.
工厂方法:创建并初始化 NS16550A 驱动
| dev_addr | 设备 MMIO 基地址 |
Definition at line 30 of file ns16550a.hpp.

|
inline |
阻塞式读取一个字符
Definition at line 63 of file ns16550a.hpp.

|
inline |
读取中断标识寄存器(ISR / IIR)
返回值 bit[0]:0=有中断挂起,1=无中断挂起 返回值 bit[3:1]:中断源标识
Definition at line 101 of file ns16550a.hpp.

|
inline |
检查接收缓冲区是否有数据可读(不消耗数据)
Definition at line 84 of file ns16550a.hpp.

|
inline |
检查是否有中断挂起
Definition at line 109 of file ns16550a.hpp.

|
inline |
写入一个字符
| c | 待写入的字符 |
Definition at line 53 of file ns16550a.hpp.

|
inline |
|
staticconstexprprivate |
write mode: FIFO control Reg
Definition at line 131 of file ns16550a.hpp.
|
staticconstexprprivate |
write mode: interrupt enable reg
Definition at line 129 of file ns16550a.hpp.
|
staticconstexprprivate |
read mode: Interrupt Status Reg
Definition at line 133 of file ns16550a.hpp.
|
staticconstexprprivate |
write mode: Line Control Reg
Definition at line 135 of file ns16550a.hpp.
|
staticconstexprprivate |
read mode: Line Status Reg
Definition at line 139 of file ns16550a.hpp.
|
staticconstexprprivate |
write mode: Modem Control Reg
Definition at line 137 of file ns16550a.hpp.
|
staticconstexprprivate |
read mode: Modem Status Reg
Definition at line 141 of file ns16550a.hpp.
|
staticconstexprprivate |
read mode: Receive holding reg
Definition at line 125 of file ns16550a.hpp.
|
staticconstexprprivate |
write mode: Transmit Holding Reg
Definition at line 127 of file ns16550a.hpp.
|
staticconstexprprivate |
LSB of divisor Latch when enabled.
Definition at line 144 of file ns16550a.hpp.
|
staticconstexprprivate |
MSB of divisor Latch when enabled.
Definition at line 146 of file ns16550a.hpp.
|
private |
Definition at line 148 of file ns16550a.hpp.