|
epio
A cycle-accurate RP2350 PIO emulator
|
Functions for driving and reading GPIO pin states. More...
Functions | |
| EPIO_EXPORT void | epio_drive_gpios_ext (epio_t *epio, uint64_t gpios, uint64_t level) |
| Drive a set of GPIOs to specified levels from an external source. | |
| void | epio_set_gpio_input_inverted (epio_t *epio, uint8_t pin, uint8_t inverted) |
| Set a GPIO pin as inverted or non-inverted. | |
| uint8_t | epio_get_gpio_input_inverted (epio_t *epio, uint8_t pin) |
| Get the inversion state of a GPIO pin. | |
| void | epio_set_gpio_output_control (epio_t *epio, uint8_t pin, uint8_t block) |
| Set GPIO output control for a pin to a specific block. | |
| void | epio_clear_gpio_output_control (epio_t *epio, uint8_t pin, uint8_t block) |
| Clear GPIO output control for a pin. | |
| uint8_t | epio_block_can_control_gpio_output (epio_t *epio, uint8_t block, uint8_t pin) |
| Check if a block can control the output of a GPIO pin. | |
| uint64_t | epio_get_gpio_output_control (epio_t *epio, uint8_t block) |
| Get the GPIO output control for a block. | |
| EPIO_EXPORT uint8_t | epio_get_gpio_input (epio_t *epio, uint8_t pin) |
| Read the current input level of a single GPIO pin. | |
| EPIO_EXPORT void | epio_init_gpios (epio_t *epio) |
| Reset all GPIOs to their default (input, pulled-up) state. | |
| EPIO_EXPORT void | epio_set_gpio_force_input_low (epio_t *epio, uint8_t pin, uint8_t force_low) |
| Force a GPIO pin configured as an input to present a low level. | |
| EPIO_EXPORT void | epio_set_gpio_force_input_high (epio_t *epio, uint8_t pin, uint8_t force_high) |
| Force a GPIO pin configured as an input to present a high level. | |
| EPIO_EXPORT uint8_t | epio_get_gpio_force_input_low (epio_t *epio, uint8_t pin) |
| Get whether a GPIO pin configured as an input has a forced input level low. | |
| EPIO_EXPORT uint8_t | epio_get_gpio_force_input_high (epio_t *epio, uint8_t pin) |
| Get whether a GPIO pin configured as an input has a forced input level high. | |
| EPIO_EXPORT void | epio_set_gpio_input (epio_t *epio, uint8_t pin) |
| Configure a GPIO pin as an input. | |
| EPIO_EXPORT void | epio_set_gpio_output (epio_t *epio, uint8_t pin) |
| Configure a GPIO pin as an output. | |
| EPIO_EXPORT void | epio_set_gpio_input_level (epio_t *epio, uint8_t pin, uint8_t level) |
| Set the level of a GPIO configured as an input. | |
| EPIO_EXPORT void | epio_set_gpio_output_level (epio_t *epio, uint8_t pin, uint8_t level) |
| Set the level of a GPIO configured as an output. | |
| EPIO_EXPORT uint64_t | epio_read_pin_states (epio_t *epio) |
| Read the current state of all GPIO pins. | |
| EPIO_EXPORT uint64_t | epio_read_driven_pins (epio_t *epio) |
| Read the set of GPIO pins currently being driven by PIO. | |
Functions for driving and reading GPIO pin states.
| uint8_t epio_block_can_control_gpio_output | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | pin | ||
| ) |
Check if a block can control the output of a GPIO pin.
Returns 1 if the specified block has output control for the specified GPIO pin, meaning it can drive that pin as an output when configured to do so. Returns 0 otherwise.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| void epio_clear_gpio_output_control | ( | epio_t * | epio, |
| uint8_t | pin, | ||
| uint8_t | block | ||
| ) |
Clear GPIO output control for a pin.
This configures a GPIO pin to not to be able to be driven by the block.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| EPIO_EXPORT void epio_drive_gpios_ext | ( | epio_t * | epio, |
| uint64_t | gpios, | ||
| uint64_t | level | ||
| ) |
Drive a set of GPIOs to specified levels from an external source.
Simulates external hardware driving GPIO pins. gpios is a bitmask of pins to affect; level is a bitmask of the desired levels for those pins. Pins not set in gpios are unaffected.
This function only affects the input state of the specified pins.
| epio | The epio instance. |
| gpios | Bitmask of GPIO pins to drive (bit N = GPIO N). |
| level | Bitmask of desired pin levels for the selected pins. |
| EPIO_EXPORT uint8_t epio_get_gpio_force_input_high | ( | epio_t * | epio, |
| uint8_t | pin | ||
| ) |
Get whether a GPIO pin configured as an input has a forced input level high.
Returns 1 if the specified pin is configured to force input high, 0 otherwise.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| EPIO_EXPORT uint8_t epio_get_gpio_force_input_low | ( | epio_t * | epio, |
| uint8_t | pin | ||
| ) |
Get whether a GPIO pin configured as an input has a forced input level low.
Returns 1 if the specified pin is configured to force input low, 0 otherwise.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| EPIO_EXPORT uint8_t epio_get_gpio_input | ( | epio_t * | epio, |
| uint8_t | pin | ||
| ) |
Read the current input level of a single GPIO pin.
Returns the level that the specified pin presents as an input to the PIO state machines, accounting for both external and PIO-driven states.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| uint8_t epio_get_gpio_input_inverted | ( | epio_t * | epio, |
| uint8_t | pin | ||
| ) |
Get the inversion state of a GPIO pin.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| uint64_t epio_get_gpio_output_control | ( | epio_t * | epio, |
| uint8_t | block | ||
| ) |
Get the GPIO output control for a block.
Returns a bitmask of which GPIO pins are configured to be driven by the specified block when they are configured as outputs.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| EPIO_EXPORT void epio_init_gpios | ( | epio_t * | epio | ) |
Reset all GPIOs to their default (input, pulled-up) state.
Clears all GPIO directions and levels. Useful for resetting between test cases.
| epio | The epio instance. |
| EPIO_EXPORT uint64_t epio_read_driven_pins | ( | epio_t * | epio | ) |
Read the set of GPIO pins currently being driven by PIO.
Returns a bitmask indicating which GPIO pins are configured as outputs and are being actively driven by the PIO state machines combined with any externally driven pins. This reflects the driving state by the RP2350, and any undriven pins are pulled up.
Bit N corresponds to GPIO N, with GPIO0 being the LSB.
| epio | The epio instance. |
| EPIO_EXPORT uint64_t epio_read_pin_states | ( | epio_t * | epio | ) |
Read the current state of all GPIO pins.
Returns the logical level of all GPIO pins as currently observed, reflecting both PIO-driven outputs and externally driven inputs. Bit N corresponds to GPIO N, with GPIO0 being the LSB.
This function returns inverted states, if the pin is configured as such
| epio | The epio instance. |
| EPIO_EXPORT void epio_set_gpio_force_input_high | ( | epio_t * | epio, |
| uint8_t | pin, | ||
| uint8_t | force_high | ||
| ) |
Force a GPIO pin configured as an input to present a high level.
This sets the emulated hardware INOVER state to always read inputs as high.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| force_high | 1 to force the pin to read as high, 0 to clear the forced state. |
| EPIO_EXPORT void epio_set_gpio_force_input_low | ( | epio_t * | epio, |
| uint8_t | pin, | ||
| uint8_t | force_low | ||
| ) |
Force a GPIO pin configured as an input to present a low level.
This sets the emulated hardware INOVER state to always read inputs as low.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| force_low | 1 to force the pin to read as low, 0 to clear the forced state. |
| EPIO_EXPORT void epio_set_gpio_input | ( | epio_t * | epio, |
| uint8_t | pin | ||
| ) |
Configure a GPIO pin as an input.
Pull-ups are assumed on all input pins.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| void epio_set_gpio_input_inverted | ( | epio_t * | epio, |
| uint8_t | pin, | ||
| uint8_t | inverted | ||
| ) |
Set a GPIO pin as inverted or non-inverted.
When a GPIO pin is inverted, the PIO state machines see the opposite level on that pin. For example, if GPIO5 is inverted and externally driven low, the SMs will see it as high. This allows testing of PIO programs that use the INVERT pin configuration to invert GPIO inputs.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| inverted | 1 to set the pin as inverted, 0 to set it as non-inverted. |
| EPIO_EXPORT void epio_set_gpio_input_level | ( | epio_t * | epio, |
| uint8_t | pin, | ||
| uint8_t | level | ||
| ) |
Set the level of a GPIO configured as an input.
Simulates an external signal on an input pin, allowing PIO programs that read GPIO state to observe the specified level.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| level | Pin level: 0 (low) or 1 (high). |
| EPIO_EXPORT void epio_set_gpio_output | ( | epio_t * | epio, |
| uint8_t | pin | ||
| ) |
Configure a GPIO pin as an output.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| void epio_set_gpio_output_control | ( | epio_t * | epio, |
| uint8_t | pin, | ||
| uint8_t | block | ||
| ) |
Set GPIO output control for a pin to a specific block.
This configures a GPIO pin to be driven by the specified PIO block when it is configured as an output. Only a PIO block with output control for that GPIO can drive it as an output.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| EPIO_EXPORT void epio_set_gpio_output_level | ( | epio_t * | epio, |
| uint8_t | pin, | ||
| uint8_t | level | ||
| ) |
Set the level of a GPIO configured as an output.
Overrides the PIO-driven level on an output pin, for test setup purposes.
| epio | The epio instance. |
| pin | GPIO pin number (0 to NUM_GPIOS-1). |
| level | Pin level: 0 (low) or 1 (high). |