Adding, removing and re-adding an ISR handle in the GPIO sample ...

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Adding, removing and re-adding an ISR handle in the GPIO sample ...

Postby kolban » Sun Jan 15, 2017 8:17 pm

Folks,
Am studying the GPIO sample found here:

https://github.com/espressif/esp-idf/bl ... pio_test.c

Specifically, I am looking at the following code fragment found within:

Code: Select all

    //install gpio isr service
    gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);
    //hook isr handler for specific gpio pin
    gpio_isr_handler_add(GPIO_INPUT_IO_0, gpio_isr_handler, (void*) GPIO_INPUT_IO_0);
    //hook isr handler for specific gpio pin
    gpio_isr_handler_add(GPIO_INPUT_IO_1, gpio_isr_handler, (void*) GPIO_INPUT_IO_1);

    //remove isr handler for gpio number.
    gpio_isr_handler_remove(GPIO_INPUT_IO_0);
    //hook isr handler for specific gpio pin again
    gpio_isr_handler_add(GPIO_INPUT_IO_0, gpio_isr_handler, (void*) GPIO_INPUT_IO_0);
Unfortunately, I'm not understanding a portion of it. We appear to associate an ISR handler with GPIO0, remove the ISR handler and then immediately re-add it. I'm not understanding the nature of that task. I can see why we would add it once, but not why we remove it and then immediately re-add it.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Adding, removing and re-adding an ISR handle in the GPIO sample ...

Postby WiFive » Mon Jan 16, 2017 12:07 am

Its just a demo, in the real world some things would happen in between removing it and readding it.

Who is online

Users browsing this forum: Baidu [Spider], ccrause and 246 guests