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

Functions for creating, configuring, and destroying an epio instance. More...

Functions

EPIO_EXPORT epio_tepio_init (void)
 Create and initialise a new epio instance.
 
EPIO_EXPORT void epio_free (epio_t *epio)
 Free an epio instance and all associated resources.
 
EPIO_EXPORT void epio_set_sm_debug (epio_t *epio, uint8_t block, uint8_t sm, epio_sm_debug_t *debug)
 Sets debug information for a specific state machine.
 
EPIO_EXPORT void epio_get_sm_debug (epio_t *epio, uint8_t block, uint8_t sm, epio_sm_debug_t *debug)
 Gets the debug information for a specific state machine.
 
EPIO_EXPORT void epio_set_gpiobase (epio_t *epio, uint8_t block, uint32_t gpio_base)
 Set the GPIO base for a PIO block.
 
EPIO_EXPORT uint32_t epio_get_gpiobase (epio_t *epio, uint8_t block)
 Get the GPIO base for a PIO block.
 
EPIO_EXPORT void epio_set_sm_reg (epio_t *epio, uint8_t block, uint8_t sm, epio_sm_reg_t *reg)
 Set the SM configuration registers for a state machine.
 
EPIO_EXPORT void epio_get_sm_reg (epio_t *epio, uint8_t block, uint8_t sm, epio_sm_reg_t *reg)
 Read the current SM configuration registers for a state machine.
 
EPIO_EXPORT void epio_enable_sm (epio_t *epio, uint8_t block, uint8_t sm)
 Enable a state machine for execution.
 
EPIO_EXPORT uint8_t epio_is_sm_enabled (epio_t *epio, uint8_t block, uint8_t sm)
 Check if a state machine is enabled.
 
EPIO_EXPORT void epio_disable_sm (epio_t *epio, uint8_t block, uint8_t sm)
 Disable a state machine.
 

Detailed Description

Functions for creating, configuring, and destroying an epio instance.

Function Documentation

◆ epio_disable_sm()

EPIO_EXPORT void epio_disable_sm ( epio_t epio,
uint8_t  block,
uint8_t  sm 
)

Disable a state machine.

Marks the specified SM as disabled. Disabled SMs are not advanced by epio_step_cycles() and do not execute instructions until re-enabled.

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).

◆ epio_enable_sm()

EPIO_EXPORT void epio_enable_sm ( epio_t epio,
uint8_t  block,
uint8_t  sm 
)

Enable a state machine for execution.

Marks the specified SM as enabled. Only enabled SMs are advanced by epio_step_cycles(). The SM must be fully configured before enabling.

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).

◆ epio_free()

EPIO_EXPORT void epio_free ( epio_t epio)

Free an epio instance and all associated resources.

Parameters
epioThe epio instance to free. Must not be used after this call.

◆ epio_get_gpiobase()

EPIO_EXPORT uint32_t epio_get_gpiobase ( epio_t epio,
uint8_t  block 
)

Get the GPIO base for a PIO block.

Parameters
epioThe epio instance.
blockPIO block index (0 to NUM_PIO_BLOCKS-1).
Returns
The GPIO base offset for this block.

◆ epio_get_sm_debug()

EPIO_EXPORT void epio_get_sm_debug ( epio_t epio,
uint8_t  block,
uint8_t  sm,
epio_sm_debug_t debug 
)

Gets the debug information for a specific state machine.

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).
debugPointer to a caller-allocated structure to receive the debug information for this SM.

◆ epio_get_sm_reg()

EPIO_EXPORT void epio_get_sm_reg ( epio_t epio,
uint8_t  block,
uint8_t  sm,
epio_sm_reg_t reg 
)

Read the current SM configuration registers for a state machine.

Copies the current register state of the specified SM into reg.

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).
regPointer to a caller-allocated structure to receive the state.
See also
epio_set_sm_reg()

◆ epio_init()

EPIO_EXPORT epio_t * epio_init ( void  )

Create and initialise a new epio instance.

Allocates and returns a new epio instance with all state machines disabled and all GPIOs in their default state. The caller is responsible for configuring the instance before stepping.

Returns
Pointer to the new epio instance, or NULL on allocation failure.
See also
epio_free(), epio_from_apio()

◆ epio_is_sm_enabled()

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

Check if a state machine is enabled.

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
1 if the SM is enabled, 0 otherwise.

◆ epio_set_gpiobase()

EPIO_EXPORT void epio_set_gpiobase ( epio_t epio,
uint8_t  block,
uint32_t  gpio_base 
)

Set the GPIO base for a PIO block.

The RP2350 supports GPIOBASE values of 0 and 16 per PIO block, shifting the block's GPIO mapping accordingly. This must match the GPIOBASE configuration of the PIO block under test.

Parameters
epioThe epio instance.
blockPIO block index (0 to NUM_PIO_BLOCKS-1).
gpio_baseGPIO base offset (0 or 16).

◆ epio_set_sm_debug()

EPIO_EXPORT void epio_set_sm_debug ( epio_t epio,
uint8_t  block,
uint8_t  sm,
epio_sm_debug_t debug 
)

Sets debug information for a specific state machine.

This is optional and used for logging and debugging purposes. It does not affect the execution of the state machine.

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).
debugPointer to the debug information to set for this SM.

◆ epio_set_sm_reg()

EPIO_EXPORT void epio_set_sm_reg ( epio_t epio,
uint8_t  block,
uint8_t  sm,
epio_sm_reg_t reg 
)

Set the SM configuration registers for a state machine.

Copies the register state from reg into the specified SM. This configures the SM's PINCTRL, EXECCTRL, SHIFTCTRL, and CLKDIV registers to match a known hardware or intended configuration.

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).
regPointer to the register state to apply.
See also
epio_get_sm_reg()