Module imxrt_hal::uart [−][src]
Expand description
Low Power Universal Asynchronous Receiver/Transmit (LPUART)
The UART module provides a serial peripheral that implements
the embedded_hal::serial
traits. The peripheral is sufficient
for implementing basic serial communications.
UARTs may also be used in bi-directional DMA transfers.
Example
use imxrt_hal;
use embedded_hal::serial::{Read, Write};
let mut peripherals = imxrt_hal::Peripherals::take().unwrap();
let uarts = peripherals.uart.clock(
&mut peripherals.ccm.handle,
imxrt_hal::ccm::uart::ClockSelect::OSC,
imxrt_hal::ccm::uart::PrescalarSelect::DIVIDE_1,
);
let mut uart = uarts
.uart2
.init(
peripherals.iomuxc.ad_b1.p02,
peripherals.iomuxc.ad_b1.p03,
115_200,
)
.unwrap();
uart.set_tx_fifo(core::num::NonZeroU8::new(3));
uart.set_rx_fifo(true);
uart.set_parity(Some(imxrt_hal::uart::Parity::Even));
uart.set_rx_inversion(true);
uart.set_tx_inversion(false);
uart.write(0xDE).unwrap();
let byte = uart.read().unwrap();
// Split the peripheral into transfer and receive halves
let (tx, rx) = uart.split();
Structs
Type that describes a read error
Errors that may occur when reading data
A UART receive half
A UART transfer half
An initialized UART peripheral
All available UARTs
Unclocked UART peripherals
An uninitialized UART peripheral
Enums
Parity selection