Chapter 2. API Reference
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
Parameters
• gpio_num: GPIO number. If you want to set the trigger type of e.g. of GPIO16, gpio_num should
be GPIO_NUM_16 (16);
• intr_type: Interrupt type, select from gpio_int_type_t
esp_err_t gpio_intr_enable(gpio_num_t gpio_num)
Enable GPIO module interrupt signal.
Note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC or Wi-Fi with sleep
mode enabled. Please refer to the comments of adc1_get_raw. Please refer to section 3.11 of
‘ECO_and_Workarounds_for_Bugs_in_ESP32’for the description of this issue. As a workaround, call
adc_power_acquire() in the app. This will result in higher power consumption (by ~1mA), but will re-
move the glitches on GPIO36 and GPIO39.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
Parameters
• gpio_num: GPIO number. If you want to enable an interrupt on e.g. GPIO16, gpio_num should
be GPIO_NUM_16 (16);
esp_err_t gpio_intr_disable(gpio_num_t gpio_num)
Disable GPIO module interrupt signal.
Return
• ESP_OK success
• ESP_ERR_INVALID_ARG Parameter error
Parameters
• gpio_num: GPIO number. If you want to disable the interrupt of e.g. GPIO16, gpio_num should
be GPIO_NUM_16 (16);
esp_err_t gpio_set_level(gpio_num_t gpio_num, uint32_t level)
GPIO set output level.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG GPIO number error
Parameters
• gpio_num: GPIO number. If you want to set the output level of e.g. GPIO16, gpio_num should
be GPIO_NUM_16 (16);
• level: Output level. 0: low ; 1: high
int gpio_get_level(gpio_num_t gpio_num)
GPIO get input level.
Warning If the pad is not configured for input (or input and output) the returned value is always 0.
Return
• 0 the GPIO input level is 0
• 1 the GPIO input level is 1
Parameters
• gpio_num: GPIO number. If you want to get the logic level of e.g. pin GPIO16, gpio_num should
be GPIO_NUM_16 (16);
esp_err_t gpio_set_direction(gpio_num_t gpio_num, gpio_mode_t mode)
GPIO set direction.
Configure GPIO direction,such as output_only,input_only,output_and_input
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG GPIO error
Parameters
Espressif Systems 251
Submit Document Feedback
Release v4.4