Chapter 2. API Reference
To install a GPIO bundle, one needs to call dedic_gpio_new_bundle() to allocate the software resources
and connect the dedicated channels to user selected GPIOs. Configurations for a GPIO bundle are covered in
dedic_gpio_bundle_config_t structure:
• gpio_array: An array that contains GPIO number.
• array_size: Element number of gpio_array.
• flags: Extra flags to control the behavior of GPIO Bundle.
– in_en and out_en are used to select whether to enable the input and output function (note, they can
be enabled together).
– in_invert and out_invert are used to select whether to invert the GPIO signal.
The following code shows how to install a output only GPIO bundle:
// configure GPIO
const int bundleA_gpios[] = {0, 1};
gpio_config_t io_conf = {
.mode = GPIO_MODE_OUTPUT,
};
for (int i = 0; i < sizeof(bundleA_gpios) / sizeof(bundleA_gpios[0]); i++) {
io_conf.pin_bit_mask = 1ULL << bundleA_gpios[i];
gpio_config(&io_conf);
}
// Create bundleA, output only
dedic_gpio_bundle_handle_t bundleA = NULL;
dedic_gpio_bundle_config_t bundleA_config = {
.gpio_array = bundleA_gpios,
.array_size = sizeof(bundleA_gpios) / sizeof(bundleA_gpios[0]),
.flags = {
.out_en = 1,
},
};
ESP_ERROR_CHECK(dedic_gpio_new_bundle(&bundleA_config, &bundleA));
To uninstall the GPIO bundle, one needs to call dedic_gpio_del_bundle().
Note: dedic_gpio_new_bundle() doesn’t cover any GPIO pad configuration (e.g. pull up/down, drive
ability, output/input enable), so before installing a dedicated GPIO bundle, you have to configure the GPIO separately
using GPIO driver API (e.g. gpio_config()). For more information about GPIO driver, please refer to GPIO
API Reference.
GPIO Bundle Operations
Operations Functions
Write to GPIOs in the bundle by mask dedic_gpio_bundle_write()
Read the value that input to bundle dedic_gpio_bundle_read_out()
Read the value that output from bundle dedic_gpio_bundle_read_in()
Note: The functions above just wrap the customized instructions defined for ESP32-S2, for the details of those
instructions, please refer to ESP32-S2 Technical Reference Manual > IO MUX and GPIO Matrix (GPIO, IO_MUX)
[PDF].
Interrupt Handling
Dedicated GPIO can also trigger interrupt on specific input event. All supported events are defined in
dedic_gpio_intr_type_t.
Espressif Systems 268
Submit Document Feedback
Release v4.4