Crate pio

source ·
Expand description

Programmable Input/Output

// Repeatedly get one word of data from the TX FIFO, stalling when
// the FIFO is empty. Write the least significant bit to the OUT pin
// group.
// https://github.com/raspberrypi/pico-examples/tree/master/pio/hello_pio/hello.pio
let mut a = pio::Assembler::<{ pio::RP2040_MAX_PROGRAM_SIZE }>::new();

let mut loop_label = a.label();

a.bind(&mut loop_label);
a.pull(false, false);
a.out(pio::OutDestination::PINS, 1);
a.jmp(pio::JmpCondition::Always, &mut loop_label);

let program = a.assemble_program();

Wrapping

let mut a = pio::Assembler::<{ pio::RP2040_MAX_PROGRAM_SIZE }>::new();

let mut wrap_source = a.label();
let mut wrap_target = a.label();

// Initialize pin direction only once
a.set(pio::SetDestination::PINDIRS, 1);
a.bind(&mut wrap_target);
a.out(pio::OutDestination::PINS, 1);
a.bind(&mut wrap_source);

let program = a.assemble_with_wrap(wrap_source, wrap_target);

Structs

A vector with a fixed capacity.
A PIO Assembler. See chapter three of the RP2040 Datasheet.
A PIO instruction.
A label.
Program ready to be executed by PIO hardware.
Parsed program with defines.
Data for ‘side’ set instruction parameters.
Source and target for automatic program wrapping.

Enums

Constants

Maximum program size of RP2040 chip, in bytes.