#include "xscugic.h" #include "xil_exception.h" // IRQ_F2P[0:0] #define INTC_INTERRUPT_ID_0 61 // function declaration int setup_interrupt_system(); void isr0 (void *intc_inst_ptr); // Global instance of interrupt controller static XScuGic intc; int main() { init_platform(); // setup and enable interrupts for IRQ_F2P[1:0] int status = setup_interrupt_system(); if (status != XST_SUCCESS) { return XST_FAILURE; } /* Your main function code here */ cleanup_platform(); return 0; } // interrupt service routine for IRQ_F2P[0:0] void isr0 (void *intc_inst_ptr) { xil_printf("Serving interrupt\n\r"); /* Your ISR code here */ } // sets up the interrupt system and enables interrupts for IRQ_F2P[1:0] int setup_interrupt_system() { int result; XScuGic *intc_instance_ptr = &intc; XScuGic_Config *intc_config; // get config for interrupt controller intc_config = XScuGic_LookupConfig(XPAR_PS7_SCUGIC_0_DEVICE_ID); if (NULL == intc_config) { return XST_FAILURE; } // initialize the interrupt controller driver result = XScuGic_CfgInitialize(intc_instance_ptr, intc_config, intc_config->CpuBaseAddress); if (result != XST_SUCCESS) { return result; } // set the priority of IRQ_F2P[0:0] to 0xA0 (highest 0xF8, lowest 0x00) and a trigger for a rising edge 0x3. XScuGic_SetPriorityTriggerType(intc_instance_ptr, INTC_INTERRUPT_ID_0, 0xA0, 0x3); // connect the interrupt service routine isr0 to the interrupt controller result = XScuGic_Connect(intc_instance_ptr, INTC_INTERRUPT_ID_0, (Xil_ExceptionHandler)isr0, (void *)&intc); if (result != XST_SUCCESS) { return result; } // enable interrupts for IRQ_F2P[0:0] XScuGic_Enable(intc_instance_ptr, INTC_INTERRUPT_ID_0); // set the priority of IRQ_F2P[1:1] to 0xA8 (highest 0xF8, lowest 0x00) and a trigger for a rising edge 0x3. XScuGic_SetPriorityTriggerType(intc_instance_ptr, INTC_INTERRUPT_ID_1, 0xA8, 0x3); // connect the interrupt service routine isr1 to the interrupt controller result = XScuGic_Connect(intc_instance_ptr, INTC_INTERRUPT_ID_1, (Xil_ExceptionHandler)isr1, (void *)&intc); if (result != XST_SUCCESS) { return result; } // enable interrupts for IRQ_F2P[1:1] XScuGic_Enable(intc_instance_ptr, INTC_INTERRUPT_ID_1); // initialize the exception table and register the interrupt controller handler with the exception table Xil_ExceptionInit(); Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XScuGic_InterruptHandler, intc_instance_ptr); // enable non-critical exceptions Xil_ExceptionEnable(); return XST_SUCCESS; }