//////////////////////////// InitializeInterruptSystem//////////////////////////////// int InitializeInterruptSystem(u16 deviceID) { int Status; GicConfig = XScuGic_LookupConfig (deviceID); if(NULL == GicConfig) { return XST_FAILURE; } Status = XScuGic_CfgInitialize(&InterruptController, GicConfig, GicConfig->CpuBaseAddress); if(Status != XST_SUCCESS) { return XST_FAILURE; } Status = SetUpInterruptSystem(&InterruptController); if(Status != XST_SUCCESS) { return XST_FAILURE; } Status = XScuGic_Connect (&InterruptController, XPAR_FABRIC_AXI_DMA_0_S2MM_INTROUT_INTR, (Xil_ExceptionHandler) InterruptHandler, NULL); if(Status != XST_SUCCESS) { return XST_FAILURE; } XScuGic_Enable(&InterruptController, XPAR_FABRIC_AXI_DMA_0_S2MM_INTROUT_INTR ); return XST_SUCCESS; }
int IntcExample(u16 DeviceId) { int Status; Status = XIntc_Initialize(&InterruptController, DeviceId); if (Status != XST_SUCCESS) { return XST_FAILURE; } Status = XIntc_SelfTest(&InterruptController); if (Status != XST_SUCCESS) { return XST_FAILURE; } Status = SetUpInterruptSystem(&InterruptController); if (Status != XST_SUCCESS) { return XST_FAILURE; } Status = XIntc_SimulateIntr(&InterruptController, INTC_DEVICE_INT_ID); if (Status != XST_SUCCESS) { return XST_FAILURE; } while (1) { if (InterruptProcessed) { break; } } return XST_SUCCESS; }
/** * * This function is an example of how to use the IO Module driver component * (XIOModule) and the hardware device. This function is designed to work * without external hardware devices to cause interrupts. It may not return if * the IO Module is not properly connected to the processor in either software * or hardware. * * @param DeviceId is device ID of the IO Module Device, typically * XPAR_<IOMODULE_instance>_DEVICE_ID value from xparameters.h * * @return XST_SUCCESS to indicate success, otherwise XST_FAILURE * * @note None. * ******************************************************************************/ XStatus IOModuleExample(u16 DeviceId) { XStatus Status; /* * Initialize the IO Module driver so that it is ready to use. */ Status = XIOModule_Initialize(&IOModule, DeviceId); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Perform a self-test to ensure that the hardware was built correctly. */ Status = XIOModule_SelfTest(&IOModule); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Setup the Interrupt System. */ Status = SetUpInterruptSystem(&IOModule); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Generate the interrupts. */ Status = XOModule_GenerateIntr(&IOModule); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Wait for the interrupts to be processed, if no interrupt occurs this * loop will wait forever. */ while (1) { /* * If the interrupts occurred which is indicated by the global * variable which is set in the device driver handler, then * stop waiting */ if (InterruptProcessed) { break; } } return XST_SUCCESS; }
int ScuGicExample(u16 DeviceId) { int Status; /* * Initialize the interrupt controller driver so that it is ready to * use. */ GicConfig = XScuGic_LookupConfig(DeviceId); if (NULL == GicConfig) { return XST_FAILURE; } Status = XScuGic_CfgInitialize(&InterruptController, GicConfig, GicConfig->CpuBaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Perform a self-test to ensure that the hardware was built * correctly */ Status = XScuGic_SelfTest(&InterruptController); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Setup the Interrupt System */ Status = SetUpInterruptSystem(&InterruptController); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Connect a device driver handler that will be called when an * interrupt for the device occurs, the device driver handler performs * the specific interrupt processing for the device */ Status = XScuGic_Connect(&InterruptController, INTC_DEVICE_INT_ID, (Xil_ExceptionHandler)DeviceDriverHandler, (void *)&InterruptController); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Enable the interrupt for the device and then cause (simulate) an * interrupt so the handlers will be called */ XScuGic_Enable(&InterruptController, INTC_DEVICE_INT_ID); return XST_SUCCESS; }
/** * * This function is an example of how to use the interrupt controller driver * (XScuGic) and the hardware device. This function is designed to * work without any hardware devices to cause interrupts. It may not return * if the interrupt controller is not properly connected to the processor in * either software or hardware. * * This function relies on the fact that the interrupt controller hardware * has come out of the reset state such that it will allow interrupts to be * simulated by the software. * * @param DeviceId is Device ID of the Interrupt Controller Device, * typically XPAR_<INTC_instance>_DEVICE_ID value from * xparameters.h * * @return XST_SUCCESS to indicate success, otherwise XST_FAILURE * * @note None. * ******************************************************************************/ int ScuGicExample(u16 DeviceId) { int Status; /* * Initialize the interrupt controller driver so that it is ready to * use. */ GicConfig = XScuGic_LookupConfig(DeviceId); if (NULL == GicConfig) { return XST_FAILURE; } Status = XScuGic_CfgInitialize(&InterruptController, GicConfig, GicConfig->CpuBaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Perform a self-test to ensure that the hardware was built * correctly */ Status = XScuGic_SelfTest(&InterruptController); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Setup the Interrupt System */ Status = SetUpInterruptSystem(&InterruptController); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Connect a device driver handler that will be called when an * interrupt for the device occurs, the device driver handler performs * the specific interrupt processing for the device */ Status = XScuGic_Connect(&InterruptController, INTC_DEVICE_INT_ID, (Xil_ExceptionHandler)DeviceDriverHandler, (void *)&InterruptController); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Enable the interrupt for the device and then cause (simulate) an * interrupt so the handlers will be called */ XScuGic_Enable(&InterruptController, INTC_DEVICE_INT_ID); /* * Simulate the Interrupt */ Status = XScuGic_SoftwareIntr(&InterruptController, INTC_DEVICE_INT_ID, XSCUGIC_SPI_CPU0_MASK); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Wait for the interrupt to be processed, if the interrupt does not * occur this loop will wait forever */ while (1) { /* * If the interrupt occurred which is indicated by the global * variable which is set in the device driver handler, then * stop waiting */ if (InterruptProcessed) { break; } } return XST_SUCCESS; }