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 used by the TestAppGen generated application to setup * the interrupt controller. * * @param IntcInstancePtr is the reference to the Interrupt Controller * instance. * @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 IntcInterruptSetup(XIntc *IntcInstancePtr, u16 DeviceId) { int Status; /* * Initialize the interrupt controller driver so that it is * ready to use. */ Status = XIntc_Initialize(IntcInstancePtr, DeviceId); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Perform a self-test to ensure that the hardware was built correctly. */ Status = XIntc_SelfTest(IntcInstancePtr); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Initialize the exception table. */ Xil_ExceptionInit(); /* * Register the interrupt controller handler with the exception table. */ Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XIntc_DeviceInterruptHandler, (void*) 0); /* * Enable exceptions. */ Xil_ExceptionEnable(); /* * Start the interrupt controller such that interrupts are enabled for * all devices that cause interrupts. */ Status = XIntc_Start(IntcInstancePtr, XIN_REAL_MODE); if (Status != XST_SUCCESS) { return XST_FAILURE; } return XST_SUCCESS; }
/** * * This function runs a self-test on the driver/device. This is a destructive * test. This function is an example of how to use the interrupt controller * driver component (XIntc) 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 IntcSelfTestExample(u16 DeviceId) { int Status; /* * Initialize the interrupt controller driver so that it is ready to use. */ Status = XIntc_Initialize(&InterruptController, DeviceId); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Perform a self-test to ensure that the hardware was built correctly. */ Status = XIntc_SelfTest(&InterruptController); if (Status != XST_SUCCESS) { return XST_FAILURE; } return XST_SUCCESS; }
/** * * This function connects the interrupt handler of the interrupt controller to * the processor. This function is seperate to allow it to be customized for * each application. Each processor or RTOS may require unique processing to * connect the interrupt handler. * * @param None. * * @return None. * * @note None. * ****************************************************************************/ int setUpInterruptSystem() { int Status; /* * Initialize the interrupt controller driver so that it is ready to * use. */ Status = XIntc_Initialize(&InterruptController, INTC_DEVICE_ID); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Perform a self-test to ensure that the hardware was built * correctly. */ Status = XIntc_SelfTest(&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 = XIntc_Connect(&InterruptController, INTC_DEVICE_INT_ID, (XInterruptHandler)hwTimerISR, (void *)0); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Start the interrupt controller such that interrupts are enabled for * all devices that cause interrupts, specify simulation mode so that * an interrupt can be caused by software rather than a real hardware * interrupt. */ Status = XIntc_Start(&InterruptController, XIN_REAL_MODE); 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. */ XIntc_Enable(&InterruptController, INTC_DEVICE_INT_ID); /* * Initialize the exception table. */ Xil_ExceptionInit(); /* * Register the interrupt controller handler with the exception table. */ Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XIntc_InterruptHandler, &InterruptController); /* * Enable exceptions. */ Xil_ExceptionEnable(); return XST_SUCCESS; }