XilinxProcessorIPLib/drivers/sysmon/examples/xsysmon_single_ch_intr_example.c
static int SysMonSetupInterruptSystem(INTC* IntcInstancePtr,
				      XSysMon *SysMonPtr,
				      u16 IntrId )
{
	int Status;

#ifdef XPAR_INTC_0_DEVICE_ID
#ifndef TESTAPP_GEN
	/*
	 * Initialize the interrupt controller driver so that it's ready to use.
	 */
	Status = XIntc_Initialize(IntcInstancePtr, INTC_DEVICE_ID);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#endif
	/*
	 * Connect the handler that will be called when an interrupt
	 * for the device occurs, the handler defined above performs the
	 * specific interrupt processing for the device.
	 */
	Status = XIntc_Connect(IntcInstancePtr,
				IntrId,
				(XInterruptHandler) SysMonInterruptHandler,
				SysMonPtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

#ifndef TESTAPP_GEN
	/*
	 * Start the interrupt controller so interrupts are enabled for all
	 * devices that cause interrupts. Specify real mode so that the System
	 * Monitor/ACD device can cause interrupts through the interrupt
	 * controller.
	 */
	Status = XIntc_Start(IntcInstancePtr, XIN_REAL_MODE);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#endif
	/*
	 * Enable the interrupt for the System Monitor/ADC device
	 */
	XIntc_Enable(IntcInstancePtr, IntrId);
#else /* SCUGIC */

#ifndef TESTAPP_GEN
	XScuGic_Config *IntcConfig;
	/*
	 * Initialize the interrupt controller driver so that it is ready to
	 * use.
	 */
	IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
	if (NULL == IntcConfig) {
		return XST_FAILURE;
	}

	Status = XScuGic_CfgInitialize(IntcInstancePtr, IntcConfig,
					IntcConfig->CpuBaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#endif

	XScuGic_SetPriorityTriggerType(IntcInstancePtr, IntrId,
					0xA0, 0x3);

	/*
	 * Connect the interrupt handler that will be called when an
	 * interrupt occurs for the device.
	 */
	Status = XScuGic_Connect(IntcInstancePtr, IntrId,
				 (Xil_ExceptionHandler)SysMonInterruptHandler,
				 SysMonPtr);
	if (Status != XST_SUCCESS) {
		return Status;
	}

	/*
	 * Enable the interrupt for the Sysmon device.
	 */
	XScuGic_Enable(IntcInstancePtr, IntrId);
#endif
#ifndef TESTAPP_GEN
	/*
	 * Initialize the exception table.
	 */
	Xil_ExceptionInit();

	/*
	 * Register the interrupt controller handler with the exception table.
	 */
	Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
					(Xil_ExceptionHandler) INTC_HANDLER,
				IntcInstancePtr);
	/*
	 * Enable exceptions.
	 */
	Xil_ExceptionEnable();

#endif /* TESTAPP_GEN */

	return XST_SUCCESS;
}
/****************************************************************************/
/**
*
* This function sets up the interrupt system so interrupts can occur for the
* System Monitor/ADC.  The function is application-specific since the actual
* system may or may not have an interrupt controller. The System Monitor/ADC
* device could be directly connected to a processor without an interrupt
* controller. The user should modify this function to fit the application.
*
* @param	IntcInstancePtr is a pointer to the Interrupt Controller
*		driver Instance
* @param	SysMonPtr is a pointer to the driver instance for the System
* 		Monitor device which is going to be connected to the interrupt
*		controller
* @param	IntrId is XPAR_<INTC_instance>_<SYSMON_ADC_instance>_VEC_ID
*		value from xparameters.h
*
* @return	XST_SUCCESS if successful, or XST_FAILURE.
*
* @note		None.
*
*
****************************************************************************/
This function sets up the interrupt system so interrupts can occur for the
System Monitor/ADC.  The function is application-specific since the actual
system may or may not have an interrupt controller. The System Monitor/ADC
device could be directly connected to a processor without an interrupt
controller. The user should modify this function to fit the application.
This function sets up the interrupt system so interrupts can occur for the System Monitor / ADC . The function is application - specific since the actual system may or may not have an interrupt controller . The System Monitor / ADC device could be directly connected to a processor without an interrupt controller . The user should modify this function to fit the application .
static int SysMonSetupInterruptSystem(INTC* IntcInstancePtr,
				      XSysMon *SysMonPtr,
				      u16 IntrId )
{
	int Status;
#ifdef XPAR_INTC_0_DEVICE_ID
#ifndef TESTAPP_GEN
	Status = XIntc_Initialize(IntcInstancePtr, INTC_DEVICE_ID);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#endif
	Status = XIntc_Connect(IntcInstancePtr,
				IntrId,
				(XInterruptHandler) SysMonInterruptHandler,
				SysMonPtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#ifndef TESTAPP_GEN
	Status = XIntc_Start(IntcInstancePtr, XIN_REAL_MODE);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#endif
	XIntc_Enable(IntcInstancePtr, IntrId);
#else 
#ifndef TESTAPP_GEN
	XScuGic_Config *IntcConfig;
	IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
	if (NULL == IntcConfig) {
		return XST_FAILURE;
	}
	Status = XScuGic_CfgInitialize(IntcInstancePtr, IntcConfig,
					IntcConfig->CpuBaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#endif
	XScuGic_SetPriorityTriggerType(IntcInstancePtr, IntrId,
					0xA0, 0x3);
	Status = XScuGic_Connect(IntcInstancePtr, IntrId,
				 (Xil_ExceptionHandler)SysMonInterruptHandler,
				 SysMonPtr);
	if (Status != XST_SUCCESS) {
		return Status;
	}
	XScuGic_Enable(IntcInstancePtr, IntrId);
#endif
#ifndef TESTAPP_GEN
	Xil_ExceptionInit();
	Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
					(Xil_ExceptionHandler) INTC_HANDLER,
				IntcInstancePtr);
	Xil_ExceptionEnable();
#endif 
	return XST_SUCCESS;
}
static int SysMonSetupInterruptSystem ( INTC * IntcInstancePtr , XSysMon * SysMonPtr , u16 IntrId ) { int Status ; #ifdef XPAR_INTC_0_DEVICE_ID #ifndef TESTAPP_GEN Status = XIntc_Initialize ( IntcInstancePtr , INTC_DEVICE_ID ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } #endif Status = XIntc_Connect ( IntcInstancePtr , IntrId , ( XInterruptHandler ) SysMonInterruptHandler , SysMonPtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } #ifndef TESTAPP_GEN Status = XIntc_Start ( IntcInstancePtr , XIN_REAL_MODE ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } #endif XIntc_Enable ( IntcInstancePtr , IntrId ) ; #else #ifndef TESTAPP_GEN XScuGic_Config * IntcConfig ; IntcConfig = XScuGic_LookupConfig ( INTC_DEVICE_ID ) ; if ( NULL == IntcConfig ) { return XST_FAILURE ; } Status = XScuGic_CfgInitialize ( IntcInstancePtr , IntcConfig , IntcConfig -> CpuBaseAddress ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } #endif XScuGic_SetPriorityTriggerType ( IntcInstancePtr , IntrId , 0xA0 , 0x3 ) ; Status = XScuGic_Connect ( IntcInstancePtr , IntrId , ( Xil_ExceptionHandler ) SysMonInterruptHandler , SysMonPtr ) ; if ( Status != XST_SUCCESS ) { return Status ; } XScuGic_Enable ( IntcInstancePtr , IntrId ) ; #endif #ifndef TESTAPP_GEN Xil_ExceptionInit ( ) ; Xil_ExceptionRegisterHandler ( XIL_EXCEPTION_ID_INT , ( Xil_ExceptionHandler ) INTC_HANDLER , IntcInstancePtr ) ; Xil_ExceptionEnable ( ) ; #endif return XST_SUCCESS ; }
This function sets up the interrupt system so interrupts can occur for the
System Monitor/ADC.
This function sets up the interrupt system so interrupts can occur for the System Monitor / ADC .
/*
	 * Initialize the interrupt controller driver so that it's ready to use.
	 */ /*
	 * Connect the handler that will be called when an interrupt
	 * for the device occurs, the handler defined above performs the
	 * specific interrupt processing for the device.
	 */ /*
	 * Start the interrupt controller so interrupts are enabled for all
	 * devices that cause interrupts. Specify real mode so that the System
	 * Monitor/ACD device can cause interrupts through the interrupt
	 * controller.
	 */ /*
	 * Enable the interrupt for the System Monitor/ADC device
	 */ /* SCUGIC */ /*
	 * Initialize the interrupt controller driver so that it is ready to
	 * use.
	 */ /*
	 * Connect the interrupt handler that will be called when an
	 * interrupt occurs for the device.
	 */ /*
	 * Enable the interrupt for the Sysmon device.
	 */ /*
	 * Initialize the exception table.
	 */ /*
	 * Register the interrupt controller handler with the exception table.
	 */ /*
	 * Enable exceptions.
	 */ /* TESTAPP_GEN */