Niklas Rosencrantz
Niklas Rosencrantz

Reputation: 26647

Understanding a C prototype

A function prototype is

int alt_irq_register (alt_u32 id, void* context, void (*isr)(void*, alt_u32));

What does the last part mean? What is the *isr doing?

Upvotes: 2

Views: 724

Answers (2)

Federico
Federico

Reputation: 3892

It is a pointer to a function. You must use a function as parameter of the alt_irq_register function. Example:

void irq_handler(void *ptr, alt_u32 val) { /* my function */
    /* I'm handling the interupt */
}
int alt_irq_register (alt_u32 id, void* context, void (*isr)(void*, alt_u32));

In your code, you must use alt_irq_register function in this way:

/* your code */
ret = alt_irq_register(id, context_ptr, irq_handler);
/* other code */

I am supposing that this function register and interrupt handler, so during the registration you are passing to the system the function that it must uses when the associated interrupt occur.

Upvotes: 5

rici
rici

Reputation: 241701

It's a pointer to a function. The function takes two arguments (void* and alt_u32) and returns nothing (void). Its parameter name is isr.

Upvotes: 2

Related Questions