XilinxProcessorIPLib/drivers/scugic/examples/xscugic_example.c
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;
}
/*****************************************************************************/
/**
*
* 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.
*
******************************************************************************/
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.
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 .
int ScuGicExample(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 = XScuGic_SelfTest(&InterruptController);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = SetUpInterruptSystem(&InterruptController);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = XScuGic_Connect(&InterruptController, INTC_DEVICE_INT_ID,
			   (Xil_ExceptionHandler)DeviceDriverHandler,
			   (void *)&InterruptController);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XScuGic_Enable(&InterruptController, INTC_DEVICE_INT_ID);
	Status = XScuGic_SoftwareIntr(&InterruptController,
					INTC_DEVICE_INT_ID,
					XSCUGIC_SPI_CPU0_MASK);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	while (1) {
		if (InterruptProcessed) {
			break;
		}
	}
	return XST_SUCCESS;
}
int ScuGicExample ( 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 = XScuGic_SelfTest ( & InterruptController ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = SetUpInterruptSystem ( & InterruptController ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XScuGic_Connect ( & InterruptController , INTC_DEVICE_INT_ID , ( Xil_ExceptionHandler ) DeviceDriverHandler , ( void * ) & InterruptController ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XScuGic_Enable ( & InterruptController , INTC_DEVICE_INT_ID ) ; Status = XScuGic_SoftwareIntr ( & InterruptController , INTC_DEVICE_INT_ID , XSCUGIC_SPI_CPU0_MASK ) ; 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 interrupt controller driver
(XScuGic) and the hardware device.
This function is an example of how to use the interrupt controller driver ( XScuGic ) and the hardware device .
/*
	 * Initialize the interrupt controller driver so that it is ready to
	 * use.
	 */ /*
	 * Perform a self-test to ensure that the hardware was built
	 * correctly
	 */ /*
	 * Setup the Interrupt System
	 */ /*
	 * 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
	 */ /*
	 * Enable the interrupt for the device and then cause (simulate) an
	 * interrupt so the handlers will be called
	 */ /*
	 *  Simulate the Interrupt
	 */ /*
	 * Wait for the interrupt to be processed, if the interrupt does not
	 * occur this loop will wait forever
	 */ /*
		 * If the interrupt occurred which is indicated by the global
		 * variable which is set in the device driver handler, then
		 * stop waiting
		 */