pub struct BufferedUart<'d> { /* private fields */ }Expand description
Buffered UART driver.
Implementations§
Source§impl<'d> BufferedUart<'d>
impl<'d> BufferedUart<'d>
Sourcepub fn new<T: Instance>(
_uart: Peri<'d, T>,
tx: Peri<'d, impl TxPin<T>>,
rx: Peri<'d, impl RxPin<T>>,
_irq: impl Binding<T::Interrupt, BufferedInterruptHandler<T>>,
tx_buffer: &'d mut [u8],
rx_buffer: &'d mut [u8],
config: Config,
) -> Self
pub fn new<T: Instance>( _uart: Peri<'d, T>, tx: Peri<'d, impl TxPin<T>>, rx: Peri<'d, impl RxPin<T>>, _irq: impl Binding<T::Interrupt, BufferedInterruptHandler<T>>, tx_buffer: &'d mut [u8], rx_buffer: &'d mut [u8], config: Config, ) -> Self
Create a buffered UART instance.
Sourcepub fn new_with_rtscts<T: Instance>(
_uart: Peri<'d, T>,
tx: Peri<'d, impl TxPin<T>>,
rx: Peri<'d, impl RxPin<T>>,
rts: Peri<'d, impl RtsPin<T>>,
cts: Peri<'d, impl CtsPin<T>>,
_irq: impl Binding<T::Interrupt, BufferedInterruptHandler<T>>,
tx_buffer: &'d mut [u8],
rx_buffer: &'d mut [u8],
config: Config,
) -> Self
pub fn new_with_rtscts<T: Instance>( _uart: Peri<'d, T>, tx: Peri<'d, impl TxPin<T>>, rx: Peri<'d, impl RxPin<T>>, rts: Peri<'d, impl RtsPin<T>>, cts: Peri<'d, impl CtsPin<T>>, _irq: impl Binding<T::Interrupt, BufferedInterruptHandler<T>>, tx_buffer: &'d mut [u8], rx_buffer: &'d mut [u8], config: Config, ) -> Self
Create a buffered UART instance with flow control.
Sourcepub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
pub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
Read from UART RX buffer.
Waits until at least one byte is available, then reads as many bytes as
are available (up to buf.len()) and returns the number of bytes read.
Sourcepub async fn fill_buf(&mut self) -> Result<&[u8], Error>
pub async fn fill_buf(&mut self) -> Result<&[u8], Error>
Wait until data is available in the RX buffer, and return a slice to it.
Call consume afterwards to mark bytes as read.
Sourcepub fn read_ready(&mut self) -> Result<bool, Error>
pub fn read_ready(&mut self) -> Result<bool, Error>
Check whether data is available in the RX buffer, i.e. whether a read would not block.
Sourcepub async fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
pub async fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
Write to UART TX buffer.
Waits until there is space in the TX buffer, then writes as many bytes as
fit (up to buf.len()) and returns the number of bytes written.
Sourcepub async fn flush(&mut self) -> Result<(), Error>
pub async fn flush(&mut self) -> Result<(), Error>
Wait until all written bytes have been fully transmitted on the wire.
Sourcepub fn blocking_write(&mut self, buffer: &[u8]) -> Result<usize, Error>
pub fn blocking_write(&mut self, buffer: &[u8]) -> Result<usize, Error>
Write to UART TX buffer blocking execution until done.
Sourcepub fn blocking_flush(&mut self) -> Result<(), Error>
pub fn blocking_flush(&mut self) -> Result<(), Error>
Flush UART TX blocking execution until done.
Sourcepub fn blocking_read(&mut self, buffer: &mut [u8]) -> Result<usize, Error>
pub fn blocking_read(&mut self, buffer: &mut [u8]) -> Result<usize, Error>
Read from UART RX buffer blocking execution until done.
Sourcepub async fn send_break(&mut self, bits: u32)
pub async fn send_break(&mut self, bits: u32)
Wait until TX is empty and send break condition.
Sourcepub fn set_baudrate(&mut self, baudrate: u32)
pub fn set_baudrate(&mut self, baudrate: u32)
sets baudrate on runtime
Sourcepub fn set_config(&mut self, config: Config)
pub fn set_config(&mut self, config: Config)
Set the configuration at runtime (ignores pin inversions)
Sourcepub fn split(self) -> (BufferedUartTx<'d>, BufferedUartRx<'d>)
pub fn split(self) -> (BufferedUartTx<'d>, BufferedUartRx<'d>)
Split into separate RX and TX handles.
Sourcepub fn split_ref(&mut self) -> (BufferedUartTx<'_>, BufferedUartRx<'_>)
pub fn split_ref(&mut self) -> (BufferedUartTx<'_>, BufferedUartRx<'_>)
Split the Uart into a transmitter and receiver by mutable reference, which is particularly useful when having two tasks correlating to transmitting and receiving.
Trait Implementations§
Source§impl<'d> BufRead for BufferedUart<'d>
impl<'d> BufRead for BufferedUart<'d>
Source§impl<'d> ErrorType for BufferedUart<'d>
impl<'d> ErrorType for BufferedUart<'d>
Source§impl<'d> Read for BufferedUart<'d>
impl<'d> Read for BufferedUart<'d>
Source§async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
Source§async fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
async fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
buf. Read moreSource§impl<'d> Read for BufferedUart<'d>
impl<'d> Read for BufferedUart<'d>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
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>>
buf. Read more