GPIO isr service

zliudr
Posts: 360
Joined: Thu Oct 03, 2019 5:15 am

GPIO isr service

Postby zliudr » Sun Nov 17, 2019 5:13 pm

I am trying to understand how to add interrupt handler for gpio pin changes. I'm using the gpio sample code that has this snippet to do it:

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);
I assume in a more complex program that has other libraries and code already in place, the gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT); call may have been made by some code outside my control. Is there any harm calling it again, in my code? If so, how to check if the call has been made? Thanks.

boarchuz
Posts: 605
Joined: Tue Aug 21, 2018 5:28 am

Re: GPIO isr service

Postby boarchuz » Sun Nov 17, 2019 8:45 pm

It's safe:

https://github.com/espressif/esp-idf/bl ... pio.h#L631
return ESP_ERR_INVALID_STATE ISR service already installed.

zliudr
Posts: 360
Joined: Thu Oct 03, 2019 5:15 am

Re: GPIO isr service

Postby zliudr » Mon Nov 18, 2019 1:53 am

Great! Thanks. Now I also get to see the prototypes of all gpio functions on one page. I remember that I printed a matrix out with all GPIO pins and their features. I think most are I/O and a few are I only. I don't remember if the matrix mentions pu/pd resistors. Do all pins have pu/pd resistors?

Who is online

Users browsing this forum: julcol and 130 guests