Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top