08-26-2019 08:51 AM - edited 08-26-2019 10:45 AM
I see many examples online for using ZYNQ general purpose interrupt controller, but what If I just want to install an interrupt callback function for when I connect only the "Core_nIRQ" signal from PL->ZYNQ. Where can I find the broiler plate c-function just for installing this type of callback function?
08-26-2019 10:07 AM - edited 08-26-2019 10:47 AM
Hint: DeviceID for nIRQ is in XSDK header file "./<appname>_bsp/ps7_cortexa9_0/include/xparameters_ps.h":
... #define XPS_IRQ_INT_ID 31U /* IRQ from FPGA fabric */ // <<===== ... #define XPS_FIQ_INT_ID 28U /* FIQ from FPGA fabric */ ...
08-26-2019 10:44 AM - edited 08-27-2019 12:41 PM
#include <stdio.h>
#include "xparameters.h"
#include "Xscugic.h"
#include "Xil_exception.h"
typedef void fpga_irq_callback_t(void*);
void fpga_irq_callback(void *CallBackRef)
{
xil_printf("FPGA Interrupt Event\n\r");
}
void fpga_irq_installer(fpga_irq_callback_t callback)
{
static XScuGic Intc;
static u32 FPGA;
XScuGic_Config* IntcConfig;
Xil_ExceptionInit();
IntcConfig = XScuGic_LookupConfig(XPAR_SCUGIC_SINGLE_DEVICE_ID);
XScuGic_CfgInitialize(
&Intc,
IntcConfig,
IntcConfig->CpuBaseAddress
);
Xil_ExceptionRegisterHandler(
XIL_EXCEPTION_ID_INT,
(Xil_ExceptionHandler)XScuGic_InterruptHandler,
&Intc
);
XScuGic_Connect(
&Intc,
XPS_IRQ_INT_ID,
(Xil_ExceptionHandler)callback,
(void *)&FPGA
);
XScuGic_Enable(&Intc, XPS_IRQ_INT_ID);
Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);
xil_printf("Interrupt Set Up\n\r");
}
int main()
{
fpga_irq_installer(fpga_irq_callback);
// Wait for Interrupts....
printf("Waiting for Interrupts... \n\r");
while(1){}
return 0;
}