Enhanced General-Purpose Input/Output (EGPIO) Appendix#
This appendix defines terminology, acronyms, use cases, and sample code for working with general-purpose input/output (GPIO) on SiWx917 microcontrollers and system-on-chip (SoC) devices. It provides reference definitions, domain explanations, and practical examples for implementing and debugging GPIO configurations in both high-performance (HP) and ultra-low-power (ULP) domains, including ultra-ultra-low-power (UULP) operation.
Glossary#
Term | Definition |
|---|---|
EGPIO | Enhanced general-purpose input/output—configurable digital pins that support input, output, and alternate peripheral functions. |
Pad | The physical pin connection, configurable for voltage, drive strength, and other electrical parameters. |
Power domain | Defines performance and power behavior, such as HP, ULP, and UULP. |
Interrupt | A hardware signal that halts execution to handle an event, such as a pin state change. |
Callback | A user-defined function triggered by GPIO driver events. |
Drive strength | The maximum current the pin can source or sink. |
Slew rate | The rate of voltage transition for an output pin. |
Pad voltage | The voltage applied to the GPIO pad (1.8 V or 3.3 V). |
REN (Receiver enable) | Enables input mode for a GPIO pad. |
Pinmux | Allows a pin to serve multiple roles (GPIO, SPI, UART, and so on). |
Direction | Defines whether a pin operates as an input or output. |
Open-Drain | An output mode that can only drive LOW and requires an external pull-up resistor. |
Port | A logical group of GPIOs. |
Pull-Up/Pull-Down Resistors | Maintain defined states when not driven. |
Tri-State (High-Z) | A high impedance state where the pin neither drives nor sinks current. |
Acronyms#
Acronym | Definition |
|---|---|
HP | High-performance (domain) |
ULP | Ultra-low-power (domain) |
UULP | Ultra-ultra-low-power (domain) |
REN | Receiver enable |
PAD | Physical pin connection |
EGPIO | Enhanced general-purpose input/output |
Pinmux | Pin multiplexing |
Extended Examples#
The following examples demonstrate common GPIO configurations and interrupt-driven scenarios:
sl_si91x_gpio_detailed_example– Basic GPIO input/output and LED toggle in an HP domain.sl_si91x_gpio_example– Configures GPIO interrupt and toggles an HP GPIO.sl_si91x_gpio_group_example– Demonstrates multi-pin group interrupts.sl_si91x_gpio_ulp_example– Toggles ULP GPIO and configures a ULP pin interrupt.sl_si91x_gpio_uulp_example– Configures an interrupt in UULP domain.sl_si91x_ulp_gpio– Demonstrates ULP GPIO state transitions between PS4 and PS2.
Usage Scenarios and Code Snippets#
Scenario 1. Toggling an LED (HP GPIO)#
#include "sl_si91x_driver_gpio.h"
#include "rsi_debug.h"
#define LED_PORT SL_SI91X_GPIO_6_PORT
#define LED_PIN GPIO_PIN_NUMBER6
static sl_si91x_gpio_pin_config_t led_pin_config = {{LED_PORT, LED_PIN}, GPIO_OUTPUT};
void gpio_led_init(void) {
sl_status_t status = sl_gpio_driver_init();
if (status != SL_STATUS_OK) return;
sl_gpio_set_configuration(led_pin_config);
}
void gpio_led_toggle(void) {
sl_gpio_driver_toggle_pin(&led_pin_config.port_pin);
}Scenario 2. Button Interrupt Handling (HP GPIO)
#include "sl_si91x_driver_gpio.h"
#define BUTTON_PORT SL_SI91X_GPIO_11_PORT
#define BUTTON_PIN GPIO_PIN_NUMBER11
void button_callback(uint32_t intr) {
if (intr == PIN_INTR_0) {
printf("Button press detected!\n");
}
}
void button_init(void) {
sl_si91x_gpio_pin_config_t button_config = {{BUTTON_PORT, BUTTON_PIN}, GPIO_INPUT};
sl_gpio_set_configuration(button_config);
sl_gpio_driver_configure_interrupt(&button_config.port_pin, 0, SL_GPIO_INTERRUPT_RISE_EDGE, button_callback, 0);
}Scenario 3. Button Interrupt Handling (ULP GPIO)
#include "sl_si91x_driver_gpio.h"
#define BUTTON_PORT SL_SI91X_ULP_GPIO_11_PORT
#define BUTTON_PIN SL_SI91X_ULP_GPIO_11_PIN
void ulp_button_callback(uint32_t intr) {
if (intr == ULP_PIN_INTR_0) {
printf("ULP Button interrupt triggered\n");
}
}
void ulp_button_init(void) {
sl_si91x_gpio_pin_config_t ulp_button_config = {{BUTTON_PORT, BUTTON_PIN}, GPIO_INPUT};
sl_gpio_set_configuration(ulp_button_config);
sl_gpio_driver_configure_interrupt(&ulp_button_config.port_pin, 0, SL_GPIO_INTERRUPT_RISE_EDGE, ulp_button_callback, 0);
}Scenario 4. Group Interrupt Example (HP and ULP GPIO)#
#include "sl_si91x_driver_gpio.h"
#define PIN_COUNT 2
sl_si91x_gpio_pin_config_t hp_pins[PIN_COUNT] = {
{{SL_SI91X_GPIO_8_PORT, GPIO_PIN_NUMBER8}, GPIO_INPUT},
{{SL_SI91X_GPIO_9_PORT, GPIO_PIN_NUMBER9}, GPIO_INPUT}
};
sl_si91x_gpio_group_interrupt_config_t group_config;
void group_callback(uint32_t grp_intr) {
if (grp_intr == GROUP_INT_1) {
printf("Group interrupt triggered\n");
}
}
void group_init(void) {
sl_gpio_driver_init();
for (int i = 0; i < PIN_COUNT; i++) sl_gpio_set_configuration(hp_pins[i]);
group_config.grp_interrupt = GROUP_INT_1;
group_config.grp_interrupt_cnt = PIN_COUNT;
group_config.and_or = GPIO_AND;
group_config.level_edge = GPIO_LEVEL;
sl_si91x_gpio_driver_configure_group_interrupt(&group_config, group_callback);
}Reference#
Example | Description | Link |
|---|---|---|
GPIO Detailed Example | HP GPIO toggling | |
GPIO Example | Basic GPIO with interrupt | |
GPIO Group Example | Multi-pin group interrupt | |
GPIO ULP Example | Low-power GPIO control | |
GPIO UULP Example | UULP domain interrupt demo | |
ULP GPIO State Transition | Demonstrates ULP GPIO between PS4/PS2 |
FAQ#
Q1: What’s the difference between HP, ULP, and UULP GPIOs?
HP GPIOs operate in active mode for performance-critical tasks.
ULP GPIOs function in deep-sleep and low-power states.
UULP GPIOs remain active in the lowest power states with minimal leakage.
Q2: How should GPIOs be configured before sleep?
Set outputs to safe states.
Enable pull-ups or pull-down resistors as needed.
Disable unused interrupts.
Save configuration if necessary.
Q3: How do I recover from undefined GPIO states?
sl_gpio_driver_deinit();
sl_gpio_driver_init();Q4: What are some common GPIO error codes?
Error Code | Meaning |
|---|---|
SL_STATUS_OK | Operation successful |
SL_STATUS_FAIL | General failure |
SL_STATUS_INVALID_PARAMETER | Invalid configuration input |
SL_STATUS_BUSY | Peripheral busy |
Q5: How can I debug GPIO issues?
Probe signal transitions with a logic analyzer.
Check pad configuration (pulls, drive strength).
Confirm pinmux settings for multifunction pins.
Use the Energy Profiler in Simplicity Studio to verify wake behavior.