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: impl Peripheral<P = U> + 'd,
timer: impl Peripheral<P = T> + 'd,
ppi_ch1: impl Peripheral<P = impl ConfigurableChannel> + 'd,
ppi_ch2: impl Peripheral<P = impl ConfigurableChannel> + 'd,
ppi_group: impl Peripheral<P = impl Group> + 'd,
_irq: impl Binding<U::Interrupt, InterruptHandler<U>> + 'd,
rxd: impl Peripheral<P = impl GpioPin> + 'd,
txd: impl Peripheral<P = impl GpioPin> + 'd,
config: Config,
rx_buffer: &'d mut [u8],
tx_buffer: &'d mut [u8],
) -> Self
pub fn new( uarte: impl Peripheral<P = U> + 'd, timer: impl Peripheral<P = T> + 'd, ppi_ch1: impl Peripheral<P = impl ConfigurableChannel> + 'd, ppi_ch2: impl Peripheral<P = impl ConfigurableChannel> + 'd, ppi_group: impl Peripheral<P = impl Group> + 'd, _irq: impl Binding<U::Interrupt, InterruptHandler<U>> + 'd, rxd: impl Peripheral<P = impl GpioPin> + 'd, txd: impl Peripheral<P = impl GpioPin> + 'd, config: Config, rx_buffer: &'d mut [u8], tx_buffer: &'d mut [u8], ) -> Self
sourcepub fn new_with_rtscts(
uarte: impl Peripheral<P = U> + 'd,
timer: impl Peripheral<P = T> + 'd,
ppi_ch1: impl Peripheral<P = impl ConfigurableChannel> + 'd,
ppi_ch2: impl Peripheral<P = impl ConfigurableChannel> + 'd,
ppi_group: impl Peripheral<P = impl Group> + 'd,
_irq: impl Binding<U::Interrupt, InterruptHandler<U>> + 'd,
rxd: impl Peripheral<P = impl GpioPin> + 'd,
txd: impl Peripheral<P = impl GpioPin> + 'd,
cts: impl Peripheral<P = impl GpioPin> + 'd,
rts: impl Peripheral<P = impl GpioPin> + 'd,
config: Config,
rx_buffer: &'d mut [u8],
tx_buffer: &'d mut [u8],
) -> Self
pub fn new_with_rtscts( uarte: impl Peripheral<P = U> + 'd, timer: impl Peripheral<P = T> + 'd, ppi_ch1: impl Peripheral<P = impl ConfigurableChannel> + 'd, ppi_ch2: impl Peripheral<P = impl ConfigurableChannel> + 'd, ppi_group: impl Peripheral<P = impl Group> + 'd, _irq: impl Binding<U::Interrupt, InterruptHandler<U>> + 'd, rxd: impl Peripheral<P = impl GpioPin> + 'd, txd: impl Peripheral<P = impl GpioPin> + 'd, cts: impl Peripheral<P = impl GpioPin> + 'd, rts: impl Peripheral<P = impl GpioPin> + '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