Questions about example code in Github: gpio_example_main.c
Posted: Fri May 29, 2020 4:33 pm
I am trying to understand ESP32 external interrupts so decided to test "gpio_example_main.c" example found on Github repository: https://github.com/espressif/esp-idf/bl ... ple_main.c
Some definitions are not clear to me:
Some definitions are not clear to me:
- Is it necessary to disable the interrupt if the pin is output?
Code: Select all
64: io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
- Why "GPIO_INPUT_IO_0" interrupt type is defined repeatedly on lines 77 and 87? Would not be sufficient to define it once?
Code: Select all
77: io_conf.intr_type = GPIO_PIN_INTR_POSEDGE;
87: gpio_set_intr_type(GPIO_INPUT_IO_0, GPIO_INTR_ANYEDGE);
- Why no interrupt type for "GPIO_INPUT_IO_1" is missing?
- Why ISR handler for "GPIO_INPUT_IO_0" added and then removed and added again?
Code: Select all
97: gpio_isr_handler_add(GPIO_INPUT_IO_0, gpio_isr_handler, (void*) GPIO_INPUT_IO_0);
102: gpio_isr_handler_remove(GPIO_INPUT_IO_0);
104: gpio_isr_handler_add(GPIO_INPUT_IO_0, gpio_isr_handler, (void*) GPIO_INPUT_IO_0);