pub struct BufferedUarte<'d> { /* private fields */ }Expand description
Buffered UARTE driver.
Implementations§
Source§impl<'d> BufferedUarte<'d>
impl<'d> BufferedUarte<'d>
Sourcepub fn new<U: UarteInstance, T: TimerInstance>(
uarte: Peri<'d, U>,
txd: Peri<'d, impl GpioPin>,
rxd: Peri<'d, impl GpioPin>,
timer: Peri<'d, T>,
ppi_ch1: Peri<'d, impl ConfigurableChannel>,
ppi_ch2: Peri<'d, impl ConfigurableChannel>,
ppi_group: Peri<'d, impl Group>,
_irq: impl Binding<U::Interrupt, InterruptHandler<U>> + 'd,
tx_buffer: &'d mut [u8],
rx_buffer: &'d mut [u8],
config: Config,
) -> Self
pub fn new<U: UarteInstance, T: TimerInstance>( uarte: Peri<'d, U>, txd: Peri<'d, impl GpioPin>, rxd: Peri<'d, impl GpioPin>, timer: Peri<'d, T>, ppi_ch1: Peri<'d, impl ConfigurableChannel>, ppi_ch2: Peri<'d, impl ConfigurableChannel>, ppi_group: Peri<'d, impl Group>, _irq: impl Binding<U::Interrupt, InterruptHandler<U>> + 'd, tx_buffer: &'d mut [u8], rx_buffer: &'d mut [u8], config: Config, ) -> Self
Sourcepub fn new_with_rtscts<U: UarteInstance, T: TimerInstance>(
uarte: Peri<'d, U>,
txd: Peri<'d, impl GpioPin>,
rxd: Peri<'d, impl GpioPin>,
cts: Peri<'d, impl GpioPin>,
rts: Peri<'d, impl GpioPin>,
timer: Peri<'d, T>,
ppi_ch1: Peri<'d, impl ConfigurableChannel>,
ppi_ch2: Peri<'d, impl ConfigurableChannel>,
ppi_group: Peri<'d, impl Group>,
_irq: impl Binding<U::Interrupt, InterruptHandler<U>> + 'd,
tx_buffer: &'d mut [u8],
rx_buffer: &'d mut [u8],
config: Config,
) -> Self
pub fn new_with_rtscts<U: UarteInstance, T: TimerInstance>( uarte: Peri<'d, U>, txd: Peri<'d, impl GpioPin>, rxd: Peri<'d, impl GpioPin>, cts: Peri<'d, impl GpioPin>, rts: Peri<'d, impl GpioPin>, timer: Peri<'d, T>, ppi_ch1: Peri<'d, impl ConfigurableChannel>, ppi_ch2: Peri<'d, impl ConfigurableChannel>, ppi_group: Peri<'d, impl Group>, _irq: impl Binding<U::Interrupt, InterruptHandler<U>> + 'd, tx_buffer: &'d mut [u8], rx_buffer: &'d mut [u8], config: Config, ) -> Self
Create a new BufferedUarte with hardware flow control (RTS/CTS)
§Panics
Panics if rx_buffer.len() is odd.
Sourcepub fn set_baudrate(&mut self, baudrate: Baudrate)
pub fn set_baudrate(&mut self, baudrate: Baudrate)
Adjust the baud rate to the provided value.
Sourcepub fn split(self) -> (BufferedUarteTx<'d>, BufferedUarteRx<'d>)
pub fn split(self) -> (BufferedUarteTx<'d>, BufferedUarteRx<'d>)
Split the UART in writer and reader parts.
This allows reading and writing concurrently from independent tasks.
Sourcepub fn split_ref(&mut self) -> (BufferedUarteTx<'_>, BufferedUarteRx<'_>)
pub fn split_ref(&mut self) -> (BufferedUarteTx<'_>, BufferedUarteRx<'_>)
Split the UART in writer and reader parts, by reference.
The returned halves borrow from self, so you can drop them and go back to using
the “un-split” self. This allows temporarily splitting the UART.
Sourcepub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
pub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
Pull some bytes from this source into the specified buffer, returning how many bytes were read.
Sourcepub async fn fill_buf(&mut self) -> Result<&[u8], Error>
pub async fn fill_buf(&mut self) -> Result<&[u8], Error>
Return the contents of the internal buffer, filling it with more data from the inner reader if it is empty.
Sourcepub fn consume(&mut self, amt: usize)
pub fn consume(&mut self, amt: usize)
Tell this buffer that amt bytes have been consumed from the buffer, so they should no longer be returned in calls to fill_buf.
Sourcepub async fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
pub async fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
Write a buffer into this writer, returning how many bytes were written.
Trait Implementations§
Source§impl<'d> BufRead for BufferedUarte<'d>
impl<'d> BufRead for BufferedUarte<'d>
Source§impl<'d> ErrorType for BufferedUarte<'d>
impl<'d> ErrorType for BufferedUarte<'d>
Source§impl<'d> Read for BufferedUarte<'d>
impl<'d> Read for BufferedUarte<'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 more