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§

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

Enums§

InSource
InstructionOperands
JmpCondition
MovDestination
MovOperation
MovSource
OutDestination
SetDestination
WaitSource

Constants§

RP2040_MAX_PROGRAM_SIZE
Maximum program size of RP2040 chip, in bytes.