Module esp32h2_hal::parl_io

source ·
Expand description

§Parallel IO

§Overview

The Parallel IO peripheral is a general purpose parallel interface that can be used to connect to external devices such as LED matrix, LCD display, Printer and Camera. The peripheral has independent TX and RX units. Each unit can have up to 8 or 16 data signals (depending on your target hardware) plus 1 or 2 clock signals.

The driver uses DMA (Direct Memory Access) for efficient data transfer.

§Examples

§Initialization for TX

// configure the data pins to use
let tx_pins = TxFourBits::new(io.pins.gpio1, io.pins.gpio2, io.pins.gpio3, io.pins.gpio4);

// configure the valid pin which will be driven high during a TX transfer
let pin_conf = TxPinConfigWithValidPin::new(tx_pins, io.pins.gpio5);

let mut parl_io = ParlIoTxOnly::new(
    peripherals.PARL_IO,
    dma_channel.configure(
        false,
        &mut tx_descriptors,
        &mut rx_descriptors,
        DmaPriority::Priority0,
    ),
    1u32.MHz(),
    &clocks,
)
.unwrap();

// configure a pin for the clock signal
let cp = ClkOutPin::new(io.pins.gpio6);

let mut parl_io_tx = parl_io
    .tx
    .with_config(pin_conf, cp, 0, SampleEdge::Normal, BitPackOrder::Msb)
    .unwrap();

§Start TX transfer

let transfer = parl_io_tx.write_dma(buffer).unwrap();

// the buffer and driver is moved into the transfer and we can get it back via
// `wait`
(buffer, parl_io_tx) = transfer.wait().unwrap();

§Initialization for RX

let rx_pins = RxFourBits::new(io.pins.gpio1, io.pins.gpio2, io.pins.gpio3, io.pins.gpio4);

let parl_io = ParlIoRxOnly::new(
    peripherals.PARL_IO,
    dma_channel.configure(
        false,
        &mut tx_descriptors,
        &mut rx_descriptors,
        DmaPriority::Priority0,
    ),
    1u32.MHz(),
    &clocks,
)
.unwrap();

let mut parl_io_rx = parl_io
    .rx
    .with_config(rx_pins, NoClkPin, BitPackOrder::Msb, Some(0xfff))
    .unwrap();

§Start RX transfer

let transfer = parl_io_rx.read_dma(buffer).unwrap();

// the buffer and driver is moved into the transfer and we can get it back via
// `wait`
(buffer, parl_io_rx) = transfer.wait().unwrap();

Structs§

Enums§