kyrpav
kyrpav

Reputation: 778

Interrupt implementation gives error on initialization at build

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.


Upvotes: 0

Views: 444

Answers (1)

romkey
romkey

Reputation: 7054

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
}

Upvotes: 1

Related Questions