Struct Lpuart
pub struct Lpuart { /* 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§
§impl Lpuart
impl Lpuart
§impl Lpuart
impl Lpuart
pub fn with_pins<TX, RX, const N: u8>(
lpuart: Instance<RegisterBlock, N>,
pins: Pins<TX, RX>,
) -> Lpuartwhere
TX: Pin<Module = Const<N>, Direction = Tx>,
RX: Pin<Module = Const<N>, Direction = Rx>,
pub fn with_pins<TX, RX, const N: u8>(
lpuart: Instance<RegisterBlock, N>,
pins: Pins<TX, RX>,
) -> Lpuartwhere
TX: Pin<Module = Const<N>, Direction = Tx>,
RX: Pin<Module = Const<N>, Direction = Rx>,
Create a new LPUART peripheral from its peripheral registers and TX / RX pins.
When this call returns, the peripheral is reset, the pins are configured for their LPUART functions, and the TX and RX halves are enabled.
The pins are consumed to ensure they’re properly configured, but they are not stored in the driver.
pub fn without_pins<const N: u8>(lpuart: Instance<RegisterBlock, N>) -> Lpuart
pub fn without_pins<const N: u8>(lpuart: Instance<RegisterBlock, N>) -> Lpuart
Create a new LPUART peripheral from its peripheral registers without any pins.
This is similar to with_pins(), 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.
pub 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.
pub 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.
pub 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.
pub fn disable<R>(&mut self, func: impl FnOnce(&mut Disabled<'_>) -> R) -> R
pub fn disable<R>(&mut self, func: impl FnOnce(&mut Disabled<'_>) -> 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.
pub fn baud(&self) -> Baud
pub fn baud(&self) -> Baud
Return the baud-specific timing values for this UART peripheral.
pub 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.
pub fn is_inverted(&self, direction: Direction) -> bool
pub fn is_inverted(&self, direction: Direction) -> bool
Indicates if the bits are inverted.
pub fn is_fifo_enabled(&self, direction: Direction) -> bool
pub fn is_fifo_enabled(&self, direction: Direction) -> bool
Indicates if the FIFO is enabled.
pub fn fifo_watermark(&self, direction: Direction) -> u32
pub fn fifo_watermark(&self, direction: Direction) -> u32
Returns the FIFO watermark value.
pub fn read_data(&self) -> ReadData
pub fn read_data(&self) -> ReadData
Read the data register.
pub 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.
pub fn status(&self) -> Status
pub fn status(&self) -> Status
Check the peripheral status register.
pub 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().
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.