Forum Discussion
Altera_Forum
Honored Contributor
12 years ago --- Quote Start --- One more question, in handle_my_interrupt(void * context, uint32_t id) I have to work with some variables that are defined in main(). So, I have added some pointers to the handle_my_interrup function: handle_my_interrup(void * context, uint32_t id, uint8_t * var_ptr1 , uint8_t var_ptr1). --- Quote End --- Yes, as the compiler warning suggests, you can't do it that way. The interrupt routines in the HAL are supposed to follow a strict prototype, with only two arguments. If you need to pass more parameters to your ISR, then the trick is to place them in a structure, and use the address of that structure as context. Something like this (I didn't try to compile it, there could be some syntax errors):
typedef struct my_isr_context_t {
int capture;
uint8_t *var_ptr1;
uint8_t var_2;
} my_isr_context_t;
volatile my_isr_context_t my_isr_context;
# ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
alt_ic_isr_register(MY_PIO_IRQ_INTERRUPT_CONTROLLER_ID, MY_PIO_IRQ, handle_my_interrupt, &my_isr_context, 0x0);
# else
alt_irq_register(MY_PIO_IRQ, edge_capture_ptr, &my_isr_context);
Then in your ISR, you cast the void* context to a my_isr_context_t* and access the different structure members.