Struct embassy_rp::uart::UartRx
source · pub struct UartRx<'d, T: Instance, M: Mode> { /* private fields */ }
Expand description
UART RX driver.
Implementations§
source§impl<'d, T: Instance, M: Mode> UartRx<'d, T, M>
impl<'d, T: Instance, M: Mode> UartRx<'d, T, M>
sourcepub fn new(
_uart: impl Peripheral<P = T> + 'd,
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>>,
rx_dma: impl Peripheral<P = impl Channel> + 'd,
config: Config
) -> Self
pub fn new( _uart: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl RxPin<T>> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>>, rx_dma: impl Peripheral<P = impl Channel> + 'd, config: Config ) -> Self
Create a new DMA-enabled UART which can only receive data
source§impl<'d, T: Instance> UartRx<'d, T, Blocking>
impl<'d, T: Instance> UartRx<'d, T, Blocking>
sourcepub fn new_blocking(
_uart: impl Peripheral<P = T> + 'd,
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
config: Config
) -> Self
pub fn new_blocking( _uart: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl RxPin<T>> + 'd, config: Config ) -> Self
Create a new UART RX instance for blocking mode operations.
sourcepub fn into_buffered(
self,
irq: impl Binding<T::Interrupt, BufferedInterruptHandler<T>>,
rx_buffer: &'d mut [u8]
) -> BufferedUartRx<'d, T>
pub fn into_buffered( self, irq: impl Binding<T::Interrupt, BufferedInterruptHandler<T>>, rx_buffer: &'d mut [u8] ) -> BufferedUartRx<'d, T>
Convert this uart RX instance into a buffered uart using the provided irq and receive buffer.
source§impl<'d, T: Instance> UartRx<'d, T, Async>
impl<'d, T: Instance> UartRx<'d, T, Async>
sourcepub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error>
pub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error>
Read from UART RX into the provided buffer.
sourcepub async fn read_to_break(
&mut self,
buffer: &mut [u8]
) -> Result<usize, ReadToBreakError>
pub async fn read_to_break( &mut self, buffer: &mut [u8] ) -> Result<usize, ReadToBreakError>
Read from the UART, waiting for a line break.
We read until one of the following occurs:
- We read
buffer.len()
bytes without a line break- returns
Err(ReadToBreakError::MissingBreak(buffer.len()))
- returns
- We read
n
bytes then a line break occurs- returns
Ok(n)
- returns
- We encounter some error OTHER than a line break
- returns
Err(ReadToBreakError::Other(error))
- returns
NOTE: you MUST provide a buffer one byte larger than your largest expected
message to reliably detect the framing on one single call to read_to_break()
.
- If you expect a message of 20 bytes + line break, and provide a 20-byte buffer:
- The first call to
read_to_break()
will returnErr(ReadToBreakError::MissingBreak(20))
- The next call to
read_to_break()
will immediately returnOk(0)
, from the “stale” line break
- The first call to
- If you expect a message of 20 bytes + line break, and provide a 21-byte buffer:
- The first call to
read_to_break()
will returnOk(20)
. - The next call to
read_to_break()
will work as expected
- The first call to
Trait Implementations§
Auto Trait Implementations§
impl<'d, T, M> Freeze for UartRx<'d, T, M>
impl<'d, T, M> RefUnwindSafe for UartRx<'d, T, M>where
M: RefUnwindSafe,
T: RefUnwindSafe,
impl<'d, T, M> Send for UartRx<'d, T, M>
impl<'d, T, M> Sync for UartRx<'d, T, M>
impl<'d, T, M> Unpin for UartRx<'d, T, M>where
M: Unpin,
impl<'d, T, M> !UnwindSafe for UartRx<'d, T, M>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.