Struct imxrt_hal::lpuart::Lpuart

source ·
pub struct Lpuart<P, const N: u8> { /* private fields */ }
Expand description

LPUART peripheral.

Lpuart lets you configure the LPUART peripheral, and perform I/O. See the module-level documentation for an example.

Lpuart implements serial traits from embedded-hal. It models DMA transfers as futures. The type exposes a lower-level API for coordinating DMA transfers. However, you may find it easier to use the dma interface.

Implementations§

source§

impl<P, const N: u8> Lpuart<P, N>

source

pub fn dma_write<'a>( &'a mut self, channel: &'a mut Channel, buffer: &'a [u8] ) -> Write<'a, Self, u8>

Use a DMA channel to write data to the UART peripheral

Completes when all data in buffer has been written to the UART peripheral.

source

pub fn dma_read<'a>( &'a mut self, channel: &'a mut Channel, buffer: &'a mut [u8] ) -> Read<'a, Self, u8>

Use a DMA channel to read data from the UART peripheral

Completes when buffer is filled.

source§

impl<TX, RX, const N: u8> Lpuart<Pins<TX, RX>, N>
where TX: Pin<Module = Const<N>, Direction = Tx>, RX: Pin<Module = Const<N>, Direction = Rx>,

source

pub fn new(lpuart: Instance<N>, pins: Pins<TX, RX>) -> Self

Create a new LPUART peripheral from its peripheral registers and TX / RX pins.

When new returns, the peripheral is reset, the pins are configured for their LPUART functions, and the TX and RX halves are enabled.

source§

impl<const N: u8> Lpuart<(), N>

source

pub fn without_pins(lpuart: Instance<N>) -> Self

Create a new LPUART peripheral from its peripheral registers without any pins.

This is similar to new(), but it does not configure pins to function as inputs and outputs. You’re responsible for configuring TX and RX pins and for making sure the pin state doesn’t change.

source§

impl<P, const N: u8> Lpuart<P, N>

source

pub const N: u8 = N

The peripheral instance.

source

pub fn is_enabled(&self, direction: Direction) -> bool

Indicates if the transmit / receive functions are (true) or are not (false) enabled.

source

pub fn set_enable(&mut self, direction: Direction, enable: bool)

Enable (true) or disable (false) the transmit / receive functions.

source

pub fn reset(&mut self)

Resets all internal logic and registers.

Note that this may not reset all peripheral state, like the state in the peripheral’s global register.

source

pub fn release(self) -> (Instance<N>, P)

Release all components of the LPUART driver.

This does not change any component state; it releases the components as-is. If you need to obtain the registers in a known, good state, consider calling methods like reset() before releasing the registers.

source

pub fn pins(&self) -> &P

Borrow the LPUART pins.

source

pub fn pins_mut(&mut self) -> &mut P

Exclusively borrow the LPUART pins.

source

pub fn disable<R>(&mut self, func: impl FnOnce(&mut Disabled<'_, N>) -> R) -> R

Temporarily disable the LPUART peripheral.

The handle to a Disabled driver lets you modify LPUART settings that require a fully disabled peripheral. This will flush TX and RX buffers.

source

pub fn baud(&self) -> Baud

Return the baud-specific timing values for this UART peripheral.

source

pub fn parity(&self) -> Option<Parity>

Return the parity seting for the UART peripheral.

Result is None if there is no parity setting.

source

pub fn is_inverted(&self, direction: Direction) -> bool

Indicates if the bits are inverted.

source

pub fn is_fifo_enabled(&self, direction: Direction) -> bool

Indicates if the FIFO is enabled.

source

pub fn fifo_watermark(&self, direction: Direction) -> u32

Returns the FIFO watermark value.

source

pub fn read_data(&self) -> ReadData

Read the data register.

source

pub fn write_byte(&self, byte: u8)

Write a byte.

This does not perform any checks for space in the transmit buffer. To check transmit buffer space, use status, and check for the transmit data register empty.

source

pub fn status(&self) -> Status

Check the peripheral status register.

source

pub fn clear_status(&mut self, status: Status)

Clear the status flags.

Bits that are read-only will be cleared by the implementation, so it’s safe to call with Status::all().

source

pub fn flush_fifo(&mut self, direction: Direction)

Flush data from the FIFO.

This does not flush anything that’s already in the transmit or receive register.

source

pub fn interrupts(&self) -> Interrupts

Return the interrupt flags.

The interrupt flags indicate the reasons that this peripheral may generate an interrupt.

source

pub fn enable_dma_transmit(&mut self)

Let the peripheral act as a DMA destination.

After this call, the peripheral will signal to the DMA engine whenever it has free space in its transfer buffer.

source

pub fn disable_dma_transmit(&mut self)

Stop the peripheral from acting as a DMA destination.

See the DMA chapter in the reference manual to understand when this should be called in the DMA transfer lifecycle.

source

pub fn data(&self) -> *const RWRegister<u32>

Produces a pointer to the data register.

You should use this pointer when coordinating a DMA transfer. You’re not expected to read from this pointer in software.

source

pub fn enable_dma_receive(&mut self)

Let the peripheral act as a DMA source.

After this call, the peripheral will signal to the DMA engine whenever it has data available to read.

source

pub fn disable_dma_receive(&mut self)

Stop the peripheral from acting as a DMA source.

See the DMA chapter in the reference manual to understand when this should be called in the DMA transfer lifecycle.

Trait Implementations§

source§

impl<P, const N: u8> Destination<u8> for Lpuart<P, N>

source§

fn destination_signal(&self) -> u32

Peripheral destination request signal Read more
source§

fn destination_address(&self) -> *const u8

Returns a pointer to the register into which the DMA channel writes data Read more
source§

fn enable_destination(&mut self)

Perform any actions necessary to enable DMA transfers Read more
source§

fn disable_destination(&mut self)

Perform any actions necessary to disable or cancel DMA transfers Read more
source§

impl<P, const N: u8> Source<u8> for Lpuart<P, N>

source§

fn source_signal(&self) -> u32

Peripheral source request signal Read more
source§

fn source_address(&self) -> *const u8

Returns a pointer to the register from which the DMA channel reads data Read more
source§

fn enable_source(&mut self)

Perform any actions necessary to enable DMA transfers Read more
source§

fn disable_source(&mut self)

Perform any actions necessary to disable or cancel DMA transfers Read more
source§

impl<P, const N: u8> Write<u8> for Lpuart<P, N>

§

type Error = Infallible

The type of error that can occur when writing
source§

fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error>

Writes a slice, blocking until everything has been written Read more
source§

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

Block until the serial interface has sent all buffered words
source§

impl<P, const N: u8> Read<u8> for Lpuart<P, N>

§

type Error = ReadFlags

Read error
source§

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

Reads a single word from the serial interface
source§

impl<P, const N: u8> Write<u8> for Lpuart<P, N>

§

type Error = Infallible

Write error
source§

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

Writes a single word to the serial interface
source§

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

Ensures that none of the previously written words are still buffered

Auto Trait Implementations§

§

impl<P, const N: u8> !RefUnwindSafe for Lpuart<P, N>

§

impl<P, const N: u8> Send for Lpuart<P, N>
where P: Send,

§

impl<P, const N: u8> !Sync for Lpuart<P, N>

§

impl<P, const N: u8> Unpin for Lpuart<P, N>
where P: Unpin,

§

impl<P, const N: u8> !UnwindSafe for Lpuart<P, N>

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>,

§

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>,

§

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.