标签:ioi 外部 inter interrupt 设置 _id ref 编译 dir
1. ZYNQ中断简述
XGpio KEYInst;
XScuGic INTCInst;
int main(void)
{
// initial KEY
int status;
status = XGpio_Initialize(&KEYInst, KEY_DEVICE_ID);
if(status != XST_SUCCESS)
return XST_FAILURE;
// set KEY IO direction as in
XGpio_SetDataDirection(&KEYInst, 1, 0xFF);
// initial interrupt controller
status = IntcInitFunction(INTC_DEVICE_ID, &KEYInst);
if(status != XST_SUCCESS)
return XST_FAILURE;
while(1);
return 0;
}
//----------------------------------------------------------------------------
// This is the interrupt handler routine for the GPIO for this example
//----------------------------------------------------------------------------
void GpioHandler(void CallbackRef)
{
XGpio GpioPtr = (XGpio *)CallbackRef;
/* Clear the Interrupt */
XGpio_InterruptClear(GpioPtr, GlobalIntrMask);
}
//----------------------------------------------------------------------------
// Interrupt controller initial function
//----------------------------------------------------------------------------
static int IntcInitFunction(u16 DeviceId, XGpio GpioInstancePtr)
{
XScuGic_Config IntcConfig;
int status;
// Interrupt controller initialization
IntcConfig = XScuGic_LookupConfig(DeviceId);
status = XScuGic_CfgInitialize(&INTCInst, IntcConfig, IntcConfig->CpuBaseAddress);
if(status != XST_SUCCESS)
return XST_FAILURE;
// Call interrupt setup function
Xil_ExceptionInit();
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
(Xil_ExceptionHandler)XScuGic_InterruptHandler, XScuGicInstancePtr);
Xil_ExceptionEnable();
// Register GPIO interrupt handler
status = XScuGic_Connect(&INTCInst, INTC_GPIO_INTERRUPT_ID,
(Xil_ExceptionHandler)GpioHandler, (void*)GpioInstancePtr);
if(status != XST_SUCCESS)
return XST_FAILURE;
// Enable GPIO interrupts
XGpio_InterruptEnable(GpioInstancePtr, 1);
XGpio_InterruptGlobalEnable(GpioInstancePtr);
// Enable GPIO interrupts in the controller
XScuGic_Enable(&INTCInst, INTC_GPIO_INTERRUPT_ID);
return XST_SUCCESS;
}
**3. 编译运行**
下载FPGA代码,以Hardware运行软件
标签:ioi 外部 inter interrupt 设置 _id ref 编译 dir
原文地址:https://blog.51cto.com/shugenyin/2429397