Skip to main content

Pl011

Struct Pl011 

Source
pub struct Pl011 { /* private fields */ }
Expand description

PL011 UART 驱动结构体

Implementations§

Source§

impl Pl011

Source

pub fn new_no_clock(base: NonNull<u8>) -> Self

创建新的 PL011 实例(仅基地址,使用默认配置)

§Arguments
  • base - UART 寄存器基地址
Source

pub fn new(base: NonNull<u8>, clock_freq: u32) -> Self

Source

pub fn open(&mut self)

初始化 PL011 UART

Source

pub fn set_irq_mask(&mut self, mask: InterruptMask)

Source

pub fn get_irq_mask(&self) -> InterruptMask

Source

pub fn pending(&mut self, direction: SerialDirection) -> bool

Source

pub fn poll_status(&mut self) -> SerialEvent

Source

pub fn try_write(&mut self, bytes: &[u8]) -> usize

Source

pub fn try_read(&mut self, bytes: &mut [u8]) -> Result<usize, TransBytesError>

Source

pub fn handle_irq(&mut self) -> SerialEvent

Source

pub fn write_byte(&mut self, byte: u8)

Source

pub fn read_byte( &mut self, status: SerialEvent, ) -> Option<Result<u8, TransferError>>

Source

pub fn take_irq_snapshot(&mut self) -> IrqSnapshot

Source

pub fn read_rx(&mut self) -> Option<RxSample>

Source§

impl Pl011

Source

pub fn enable_fifo(&self, enable: bool)

启用或禁用 FIFO

Source

pub fn set_fifo_trigger_level(&self, rx_level: u8, tx_level: u8)

设置 FIFO 触发级别

Trait Implementations§

Source§

impl RawUart for Pl011

Source§

fn name(&self) -> &'static str

Source§

fn base_addr(&self) -> usize

Source§

fn clock_freq(&self) -> Option<NonZeroU32>

Source§

fn startup(&mut self, config: &Config) -> Result<(), ConfigError>

初始化 FIFO、控制寄存器和线路参数。 Read more
Source§

fn shutdown(&mut self)

关闭所有设备 IRQ 并停止端口。
Source§

fn set_config(&mut self, config: &Config) -> Result<(), ConfigError>

调整 baud/data bits/parity/stop bits。 Read more
Source§

fn baudrate(&self) -> u32

Source§

fn data_bits(&self) -> DataBits

Source§

fn stop_bits(&self) -> StopBits

Source§

fn parity(&self) -> Parity

Source§

fn enable_loopback(&mut self)

Source§

fn disable_loopback(&mut self)

Source§

fn is_loopback_enabled(&self) -> bool

Source§

fn set_irq_mask(&mut self, mask: InterruptMask)

写设备侧 IRQ mask。它只管理设备中断,不是同步原语。
Source§

fn take_irq_snapshot(&mut self) -> IrqSnapshot

读取并按硬件要求确认当前 IRQ source。
Source§

fn read_rx(&mut self) -> Option<RxSample>

从 RX FIFO 读取一个 sample;FIFO 空时返回 None。
Source§

fn tx_ready(&mut self) -> bool

硬件 TX FIFO 是否仍可接收一个字符。
Source§

fn write_tx(&mut self, byte: u8)

将一个字节写入硬件 TX FIFO。 Read more
Source§

fn tx_load_size(&self) -> usize

一轮 IRQ 建议写入的最大字节数。
Source§

fn tx_idle(&mut self) -> bool

FIFO 和 shift register 是否都已空。
Source§

fn poll_status(&mut self) -> SerialEvent

Read a raw hardware status snapshot. Read more
Source§

fn write_byte(&mut self, byte: u8)

Direct polling helper for early console users.
Source§

fn read_byte( &mut self, status: SerialEvent, ) -> Option<Result<u8, TransferError>>

Consume one byte/error according to caller-owned polling state.
Source§

fn ack_modem_status(&mut self)

Source§

fn ack_busy_detect(&mut self)

Auto Trait Implementations§

§

impl !RefUnwindSafe for Pl011

§

impl !UnwindSafe for Pl011

§

impl Freeze for Pl011

§

impl Send for Pl011

§

impl Sync for Pl011

§

impl Unpin for Pl011

§

impl UnsafeUnpin for Pl011

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.