pub struct PL011<UART> {
pub regs: UART,
/* private fields */
}
Expand description
Struct representing the actual driver.
Notice that there are no silly ideas like setting the baud rate, or assigning GPIO pins to the driver: the qemu implementation doesnt need any of that, we can just write to the registers directly.
Implements embedded_hal::serial as well as core::fmt::Write
§Examples
use pl011_qemu;
// build a driver for UART1
let mut uart = pl011_qemu::PL011::new(pl011_qemu::UART1::take().unwrap());
Fields§
§regs: UART
owned copy of the underlying uart registers.
Since they are moved into this struct, no one else can access them after the driver is initialized
Implementations§
Source§impl<T> PL011<T>where
T: ConstRegBlockPtr<PL011_Regs>,
impl<T> PL011<T>where
T: ConstRegBlockPtr<PL011_Regs>,
Sourcepub fn split(self) -> (Tx<T>, Rx<T>)
pub fn split(self) -> (Tx<T>, Rx<T>)
splits a single PL011 uart object into separate Rx and Tx streams.
Useful when you want to separate the two different halves of the UART and use them in different parts of the application
Note that the Rx and Tx structs do not contain a reference to the underlying UART, this is because once you split the UART in half, it is no longer possible to interact with the uart hardware directly, since the other half (rx or tx) might be using it at the same time.
Sourcepub fn write_byte(&self, data: u8)
pub fn write_byte(&self, data: u8)
writes a single byte out the uart
spins until space is available in the fifo