embassy-mcxa

Crates

git

Versions

mcx-a256

Flavors

LpuartRx

Struct LpuartRx 

Source
pub struct LpuartRx<'a, M: Mode> { /* private fields */ }
Expand description

Lpuart Rx driver.

Implementations§

Source§

impl<'a> LpuartRx<'a, Blocking>

Source

pub fn new_blocking<T: Instance>( _inner: Peri<'a, T>, rx_pin: Peri<'a, impl RxPin<T>>, config: Config, ) -> Result<Self, Error>

Create a new blocking LPUART Receiver instance.

Any external pin will be placed into Disabled state upon Drop.

Source

pub fn new_blocking_with_rts<T: Instance>( _inner: Peri<'a, T>, rx_pin: Peri<'a, impl RxPin<T>>, rts_pin: Peri<'a, impl RtsPin<T>>, config: Config, ) -> Result<Self, Error>

Create a new blocking LPUART Receiver instance with RTS flow control.

Any external pin will be placed into Disabled state upon Drop.

Source

pub fn read(&mut self, buf: &mut [u8]) -> Result<(), Error>

Read data from LPUART RX without blocking.

Source

pub fn blocking_read(&mut self, buf: &mut [u8]) -> Result<(), Error>

Read data from LPUART RX blocking execution until the buffer is filled.

Source§

impl<'a> LpuartRx<'a, Buffered>

Source

pub fn new<T: Instance>( _inner: Peri<'a, T>, rx_pin: Peri<'a, impl RxPin<T>>, _irq: impl Binding<T::Interrupt, BufferedInterruptHandler<T>> + 'a, rx_buffer: &'a mut [u8], config: Config, ) -> Result<Self, Error>

Create a new RX-only buffered LPUART.

Any external pin will be placed into Disabled state upon Drop.

§SAFETY

You must NOT call core::mem::forget on LpuartRx if rx_buffer is not 'static. This will cause memory corruption.

Source

pub fn new_with_rts<T: Instance>( _inner: Peri<'a, T>, rx_pin: Peri<'a, impl RxPin<T>>, rts_pin: Peri<'a, impl RtsPin<T>>, _irq: impl Binding<T::Interrupt, BufferedInterruptHandler<T>> + 'a, rx_buffer: &'a mut [u8], config: Config, ) -> Result<Self, Error>

Create a new RX-only buffered LPUART with RTS flow control.

Any external pin will be placed into Disabled state upon Drop.

§SAFETY

You must NOT call core::mem::forget on LpuartRx if rx_buffer is not 'static. This will cause memory corruption.

Source

pub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>

Read data asynchronously

Source

pub fn try_read(&mut self, buf: &mut [u8]) -> usize

Try to read without blocking

May return zero bytes if none are available, or the provided buffer is of zero length.

Source§

impl<'a> LpuartRx<'a, Dma<'a>>

Source

pub fn new_async_with_dma<T: Instance>( _inner: Peri<'a, T>, rx_pin: Peri<'a, impl RxPin<T>>, rx_dma_ch: Peri<'a, impl Channel>, config: Config, ) -> Result<Self, Error>

Create a new LPUART RX driver with DMA support.

Any external pin will be placed into Disabled state upon Drop.

Source

pub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>

Read data using DMA.

This configures the DMA channel for a peripheral-to-memory transfer and waits for completion asynchronously. Large buffers are automatically split into chunks that fit within the DMA transfer limit.

The DMA request source is automatically derived from the LPUART instance type.

§Safety

If the returned future is dropped before completion (e.g., due to a timeout), the DMA transfer is automatically aborted to prevent use-after-free.

§Arguments
  • buf - Buffer to receive data into
Source

pub fn blocking_read(&mut self, buf: &mut [u8]) -> Result<(), Error>

Blocking read (fallback when DMA is not needed)

Source

pub fn into_ring_dma_rx<'buf: 'a>( &mut self, buf: &'buf mut [u8], ) -> RingBufferedLpuartRx<'_, 'buf>

Trait Implementations§

Source§

impl<M: Mode> Drop for LpuartRx<'_, M>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<M: Mode> ErrorType for LpuartRx<'_, M>

Source§

type Error = Error

Error type
Source§

impl<M: Mode> ErrorType for LpuartRx<'_, M>

Source§

type Error = Error

Error type of all the IO operations on this type.
Source§

impl Read for LpuartRx<'_, Blocking>

Source§

fn read(&mut self) -> Result<u8, Self::Error>

Reads a single word from the serial interface
Source§

impl Read for LpuartRx<'_, Blocking>

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl Read for LpuartRx<'_, Buffered>

Source§

async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

async fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl<'a> Read for LpuartRx<'a, Dma<'a>>

Source§

async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

async fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl Read<u8> for LpuartRx<'_, Blocking>

Source§

type Error = Error

Read error
Source§

fn read(&mut self) -> Result<u8, Error<Self::Error>>

Reads a single word from the serial interface

Auto Trait Implementations§

§

impl<'a, M> Freeze for LpuartRx<'a, M>
where M: Freeze,

§

impl<'a, M> !RefUnwindSafe for LpuartRx<'a, M>

§

impl<'a, M> Send for LpuartRx<'a, M>
where M: Send,

§

impl<'a, M> Sync for LpuartRx<'a, M>
where M: Sync,

§

impl<'a, M> Unpin for LpuartRx<'a, M>
where M: Unpin,

§

impl<'a, M> !UnwindSafe for LpuartRx<'a, M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.