Chapter 2. API Reference
• gpio_num: Configure GPIO pins number, it should be GPIO number. If you want to set direction
of e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
• mode: GPIO direction
esp_err_t gpio_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull)
Configure GPIO pull-up/pull-down resistors.
Only pins that support both input & output have integrated pull-up and pull-down resistors. Input-only GPIOs
34-39 do not.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG : Parameter error
Parameters
• gpio_num: GPIO number. If you want to set pull up or down mode for e.g. GPIO16, gpio_num
should be GPIO_NUM_16 (16);
• pull: GPIO pull up/down mode.
esp_err_t gpio_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type)
Enable GPIO wake-up function.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
Parameters
• gpio_num: GPIO number.
• intr_type: GPIO wake-up type. Only GPIO_INTR_LOW_LEVEL or
GPIO_INTR_HIGH_LEVEL can be used.
esp_err_t gpio_wakeup_disable(gpio_num_t gpio_num)
Disable GPIO wake-up function.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
Parameters
• gpio_num: GPIO number
esp_err_t gpio_isr_register(void (*fn))void *
, void *arg, int intr_alloc_flags, gpio_isr_handle_t *handleRegister GPIO interrupt handler, the handler is an
ISR. The handler will be attached to the same CPU core that this function is running on.
This ISR function is called whenever any GPIO interrupt occurs. See the alternative gpio_install_isr_service()
and gpio_isr_handler_add() API in order to have the driver support per-GPIO ISRs.
To disable or remove the ISR, pass the returned handle to the interrupt allocation functions.
Parameters
• fn: Interrupt handler function.
• arg: Parameter for handler function
• intr_alloc_flags: Flags used to allocate the interrupt. One or multiple (ORred)
ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
• handle: Pointer to return handle. If non-NULL, a handle for the interrupt will be returned here.
Return
• ESP_OK Success ;
• ESP_ERR_INVALID_ARG GPIO error
• ESP_ERR_NOT_FOUND No free interrupt found with the specified flags
esp_err_t gpio_pullup_en(gpio_num_t gpio_num)
Enable pull-up on GPIO.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
Espressif Systems 252
Submit Document Feedback
Release v4.4