Specifications

Registering an ISR with the Enhanced Interrupt API
Before the software can use an ISR, you must register it by calling alt_ic_isr_register(). The
prototype for alt_ic_isr_register() is:
int alt_ic_isr_register(alt_u32 ic_id,
alt_u32 irq,
alt_isr_func isr,
void *isr_context,
void* flags)
The function has the following parameters:
ic_id is the interrupt controller identifier (ID) as defined in system.h. With daisychained EICs, ic_id
identifies the EIC in the daisy chain. With the IIC, ic_id is not significant.
irq is the hardware interrupt number for the device, as defined in system.h.
For the IIC, irq is the IRQ number. Interrupt priority corresponds inversely to the IRQ number.
Therefore, IRQ
0
represents the highest priority interrupt and IRQ
31
is the lowest.
For an EIC, irq is the interrupt port ID.
isr_context points to a data structure associated with the device driver instance. isr_context is
passed as the input argument to the isr function. It is used to pass context-specific information to the
ISR, and can point to any ISR-specific information. The context value is opaque to the HAL; it is
provided entirely for the benefit of the user-defined ISR.
isr is a pointer to the ISR function that is called in response to IRQ number irq. The ISR function
prototype is:
void (void* isr_context);
The input argument provided to this function is the isr_context.
Note:
Registering a null pointer for isr results in the interrupt being disabled.
flags is reserved.
Related Information
The Enhanced HAL Interrupt API
Methods the HAL Uses to Register the ISR
The HAL registers the ISR by one of the following methods:
For the IIC, by the storing the function pointer, isr, in a lookup table.
For an EIC, by configuring the vector table with the appropriate funnel code
For more information, refer to the “Using Interrupt Funnels” chapter.
The return code from alt_ic_isr_register() is zero if the function succeeded, and nonzero if it failed.
If the HAL registers your ISR successfully, the associated Nios II hardware interrupt (as defined by irq) is
enabled on return from alt_ic_isr_register().
Note:
Hardware-specific initialization might also be required.
When a specific interrupt occurs, the HAL code ensures that the registered ISR is correctly dispatched.
For more information and details about hardware interrupt initialization specific to your peripheral, refer
to the relevant chapter of the Embedded Peripherals IP User Guide.
NII5V2
2015.05.14
Registering an ISR with the Enhanced Interrupt API
8-13
Exception Handling
Altera Corporation
Send Feedback