22#include "periph_conf.h"
30#if defined(CPU_MODEL_RP2040) || defined(DOXYGEN)
39#define PIO_INSTR_NUMOF 32
44#define PIO_IRQ_NUMOF 8
57#define PIO_GPIO_INIT_HIGH(pin) (((gpio_t)(1)) << (pin))
64#define PIO_GPIO_INIT_LOW(pin) ((gpio_t)0)
71#define PIO_GPIO_INIT_OUT(pin) (((gpio_t)(1)) << (pin))
78#define PIO_GPIO_INIT_IN(pin) ((gpio_t)0)
99#define PIO_INST_JMP (0u << 13)
103#define PIO_INST_JMP_MASK (7u << 13)
107#define PIO_INST_JMP_CONDITION_SHIFT 5
111#define PIO_INST_JMP_CONDITION_MASK (7u << PIO_INST_JMP_CONDITION_SHIFT)
115#define PIO_INST_JMP_ADDRESS_MASK (31u)
132#define PIO_INST_WAIT (1u << 13)
136#define PIO_INST_WAIT_MASK (7u << 13)
140#define PIO_INST_WAIT_POL_SHIFT 7
144#define PIO_INST_WAIT_POL_MASK (1u << PIO_INST_WAIT_POL_SHIFT)
148#define PIO_INST_WAIT_SOURCE_SHIFT 5
152#define PIO_INST_WAIT_SOURCE_MASK (3u << PIO_INST_WAIT_SOURCE_SHIFT)
156#define PIO_INST_WAIT_INDEX_MASK (31u)
175#define PIO_INST_IN (2u << 13)
179#define PIO_INST_IN_MASK (7u << 13)
183#define PIO_INST_IN_SOURCE_SHIFT 5
187#define PIO_INST_IN_SOURCE_MASK (7u << PIO_INST_IN_SOURCE_SHIFT)
191#define PIO_INST_IN_BIT_COUNT_MASK (31u)
206#define PIO_INST_OUT (3u << 13)
210#define PIO_INST_OUT_MASK (7u << 13)
214#define PIO_INST_OUT_DESTINATION_SHIFT 5
218#define PIO_INST_OUT_DESTINATION_MASK (7u << PIO_INST_OUT_DESTINATION_SHIFT)
222#define PIO_INST_OUT_BIT_COUNT_MASK (31u)
239#define PIO_INST_PUSH (4u << 13)
243#define PIO_INST_PUSH_MASK ((7u << 13) | (1u << 7) | 31u)
247#define PIO_INST_PUSH_IF_FULL_SHIFT 6
251#define PIO_INST_PUSH_IF_FULL_MASK (1u << PIO_INST_PUSH_IF_FULL_SHIFT)
255#define PIO_INST_PUSH_BLOCK_SHIFT 5
259#define PIO_INST_PUSH_BLOCK_MASK (1u << PIO_INST_PUSH_BLOCK_SHIFT)
263#define PIO_INST_PULL ((4u << 13) | (1u << 7))
267#define PIO_INST_PULL_MASK ((7u << 13) | (1u << 7) | 31u)
271#define PIO_INST_PULL_IF_EMPTY_SHIFT 6
275#define PIO_INST_PULL_IF_EMPTY_MASK (1u << PIO_INST_PULL_IF_EMPTY_SHIFT)
279#define PIO_INST_PULL_BLOCK_SHIFT 5
283#define PIO_INST_PULL_BLOCK_MASK (1u << PIO_INST_PULL_BLOCK_SHIFT)
287#define PIO_INST_MOV (5u << 13)
291#define PIO_INST_MOV_MASK (7u << 13)
295#define PIO_INST_MOV_DESTINATION_SHIFT 5
299#define PIO_INST_MOV_DESTINATION_MASK (7u << PIO_INST_MOV_DESTINATION_SHIFT)
303#define PIO_INST_MOV_OP_SHIFT 3
307#define PIO_INST_MOV_OP_MASK (3u << PIO_INST_MOV_OP_SHIFT)
311#define PIO_INST_MOV_SOURCE_SHIFT 0
315#define PIO_INST_MOV_SOURCE_MASK (7u)
351#define PIO_INST_IRQ (6u << 13)
355#define PIO_INST_IRQ_MASK ((7u << 13) | (1u << 7))
359#define PIO_INST_IRQ_CLR_SHIFT 6
363#define PIO_INST_IRQ_CLR_MASK (1u << PIO_INST_IRQ_CLR_SHIFT)
367#define PIO_INST_IRQ_WAIT_SHIFT 5
371#define PIO_INST_IRQ_WAIT_MASK (1u << PIO_INST_IRQ_WAIT_SHIFT)
375#define PIO_INST_IRQ_INDEX_MASK (31u)
379#define PIO_INST_SET (7u << 13)
383#define PIO_INST_SET_MASK (7u << 13)
387#define PIO_INST_SET_DESTINATION_SHIFT 5
391#define PIO_INST_SET_DESTINATION_MASK (7u << PIO_INST_SET_DESTINATION_SHIFT)
395#define PIO_INST_SET_DATA_MASK (31u)
439 ((!!relative) << 4) | index;
537 ((!!relative << 4) | index);
566 unsigned sideset_count,
570 return ((!!sideset_opt) << 12) |
571 (sideset << (13 - (!!sideset_opt + sideset_count))) |
591#define PIO_SM_CTRL_BASE(dev) ((pio_sm_ctrl_regs_t *)(&((dev)->SM0_CLKDIV)))
596#define PIO_SM_CLKDIV_MAX 65536
601#define PIO_SM_MASK(sm) (1u << (sm))
606#define PIO_IRQ_MASK(irq) (1u << (irq))
643 return (irq_abs & 0b100u) | ((irq_abs + sm) & 0b011u);
659 return (irq_abs & 0b100u) | ((irq_rel - irq_abs) & 0b011u);
665#define PIO_IRQ_REL_MASK(irq, sm) PIO_IRQ_MASK(pio_irq_rel_index(irq, sm))
1240 ((sm_mask &
PIO_SM_ALL) << PIO0_FDEBUG_TXSTALL_Pos));
1252 ((sm_mask &
PIO_SM_ALL) << PIO0_FDEBUG_TXOVER_Pos));
1264 ((sm_mask &
PIO_SM_ALL) << PIO0_FDEBUG_RXUNDER_Pos));
1276 ((sm_mask &
PIO_SM_ALL) << PIO0_FDEBUG_RXSTALL_Pos));
1289 return !!(
pio_config[pio].
dev->FSTAT & ((1u << sm) << PIO0_FSTAT_TXEMPTY_Pos));
1302 return !!(
pio_config[pio].
dev->FSTAT & ((1u << sm) << PIO0_FSTAT_TXFULL_Pos));
1315 return !!(
pio_config[pio].
dev->FSTAT & ((1u << sm) << PIO0_FSTAT_RXEMPTY_Pos));
1328 return !!((
pio_config[pio].
dev)->FSTAT & ((1u << sm) << PIO0_FSTAT_RXFULL_Pos));
#define assert(cond)
abort the program if assertion is false
static const pio_conf_t pio_config[]
Array of PIO configurations.
static unsigned pio_irq_rel_index(unsigned irq_abs, unsigned sm)
Convert absolute IRQ index to relative IRQ index.
uint16_t pio_instr_t
Type to represent the width of an instruction.
static pio_instr_t pio_inst_jmp(pio_inst_jmp_cond_t condition, unsigned address)
Construct a JMP instruction.
void pio_sm_clear_fifos(pio_t pio, pio_sm_t sm)
Drop all pending words in the tx and rx FIFO.
static void pio_sm_clear_debug_txover(pio_t pio, unsigned sm_mask)
Clear TX overflow debug flag.
pio_inst_jmp_cond_t
JMP conditions.
@ PIO_INST_JMP_COND_NOT_X_EQ_Y
If scratch X != scratch Y.
@ PIO_INST_JMP_COND_NONE
Unconditionally.
@ PIO_INST_JMP_COND_PIN
If jump pin is high.
@ PIO_INST_JMP_COND_X_DEC
If scratch X– is not 0.
@ PIO_INST_JMP_COND_X_ZERO
If scratch X is 0.
@ PIO_INST_JMP_COND_Y_ZERO
If scratch Y is 0.
@ PIO_INST_JMP_COND_Y_DEC
If scratch Y– is not 0.
@ PIO_INST_JMP_COND_NOT_OSR_EMPTY
If OSR is not empty.
struct pio_sm_ctrl_regs pio_sm_ctrl_regs_t
Internal state machine registers.
void pio_sm_set_sideset_pins_init(pio_t pio, pio_sm_t sm, const pio_gpio_init_t *pin_init)
Set pins affected by sideset instructions and initialize the pins as PIO pins and a state according t...
void pio_sm_set_sideset_count(pio_t pio, pio_sm_t sm, unsigned pin_count, bool enable)
Configure how many pins are sideset pins and whether a sideset is optional or required for every inst...
#define PIO_SM_NUMOF
Number of state machines per PIO.
pio_inst_out_dst_t
OUT destinations.
@ PIO_INST_OUT_DST_PINS
To output pins.
@ PIO_INST_OUT_DST_NULL
Discard data.
@ PIO_INST_OUT_DST_PC
To program counter.
@ PIO_INST_OUT_DST_PINDIRS
To output pin directions.
@ PIO_INST_OUT_DST_Y
To scratch Y.
@ PIO_INST_OUT_DST_X
To scratch X.
@ PIO_INST_OUT_DST_ISR
To input shift register.
@ PIO_INST_OUT_DST_EXEC
Execute as instruction.
void pio_sm_set_out_pins(pio_t pio, pio_sm_t sm, gpio_t pin_base, unsigned pin_count)
Configure which pins are writeable by an 'out pins' instruction.
#define PIO_INST_JMP_CONDITION_SHIFT
JMP condition shift position.
static pio_instr_t pio_inst_push(bool if_full, bool block)
Construct a PUSH instruction.
void pio_print_debug(pio_t pio)
Print debug information about the current state of this PIO.
void pio_irq_disable(pio_t pio, pio_irq_line_t irq, pio_irq_source_t irq_mask)
Disable PIO<pio>_IRQ<irq> interrupts.
#define PIO_INST_PULL
PULL opcode.
struct pio_isr_vec pio_isr_vec_t
PIO interrupt callbacks for FIFO interrupts.
#define PIO_INST_PUSH_IF_FULL_SHIFT
PUSH if input shift register is full shift position.
void pio_sm_set_in_shift(pio_t pio, pio_sm_t sm, bool right, bool autopush, unsigned threshold)
Configure the shift in behaviour of a state machine.
void pio_set_isr_vec(pio_t pio, pio_sm_t sm, const pio_isr_vec_t *vec)
Set ISR callbacks for FIFO interrupts per state machine.
#define PIO_INST_PULL_IF_EMPTY_SHIFT
PULL if output shift register is empty flag shift position.
#define PIO_INST_JMP
JMP opcode.
#define PIO_INST_SET_DESTINATION_SHIFT
SET destination shift position.
#define PIO_INST_IRQ
IRQ opcode.
void pio_sm_set_wrap(pio_t pio, pio_sm_t sm, unsigned prog_loc, uint8_t top, uint8_t bottom)
Set program instruction wrap boundaries.
static unsigned pio_irq_rel_sm(unsigned irq_abs, unsigned irq_rel)
Get state machine index from relative IRQ index.
#define PIO_INST_MOV_OP_SHIFT
MOV operation shift position.
static pio_instr_t pio_inst_delay_sideset(unsigned sideset, unsigned sideset_count, bool sideset_opt, unsigned delay)
Encode the delay/sideset instruction field.
void pio_sm_set_pins_with_mask(pio_t pio, pio_sm_t sm, gpio_t values, gpio_t mask)
Apply pin values in values for which the corresponding bit in mask is set.
uint32_t pio_irq_get(pio_t pio)
Read interrupt flags.
struct pio_sm_clkdiv pio_sm_clkdiv_t
PIO clock configuration.
pio_inst_mov_src_t
MOV source.
@ PIO_INST_MOV_SRC_NULL
Fill with zeros.
@ PIO_INST_MOV_SRC_X
From scratch X.
@ PIO_INST_MOV_SRC_STATUS
From status.
@ PIO_INST_MOV_SRC_Y
From scratch Y.
@ PIO_INST_MOV_SRC_OSR
From output shift register.
@ PIO_INST_MOV_SRC_ISR
From input shift register.
@ PIO_INST_MOV_SRC_PINS
From input pins.
#define PIO_INST_OUT
OUT opcode.
#define PIO_INST_MOV
MOV opcode.
void pio_set_isr_sm_vec(pio_t pio, unsigned irq, const pio_isr_sm_vec_t *vec)
Set ISR callbacks for state machine interrupts.
static bool pio_sm_rx_fifo_full(pio_t pio, pio_sm_t sm)
Check if RX FIFO is full.
static pio_instr_t pio_inst_irq(bool clear, bool wait, bool relative, unsigned index)
Construct an IRQ instruction.
void pio_sm_set_out_pins_init(pio_t pio, pio_sm_t sm, const pio_gpio_init_t *pin_init)
Set output pins affected by 'out pins', 'out pindirs' and 'mov pins' instructions and initialize the ...
static pio_instr_t pio_inst_set(pio_inst_set_dst_t destination, unsigned data)
Construct a SET instruction.
static pio_instr_t pio_inst_out(pio_inst_out_dst_t destination, unsigned bit_count)
Construct an OUT instruction.
int pio_sm_exec(pio_t pio, pio_sm_t sm, pio_instr_t inst)
Execute a single instruction.
void pio_sm_reset_fifos(pio_t pio, pio_sm_t sm)
No joined FIFO.
static pio_instr_t pio_inst_mov(pio_inst_mov_dst_t destination, pio_inst_mov_op_t operation, pio_inst_mov_src_t source)
Construct a MOV instruction.
void pio_sm_reset(pio_t pio, pio_sm_t sm)
Apply the default state machine configuration.
static bool pio_sm_tx_fifo_full(pio_t pio, pio_sm_t sm)
Check if TX FIFO is full.
pio_irq_line_t
PIO interrupt lines.
@ PIO_IRQ_LINE_1
IRQ line 1.
@ PIO_IRQ_LINE_0
IRQ line 0.
@ PIO_IRQ_LINE_NUMOF
Number of IRQ lines.
static pio_instr_t pio_inst_pull(bool if_empty, bool block)
Construct a PULL instruction.
static bool pio_sm_tx_fifo_empty(pio_t pio, pio_sm_t sm)
Check if TX FIFO is empty.
static void pio_sm_clear_debug_rxstall(pio_t pio, unsigned sm_mask)
Clear RX stall debug flag.
void pio_sm_set_set_pins_init(pio_t pio, pio_sm_t sm, const pio_gpio_init_t *pin_init)
Set pins affected by 'set pins' and 'set pindirs' instructions and initialize the pins as PIO pins an...
static void pio_sm_clear_debug_rxunder(pio_t pio, unsigned sm_mask)
Clear RX underflow debug flag.
void pio_print_status(pio_t pio)
Print status information about the FIFOs and programs.
struct pio_isr_sm_vec pio_isr_sm_vec_t
PIO state machine interrupt callbacks for state machine interrupts.
pio_inst_in_src_t
IN sources.
@ PIO_INST_IN_SRC_PINS
From input pins.
@ PIO_INST_IN_SRC_Y
From scratch Y.
@ PIO_INST_IN_SRC_ISR
From input shift register.
@ PIO_INST_IN_SRC_OSR
From output shift register.
@ PIO_INST_IN_SRC_X
From scratch X.
@ PIO_INST_IN_SRC_NULL
Fill with zeros.
void pio_irq_clear(pio_t pio, unsigned irq_flags)
Clear interrupt flags.
#define PIO_INST_IRQ_CLR_SHIFT
IRQ clear flag shift position.
void pio_sm_exec_block(pio_t pio, pio_sm_t sm, pio_instr_t inst)
Execute a single instruction.
pio_inst_mov_dst_t
MOV destinations.
@ PIO_INST_MOV_DST_PINS
To output pins.
@ PIO_INST_MOV_DST_ISR
To input shift register.
@ PIO_INST_MOV_DST_Y
To scratch Y.
@ PIO_INST_MOV_DST_OSR
To output shift register.
@ PIO_INST_MOV_DST_PC
To program counter.
@ PIO_INST_MOV_DST_EXEC
Execute data as instruction.
@ PIO_INST_MOV_DST_X
To scratch X.
pio_inst_wait_src_t
WAIT sources.
@ PIO_INST_WAIT_SRC_IRQ
Wait on interrupt.
@ PIO_INST_WAIT_SRC_PIN
Wait on input pin.
@ PIO_INST_WAIT_SRC_GPIO
Wait on GPIO.
void pio_sm_restart(pio_t pio, pio_sm_t sm)
Restart a state machine.
pio_irq_source_t
PIO IRQ flags.
@ PIO_IRQ_TXNFULL_SM3
SM3 TX FIFO is not full.
@ PIO_IRQ_TXNFULL_SM2
SM2 TX FIFO is not full.
@ PIO_IRQ_SM_3
Any state machine issued irq 3.
@ PIO_IRQ_SM_0
any state machine issued irq 0
@ PIO_IRQ_RXNEMPTY_SM2
SM2 RX FIFO is not empty.
@ PIO_IRQ_RXNEMPTY_SM3
SM3 RX FIFO is not empty.
@ PIO_IRQ_SM_2
Any state machine issued irq 2.
@ PIO_IRQ_SM_1
Any state machine issued irq 1.
@ PIO_IRQ_TXNFULL_SM0
SM0 TX FIFO is not full.
@ PIO_IRQ_TXNFULL_SM1
SM1 TX FIFO is not full.
@ PIO_IRQ_RXNEMPTY_SM1
SM1 RX FIFO is not empty.
@ PIO_IRQ_RXNEMPTY_SM0
SM0 RX FIFO is not empty.
@ PIO_IRQ_ALL_SM
All SM interrupts.
@ PIO_IRQ_ALL
All flags above.
void pio_sm_transmit_words_block(pio_t pio, pio_sm_t sm, const uint32_t *words, unsigned count)
Send count words to a state machine.
#define PIO_INST_SET
SET opcode.
#define PIO_INST_OUT_DESTINATION_SHIFT
OUT destination shift position.
#define PIO_IRQ_NUMOF
Number of interrupt flags per PIO.
#define PIO_INST_WAIT
WAIT opcode.
#define PIO_INST_IN
IN opcode.
static bool pio_sm_rx_fifo_empty(pio_t pio, pio_sm_t sm)
Check if RX FIFO is empty.
pio_inst_wait_pol_t
WAIT polarities.
@ PIO_INST_WAIT_POL_LOW
Wait for 0.
@ PIO_INST_WAIT_POL_HIGH
Wait for 1.
void pio_sm_set_pindirs_with_mask(pio_t pio, pio_sm_t sm, gpio_t values, gpio_t mask)
Apply pin directions in values for which the corresponding bit in mask is set.
#define PIO_INST_WAIT_POL_SHIFT
WAIT polarity shift position.
void pio_sm_receive_word_block(pio_t pio, pio_sm_t sm, uint32_t *word)
Receive one word from a state machine.
int pio_sm_init_common(pio_t pio, pio_sm_t sm, const pio_program_t *prog, const pio_program_conf_t *conf)
Apply common program configuration.
void pio_sm_receive_words_block(pio_t pio, pio_sm_t sm, uint32_t *words, unsigned count)
Receive words from a state machine.
#define PIO_INST_MOV_DESTINATION_SHIFT
MOV destination shift position.
int pio_sm_receive_word(pio_t pio, pio_sm_t sm, uint32_t *word)
Receive a word from a state machine.
#define PIO_INST_PULL_BLOCK_SHIFT
PULL if TX FIFO is not empty flag shift position.
void pio_sm_set_fifo_join_tx(pio_t pio, pio_sm_t sm)
Join the RX FIFO to the TX FIFO.
pio_sm_mask_t
PIO state machine flags.
@ PIO_SM1
Mask bit of SM 1.
@ PIO_SM0
Mask bit of SM 0.
@ PIO_SM_ALL
All flags above.
@ PIO_SM2
Mask bit of SM 2.
@ PIO_SM3
Mask bit of SM 3.
int pio_sm_transmit_word(pio_t pio, pio_sm_t sm, uint32_t word)
Send one word to a state machine.
void pio_sm_set_sideset_target(pio_t pio, pio_sm_t sm, bool pindir)
Configure whether a sideset effects pins or pin directions.
#define PIO_INST_PUSH_BLOCK_SHIFT
PUSH if RX FIFO is not full shift position.
void pio_sm_set_clkdiv(pio_t pio, pio_sm_t sm, pio_sm_clkdiv_t clk)
Apply the clock configuration to a PIO.
struct pio_program_conf pio_program_conf_t
PIO program configuration.
static pio_instr_t pio_inst_wait(pio_inst_wait_pol_t polarity, pio_inst_wait_src_t source, bool relative, unsigned index)
Construct a WAIT instruction.
#define PIO_INST_PUSH
PUSH opcode.
#define PIO_INST_MOV_SOURCE_SHIFT
MOV source shift position.
void pio_sm_transmit_word_block(pio_t pio, pio_sm_t sm, uint32_t word)
Send one word to a state machine.
void pio_sm_set_out_shift(pio_t pio, pio_sm_t sm, bool right, bool autopull, unsigned threshold)
Configure the shift out behaviour of a state machine.
int pio_write_program(pio_t pio, pio_program_t *prog, const pio_instr_t *instr)
Write program instructions to their allocated location.
#define PIO_INST_WAIT_SOURCE_SHIFT
WAIT source shift positions.
void pio_sm_set_set_pins(pio_t pio, pio_sm_t sm, gpio_t pin_base, unsigned pin_count)
Configure which pins are effected by a 'set pins' instructions.
void pio_sm_set_sideset_pins(pio_t pio, pio_sm_t sm, gpio_t pin_base)
Set the first pin of a sequence of sideset count pins which are effected by sideset instructions.
pio_inst_set_dst_t
SET destinations.
@ PIO_INST_SET_DST_Y
To scratch Y.
@ PIO_INST_SET_DST_PINDIRS
To set pin directions.
@ PIO_INST_SET_DST_PINS
To set pins.
@ PIO_INST_SET_DST_X
To scratch X.
static void pio_sm_clear_debug_txstall(pio_t pio, unsigned sm_mask)
Clear TX stall debug flag.
void pio_sm_set_fifo_join_rx(pio_t pio, pio_sm_t sm)
Join the TX FIFO to the RX FIFO.
#define PIO_SM_MASK(sm)
Convert state machine index to bitmask.
void pio_sm_clkdiv_restart(pio_t pio, unsigned sm_mask)
Restart the clock divider of several state machines.
void pio_sm_set_jmp_pin(pio_t pio, pio_sm_t sm, gpio_t pin)
Configure the pin on which to branch on a 'jmp pins' instruction.
void pio_sm_set_in_pins(pio_t pio, pio_sm_t sm, gpio_t pin_base)
Configure the state machine input pin mapping.
pio_inst_mov_op_t
MOV operation.
@ PIO_INST_MOV_OP_REVERSE
Bitwise reverse.
@ PIO_INST_MOV_OP_NONE
No operation.
@ PIO_INST_MOV_OP_INVERT
Bitwise complement.
#define PIO_INST_IN_SOURCE_SHIFT
IN source shift position.
#define PIO_INST_IRQ_WAIT_SHIFT
IRQ wait until cleared flag shift position.
void pio_irq_enable(pio_t pio, pio_irq_line_t irq, pio_irq_source_t irq_mask)
Enable PIO<pio>_IRQ<irq> interrupts.
static pio_instr_t pio_inst_in(pio_inst_in_src_t source, unsigned bit_count)
Construct an IN instruction.
Low-level GPIO peripheral driver interface definitions.
High-level PIO peripheral driver interface.
unsigned pio_t
PIO index type.
int pio_sm_t
PIO state machine index type.
void delay(unsigned long msec)
Sleep for a given amount of time [milliseconds].
static void io_reg_atomic_set(volatile uint32_t *reg, uint32_t mask)
Set the bits in the register at address reg as given by the set bits in operand op.
Memory layout of GPIO control register in IO bank 0.
Memory layout of GPIO control register in pads bank 0.
PIO0_Type * dev
PIO device.
Type used to configure PIO gpios pins.
gpio_t gpio_direction
GPIO directions applied to pins, where the LSBit is the base.
gpio_pad_ctrl_t pad
Pads bank GPIO control register configuration.
gpio_io_ctrl_t io
IO bank GPIO control register.
unsigned gpio_count
Number of GPIOs starting at base.
gpio_t gpio_base
GPIO base.
gpio_t gpio_state
GPIO states applied to pins, where the LSBit is the base.
PIO state machine interrupt callbacks for state machine interrupts.
void(* sm)(pio_t pio, unsigned irq)
Called when any SM issues an interrupt [0-3].
PIO interrupt callbacks for FIFO interrupts.
void(* tx_ready)(pio_t pio, pio_sm_t sm)
Called when Tx FIFO is not full.
void(* rx_ready)(pio_t pio, pio_sm_t sm)
Called when Rx FIFO is not empty.
PIO program configuration.
unsigned pc_start
Initial program counter.
unsigned wrap_bottom
Instruction index after which the PC wraps around.
bool sideset_optional
Whether the sideset is optional.
bool sideset_pindirs
Whether the sideset effects pin directions.
unsigned sideset_count
Number of bits used for sideset.
unsigned wrap_top
Instruction index the PC wraps to.
Struct that models a PIO program.
uint16_t div
Integer divider.
uint8_t frac_100
Fractional divider, two digits after comma.
Internal state machine registers.
volatile uint32_t clkdiv
SMx_CLKDIV.
volatile uint32_t instr
SMx_INSTR.
volatile uint32_t pinctrl
SMx_PINCTRL.
volatile uint32_t shiftctrl
SMx_SHIFTCTRL.
const volatile uint32_t addr
SMx_ADDR.
volatile uint32_t execctrl
SMx_EXECCTRL.