Enhanced General-Purpose Input/Output (EGPIO) API Reference#
The WiSeConnect software development kit (SDK) provides a unified set of enhanced general-purpose input/output (EGPIO) application programming interfaces (APIs) for configuring and controlling GPIO pins on SiWx917 devices. These APIs support input and output operations, interrupt handling, and pin multiplexing across high-performance (HP), ultra-low-power (ULP), and ultra-ultra-low-power (UULP) domains.
This section summarizes commonly used APIs and provides examples to help you integrate GPIO functionality into your application.
Public APIs#
Use these APIs to initialize the GPIO subsystem, configure pin characteristics, and read or write pin values.
For complete API definitions, data types, macros, and usage examples, see the SiWx917 GPIO and EGPIO API Reference Guide.
These APIs include functions for:
Configuring GPIO pin direction (input or output)
Setting and reading pin states (HIGH or LOW)
Enabling internal pull-up or pull-down resistors
Managing EGPIO pin multiplexing
Configuring high-performance and low-power pin modes
Initialization#
sl_gpio_driver_init();
sl_gpio_driver_deinit();These functions enable or disable the GPIO driver and prepare the hardware for operation.
Pin Configuration#
Use configuration APIs to set direction, mode, and pad attributes.
API | Description |
|---|---|
| Sets a pin as input or output. |
| Applies a full configuration structure for a pin. |
| Sets the GPIO drive strength. |
| Sets pin mode and output type. |
Pin configuration options vary depending on whether the target pin is in the HP, ULP, or UULP domain.
Pin State Control#
Use these APIs to drive GPIO output values or read input states.
API | Description |
|---|---|
| Drives the output HIGH. |
| Drives the output LOW. |
| Toggles the current value. |
| Reads the input state for a configured pin. |
Callback and Interrupt APIs#
Callback and interrupt APIs enable asynchronous event handling by registering application-defined interrupt service routines for GPIO activity. This mechanism allows applications to respond efficiently to input transitions or external hardware events without continuous polling.
Supported Callback Registrations#
Callback Type | Description | API Reference |
|---|---|---|
HP / ULP / UULP Pin Interrupts | Register interrupt callbacks for individual GPIO pins across high-performance, ultra-low-power, and ultra-ultra-low-power domains. | |
MCU HP Group Interrupts | Configure and register callbacks for MCU group-level interrupts in HP mode. | |
MCU ULP Group Interrupts | Configure and register callbacks for MCU ULP group-level interrupts in low-power operation. |
Example: GPIO Interrupt Callback Registration#
#include "sl_si91x_gpio.h"
/* Pin config for PORT 0, PIN 5 */
static sl_si91x_gpio_pin_config_t gpio_pin5_cfg = { { GPIO_PORT_0, GPIO_PIN_5 }, GPIO_INPUT };
// Example callback for GPIO interrupt
void gpio_event_callback(uint8_t pin_number) {
printf("Interrupt detected on GPIO pin: %d\n", pin_number);
}
void configure_gpio(void) {
// Initialize GPIO driver
sl_gpio_driver_init();
// Configure pin as input
sl_gpio_set_configuration(gpio_pin5_cfg);
// Register callback for rising edge detection
sl_gpio_driver_configure_interrupt(&gpio_pin5_cfg.port_pin,
interrupt_channel,
SL_GPIO_INTERRUPT_RISE_EDGE,
&gpio_event_callback,
0);
}Example: Group Interrupt Handling#
#include "sl_si91x_gpio.h"
// Example callback for group interrupt
void gpio_group_callback(uint8_t group_id) {
printf("Group interrupt triggered: Group %d\n", group_id);
}
void configure_group_interrupt(void) {
// Configure HP group interrupt for multiple pins
sl_si91x_gpio_driver_configure_group_interrupt(&Config_group_struct, &gpio_group_callback);
}