Specifications

The driver for an EIC can provide specialized functions to manage any implementation-specific features
of the EIC. An example would be modifying interrupt priority levels at runtime.
For more information, refer to the examples in the "Vectored Interrupt Controller Core" chapter in the
Embedded Peripherals IP User Guide.
Related Information
Vectored Interrupt Controller Core
C Example
An ISR to Service a Button PIO Interrupt
This example is based on a Nios II system with a 4-bit PIO peripheral connected to push buttons. An IRQ
is generated any time a button is pushed. The ISR code reads the PIO peripheral’s edge capture register
and stores the value to a global variable. The address of the global variable is passed to the ISR in the
context pointer.
Example 8-1: Example 8–1. An ISR to Service a Button PIO Interrupt
#include "system.h"
#include "altera_avalon_pio_regs.h"
#include "alt_types.h"
#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
static void handle_button_interrupts(void* context)
#else
static void handle_button_interrupts(void* context, alt_u32 id)
#endif
{
/* Cast context to edge_capture's type. It is important that this
be declared volatile to avoid unwanted compiler optimization. */
volatile int* edge_capture_ptr = (volatile int*) context;
/*
* Read the edge capture register on the button PIO.
* Store value.
*/
*edge_capture_ptr =
IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE);
/* Write to the edge capture register to reset it. */
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0);
/* Read the PIO to delay ISR exit. This is done to prevent a
spurious interrupt in systems with high processor -> pio
latency and fast interrupts. */
IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE);
}
Registering the Button PIO ISR with the HAL
Based on the code in the example, the following execution flow is possible:
NII5V2
2015.05.14
C Example
8-15
Exception Handling
Altera Corporation
Send Feedback