pub struct BufferedUarte<'d, U: UarteInstance, T: TimerInstance> { /* private fields */ }
Expand description
Buffered UARTE driver.
Implementations§
Source§impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T>
impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T>
Sourcepub fn new(
uarte: Peri<'d, U>,
timer: Peri<'d, T>,
ppi_ch1: Peri<'d, impl ConfigurableChannel>,
ppi_ch2: Peri<'d, impl ConfigurableChannel>,
ppi_group: Peri<'d, impl Group>,
rxd: Peri<'d, impl GpioPin>,
txd: Peri<'d, impl GpioPin>,
_irq: impl Binding<U::Interrupt, InterruptHandler<U>> + 'd,
config: Config,
rx_buffer: &'d mut [u8],
tx_buffer: &'d mut [u8],
) -> Self
pub fn new( uarte: Peri<'d, U>, timer: Peri<'d, T>, ppi_ch1: Peri<'d, impl ConfigurableChannel>, ppi_ch2: Peri<'d, impl ConfigurableChannel>, ppi_group: Peri<'d, impl Group>, rxd: Peri<'d, impl GpioPin>, txd: Peri<'d, impl GpioPin>, _irq: impl Binding<U::Interrupt, InterruptHandler<U>> + 'd, config: Config, rx_buffer: &'d mut [u8], tx_buffer: &'d mut [u8], ) -> Self
Sourcepub fn new_with_rtscts(
uarte: Peri<'d, U>,
timer: Peri<'d, T>,
ppi_ch1: Peri<'d, impl ConfigurableChannel>,
ppi_ch2: Peri<'d, impl ConfigurableChannel>,
ppi_group: Peri<'d, impl Group>,
rxd: Peri<'d, impl GpioPin>,
txd: Peri<'d, impl GpioPin>,
cts: Peri<'d, impl GpioPin>,
rts: Peri<'d, impl GpioPin>,
_irq: impl Binding<U::Interrupt, InterruptHandler<U>> + 'd,
config: Config,
rx_buffer: &'d mut [u8],
tx_buffer: &'d mut [u8],
) -> Self
pub fn new_with_rtscts( uarte: Peri<'d, U>, timer: Peri<'d, T>, ppi_ch1: Peri<'d, impl ConfigurableChannel>, ppi_ch2: Peri<'d, impl ConfigurableChannel>, ppi_group: Peri<'d, impl Group>, rxd: Peri<'d, impl GpioPin>, txd: Peri<'d, impl GpioPin>, cts: Peri<'d, impl GpioPin>, rts: Peri<'d, impl GpioPin>, _irq: impl Binding<U::Interrupt, InterruptHandler<U>> + 'd, config: Config, rx_buffer: &'d mut [u8], tx_buffer: &'d mut [u8], ) -> 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) -> (BufferedUarteRx<'d, U, T>, BufferedUarteTx<'d, U>)
pub fn split(self) -> (BufferedUarteRx<'d, U, T>, BufferedUarteTx<'d, U>)
Split the UART in reader and writer parts.
This allows reading and writing concurrently from independent tasks.
Sourcepub fn split_by_ref(
&mut self,
) -> (&mut BufferedUarteRx<'d, U, T>, &mut BufferedUarteTx<'d, U>)
pub fn split_by_ref( &mut self, ) -> (&mut BufferedUarteRx<'d, U, T>, &mut BufferedUarteTx<'d, U>)
Split the UART in reader and writer 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, U: UarteInstance, T: TimerInstance> BufRead for BufferedUarte<'d, U, T>
impl<'d, U: UarteInstance, T: TimerInstance> BufRead for BufferedUarte<'d, U, T>
Source§impl<'d, U: UarteInstance, T: TimerInstance> ErrorType for BufferedUarte<'d, U, T>
impl<'d, U: UarteInstance, T: TimerInstance> ErrorType for BufferedUarte<'d, U, T>
Source§impl<'d, U: UarteInstance, T: TimerInstance> Read for BufferedUarte<'d, U, T>
impl<'d, U: UarteInstance, T: TimerInstance> Read for BufferedUarte<'d, U, T>
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