epio
A cycle-accurate RP2350 PIO emulator
Loading...
Searching...
No Matches
Functions
FIFO API

Functions for interacting with PIO TX and RX FIFOs. More...

Functions

EPIO_EXPORT int32_t epio_wait_tx_fifo (epio_t *epio, uint8_t block, uint8_t sm, int32_t count)
 Wait for a maximum of count cycles until the TX FIFO of a state machine has an entry pushed to it.
 
EPIO_EXPORT uint8_t epio_tx_fifo_depth (epio_t *epio, uint8_t block, uint8_t sm)
 Return the current number of entries in the TX FIFO.
 
EPIO_EXPORT uint8_t epio_rx_fifo_depth (epio_t *epio, uint8_t block, uint8_t sm)
 Return the current number of entries in the RX FIFO.
 
EPIO_EXPORT uint32_t epio_pop_rx_fifo (epio_t *epio, uint8_t block, uint8_t sm)
 Pop a value from the RX FIFO.
 
EPIO_EXPORT uint32_t epio_pop_tx_fifo (epio_t *epio, uint8_t block, uint8_t sm)
 Pop a value from the TX FIFO.
 
EPIO_EXPORT void epio_push_tx_fifo (epio_t *epio, uint8_t block, uint8_t sm, uint32_t value)
 Push a value into the TX FIFO.
 
EPIO_EXPORT void epio_push_rx_fifo (epio_t *epio, uint8_t block, uint8_t sm, uint32_t value)
 Push a value directly into the RX FIFO from the host.
 

Detailed Description

Functions for interacting with PIO TX and RX FIFOs.

Function Documentation

◆ epio_pop_rx_fifo()

EPIO_EXPORT uint32_t epio_pop_rx_fifo ( epio_t epio,
uint8_t  block,
uint8_t  sm 
)

Pop a value from the RX FIFO.

Removes and returns the oldest entry from the RX FIFO. The RX FIFO is written by the SM (via PUSH instructions) and read by the host.

Asserts if the RX FIFO is empty (i.e. has no entries to pop).

Parameters
epioThe epio instance.
blockPIO block index (0 to NUM_PIO_BLOCKS-1).
smState machine index within the block (0 to NUM_SMS_PER_BLOCK-1).
Returns
The 32-bit value popped from the RX FIFO.

◆ epio_pop_tx_fifo()

EPIO_EXPORT uint32_t epio_pop_tx_fifo ( epio_t epio,
uint8_t  block,
uint8_t  sm 
)

Pop a value from the TX FIFO.

Removes and returns the oldest entry from the TX FIFO. The TX FIFO is read by the SM (via PULL instructions).

Asserts if the TX FIFO is empty (i.e. has no entries to pop).

Parameters
epioThe epio instance.
blockPIO block index (0 to NUM_PIO_BLOCKS-1).
smState machine index within the block (0 to NUM_SMS_PER_BLOCK-1).
Returns
The 32-bit value popped from the TX FIFO.

◆ epio_push_rx_fifo()

EPIO_EXPORT void epio_push_rx_fifo ( epio_t epio,
uint8_t  block,
uint8_t  sm,
uint32_t  value 
)

Push a value directly into the RX FIFO from the host.

Allows the host to inject a value into the RX FIFO, simulating a DMA write or other external data source.

Asserts if the RX FIFO is full (i.e. has MAX_FIFO_DEPTH entries).

Parameters
epioThe epio instance.
blockPIO block index (0 to NUM_PIO_BLOCKS-1).
smState machine index within the block (0 to NUM_SMS_PER_BLOCK-1).
valueThe 32-bit value to push.

◆ epio_push_tx_fifo()

EPIO_EXPORT void epio_push_tx_fifo ( epio_t epio,
uint8_t  block,
uint8_t  sm,
uint32_t  value 
)

Push a value into the TX FIFO.

Adds value to the TX FIFO. The SM will consume this via PULL instructions. The TX FIFO is written by the host and read by the SM.

Asserts if the TX FIFO is full (i.e. has MAX_FIFO_DEPTH entries).

Parameters
epioThe epio instance.
blockPIO block index (0 to NUM_PIO_BLOCKS-1).
smState machine index within the block (0 to NUM_SMS_PER_BLOCK-1).
valueThe 32-bit value to push.

◆ epio_rx_fifo_depth()

EPIO_EXPORT uint8_t epio_rx_fifo_depth ( epio_t epio,
uint8_t  block,
uint8_t  sm 
)

Return the current number of entries in the RX FIFO.

Parameters
epioThe epio instance.
blockPIO block index (0 to NUM_PIO_BLOCKS-1).
smState machine index within the block (0 to NUM_SMS_PER_BLOCK-1).
Returns
Number of entries currently in the RX FIFO (0 to MAX_FIFO_DEPTH).

◆ epio_tx_fifo_depth()

EPIO_EXPORT uint8_t epio_tx_fifo_depth ( epio_t epio,
uint8_t  block,
uint8_t  sm 
)

Return the current number of entries in the TX FIFO.

Parameters
epioThe epio instance.
blockPIO block index (0 to NUM_PIO_BLOCKS-1).
smState machine index within the block (0 to NUM_SMS_PER_BLOCK-1).
Returns
Number of entries currently in the TX FIFO (0 to MAX_FIFO_DEPTH).

◆ epio_wait_tx_fifo()

EPIO_EXPORT int32_t epio_wait_tx_fifo ( epio_t epio,
uint8_t  block,
uint8_t  sm,
int32_t  count 
)

Wait for a maximum of count cycles until the TX FIFO of a state machine has an entry pushed to it.

Blocks (in the emulation sense, by stepping the SM) until the TX FIFO has an entry. Returns the number of cycles waited.

Parameters
epioThe epio instance.
blockPIO block index (0 to NUM_PIO_BLOCKS-1).
smState machine index within the block (0 to NUM_SMS_PER_BLOCK-1).
countNumber of cycles to wait for, or -1 to wait forever.
Returns
Number of cycles waited.