Home > other >  Interrupt implementation gives error on initialization at build
Interrupt implementation gives error on initialization at build

Time:02-16

i am trying to use esp32 and an pin interrupt in positive edge.

I have defined the gpio with this

gpio_config_t panel = {
        .pin_bit_mask = (1ULL << start_pin) || (1ULL << knot_pin),
        .mode = GPIO_MODE_INPUT,
        .pull_up_en= GPIO_PULLUP_DISABLE,
        .pull_down_en = GPIO_PULLDOWN_ENABLE,
        .intr_type = GPIO_INTR_POSEDGE
    };
    gpio_config(&panel);
    gpio_install_isr_service(0);
    gpio_isr_handler_add(start_pin,on_start_irs_handler,(void *)start_pin);
    gpio_isr_handler_add(knot_pin,on_knot_irs_handler,(void *)knot_pin);
    

So i have to write also the handler functions which is done with this code:

static void IRAM_ATTR on_start_irs_handler(void *args)(
// do something
)

static void IRAM_ATTR on_knot_irs_handler(void *args)(
// do something
)

On build i get this error:

expected initializer before 'static'

where the error is marked on the second function of the on_knot_irs_handler not at the first.

What is the proper declaration or definition or implementation.


CodePudding user response:

You wrote:

static void IRAM_ATTR on_start_irs_handler(void *args)(
// do something
)

static void IRAM_ATTR on_knot_irs_handler(void *args)(
// do something
)

C and C functions use curly braces to enclose code, not parentheses. This code should be:

static void IRAM_ATTR on_start_irs_handler(void *args) {
// do something
}

static void IRAM_ATTR on_knot_irs_handler(void *args) {
// do something
}
  • Related