gpio_intr_enable() unnecessary?
Posted: Thu Aug 03, 2023 2:32 pm
1: I just wrote a minimal code example to enable a rising-edge Interrupt for a GPIO using the IDF 5.1. The code works and the Interrupt is detected, however I noticed that calling the function "gpio_intr_enable()" is completely unnecessary:
When I comment out the line "gpio_intr_enable(gpio_num)" the interrupt is still detected.
Another thing I noticed: I can even disable the interrupt using "gpio_intr_disable(gpio_num)" and the Interrupt is still detected:
Can anyone explain this?
2: I noticed that there are multiple ways to configure the interrupt type for a GPIO:
- esp_err_t gpio_config(const gpio_config_t *pGPIOConfig) --> "gpio_config_t" has a member "gpio_int_type_t intr_type"
- esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type) --> sets intr_type
This seems redundant and I am wondering if one of the functions is intended to be deprecated? Which one should be used?
Best regards
Code: Select all
gpio_num_t gpio_num = GPIO_NUM_0;
// [set gpio_num as input, enable pullups etc.... ]
gpio_set_intr_type(gpio_num, GPIO_INTR_POSEDGE);
gpio_intr_enable(gpio_num);
gpio_install_isr_service(0);
gpio_isr_handler_add(gpio_num, gpio_isr_handler, (void*) gpio_num);
Another thing I noticed: I can even disable the interrupt using "gpio_intr_disable(gpio_num)" and the Interrupt is still detected:
Code: Select all
gpio_num_t gpio_num = GPIO_NUM_0;
// [set gpio_num as input, enable pullups etc.... ]
gpio_set_intr_type(gpio_num, GPIO_INTR_POSEDGE);
gpio_intr_disable(gpio_num); // DISABLE Interrupt, but still works!
gpio_install_isr_service(0);
gpio_isr_handler_add(gpio_num, gpio_isr_handler, (void*) gpio_num);
2: I noticed that there are multiple ways to configure the interrupt type for a GPIO:
- esp_err_t gpio_config(const gpio_config_t *pGPIOConfig) --> "gpio_config_t" has a member "gpio_int_type_t intr_type"
- esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type) --> sets intr_type
This seems redundant and I am wondering if one of the functions is intended to be deprecated? Which one should be used?
Best regards