pub struct Uart { /* private fields */ }Expand description
Driver for a PL011 UART.
Implementations§
Source§impl Uart
impl Uart
Sourcepub unsafe fn new(base_address: *mut u32) -> Self
pub unsafe fn new(base_address: *mut u32) -> Self
Constructs a new instance of the UART driver for a PL011 device at the given base address.
§Safety
The given base address must point to the 14 MMIO control registers of a PL011 device, which must be mapped into the address space of the process as device memory and not have any other aliases.
Sourcepub fn init(&mut self, clock: u32, baud_rate: u32)
pub fn init(&mut self, clock: u32, baud_rate: u32)
Initializes PL011 UART.
clock: Uart clock in Hz. baud_rate: Baud rate.
Sourcepub fn write_byte(&mut self, byte: u8)
pub fn write_byte(&mut self, byte: u8)
Writes a single byte to the UART.
This blocks until there is space in the transmit FIFO or holding register, but returns as soon as the byte has been written to the transmit FIFO or holding register. It doesn’t wait for the byte to be sent.
Sourcepub fn is_transmitting(&self) -> bool
pub fn is_transmitting(&self) -> bool
Returns whether the UART is currently transmitting data.
This will be true immediately after calling write_byte.
Trait Implementations§
Source§impl Read for Uart
impl Read for Uart
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
Read the exact number of bytes required to fill
buf. Read moreSource§impl Write for Uart
impl Write for Uart
Source§impl Write for Uart
impl Write for Uart
Source§fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
Write a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<(), Self::Error>
fn flush(&mut self) -> Result<(), Self::Error>
Flush this output stream, blocking until all intermediately buffered contents reach their destination.
Source§impl WriteReady for Uart
impl WriteReady for Uart
impl Send for Uart
impl Sync for Uart
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more