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>
impl<P, const N: u8> Lpuart<P, N>
source§impl<const N: u8> Lpuart<(), N>
impl<const N: u8> Lpuart<(), N>
sourcepub fn without_pins(lpuart: Instance<N>) -> Self
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>
impl<P, const N: u8> Lpuart<P, N>
sourcepub fn is_enabled(&self, direction: Direction) -> bool
pub fn is_enabled(&self, direction: Direction) -> bool
Indicates if the transmit / receive functions are
(true
) or are not (false
) enabled.
sourcepub fn set_enable(&mut self, direction: Direction, enable: bool)
pub fn set_enable(&mut self, direction: Direction, enable: bool)
Enable (true
) or disable (false
) the transmit / receive
functions.
sourcepub fn reset(&mut self)
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.
sourcepub fn release(self) -> (Instance<N>, P)
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.
sourcepub fn disable<R>(&mut self, func: impl FnOnce(&mut Disabled<'_, N>) -> R) -> R
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.
sourcepub fn parity(&self) -> Option<Parity>
pub fn parity(&self) -> Option<Parity>
Return the parity seting for the UART peripheral.
Result is None
if there is no parity setting.
sourcepub fn is_inverted(&self, direction: Direction) -> bool
pub fn is_inverted(&self, direction: Direction) -> bool
Indicates if the bits are inverted.
sourcepub fn is_fifo_enabled(&self, direction: Direction) -> bool
pub fn is_fifo_enabled(&self, direction: Direction) -> bool
Indicates if the FIFO is enabled.
sourcepub fn fifo_watermark(&self, direction: Direction) -> u32
pub fn fifo_watermark(&self, direction: Direction) -> u32
Returns the FIFO watermark value.
sourcepub fn write_byte(&self, byte: u8)
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.
sourcepub fn clear_status(&mut self, status: Status)
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()
.
sourcepub fn flush_fifo(&mut self, direction: Direction)
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.
sourcepub fn interrupts(&self) -> Interrupts
pub fn interrupts(&self) -> Interrupts
Return the interrupt flags.
The interrupt flags indicate the reasons that this peripheral may generate an interrupt.
sourcepub fn enable_dma_transmit(&mut self)
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.
sourcepub fn disable_dma_transmit(&mut self)
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.
sourcepub fn data(&self) -> *const RWRegister<u32>
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.
sourcepub fn enable_dma_receive(&mut self)
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.
sourcepub fn disable_dma_receive(&mut self)
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.