XilinxProcessorIPLib/drivers/axipmon/examples/xaxipmon_intr_example.c
int AxiPmonInterruptExample(u16 AxiPmonDeviceId, u32 *Metrics)
{
	int Status;
	XAxiPmon_Config *ConfigPtr;
	u8 SlotId = 0x1;
	u16 Range2 = 0x10;	/* Range 2 - 16 */
	u16 Range1 = 0x08;	/* Range 1 - 8 */
	XAxiPmon *AxiPmonInstPtr = &AxiPmonInst;
	u32 SampleInterval  = 0x3FFFF;

	/*
	 * Initialize the AxiPmon driver.
	 */
	ConfigPtr = XAxiPmon_LookupConfig(AxiPmonDeviceId);
	if (ConfigPtr == NULL) {
		return XST_FAILURE;
	}
	XAxiPmon_CfgInitialize(AxiPmonInstPtr, ConfigPtr,
				ConfigPtr->BaseAddress);

	/*
	 * Self Test the Axi Performance Monitor device
	 */
	Status = XAxiPmon_SelfTest(AxiPmonInstPtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}


	Status = AxiPmonSetupIntrSystem(&Intc, AxiPmonInstPtr,
					INTC_AXIPMON_INTERRUPT_ID);


	/*
	 * Select Agent and required set of Metrics for a Counter.
	 * We can select another agent,Metrics for another counter by
	 * calling below function again.
	 */

	XAxiPmon_SetMetrics(AxiPmonInstPtr, SlotId, XAPM_METRIC_SET_0,
				XAPM_METRIC_COUNTER_0);

	/*
	 * Set Incrementer Ranges
	 */
	XAxiPmon_SetIncrementerRange(AxiPmonInstPtr, XAPM_INCREMENTER_0,
							Range2, Range1);


	XAxiPmon_SetSampleInterval(AxiPmonInstPtr, SampleInterval);

	XAxiPmon_LoadSampleIntervalCounter(AxiPmonInstPtr);

	/*
	 * Enable Metric Counters.
	 */
	XAxiPmon_EnableMetricsCounter(AxiPmonInstPtr);


	/*
	 * Enable Sample Interval Counter Overflow Interrupt
	 */
	XAxiPmon_IntrEnable(AxiPmonInstPtr, XAPM_IXR_SIC_OVERFLOW_MASK);

	/*
	 * Enable Global Interrupt
	 */
	XAxiPmon_IntrGlobalEnable(AxiPmonInstPtr);


	/*
	 * Application for which Metrics has to be computed should be
	 * called here
	 */

	/*
	 * Enable Sample Interval Counter and wait for interrupt to occur
	 */
	XAxiPmon_EnableSampleIntervalCounter(AxiPmonInstPtr);


	/** Wait until Sample Interval Overflow occurs */
	while(!(SampleCounterIntr));


	/** Disable Sample Interval Counter */
	XAxiPmon_DisableSampleIntervalCounter(AxiPmonInstPtr);

	/** Disable Sample Interval Counter Overflow Interrupt */
	XAxiPmon_IntrDisable(AxiPmonInstPtr, XAPM_IXR_SIC_OVERFLOW_MASK);

	/** Disable Global Interrupt */
	XAxiPmon_IntrGlobalDisable(AxiPmonInstPtr);

	/* Get Sampled Metric Counter 0 in Metrics */
	*Metrics = XAxiPmon_GetSampledMetricCounter(AxiPmonInstPtr,
					XAPM_METRIC_COUNTER_0);
	/*
	 * Disable Metric Counters.
	 */
	XAxiPmon_DisableMetricsCounter(AxiPmonInstPtr);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function runs a test on the AXI Performance Monitor device using the
* driver APIs.
* This function does the following tasks:
*	- Initiate the AXI Performance Monitor device driver instance
*	- Run self-test on the device
*	- Setup Interrupt System
*	- Sets Agent Number
*	- Sets Metric Set 0 as Metrics for Metric Counter 0
*	- Sets Upper and Lower Ranges for Incrementer 0
*	- Sets and loads Sample Interval
*	- Enables Metric Counters
*	- Calls Application for which Metrics need to be computed
*	- Enables Sample Interval Counter Interrupt
*	- Wait for interrupt and disables Interrupts after Interrupt occurs
*	- Reads Sampled Metric Counter 0
*	- Disables Metric Counters
*
* @param	AxiPmonDeviceId is the XPAR_<AXIPMON_instance>_DEVICE_ID value
*		from xparameters.h.
* @param	Metrics is an user referece variable in which computed metrics
*			will be filled
*
* @return
*		- XST_SUCCESS if the example has completed successfully.
*		- XST_FAILURE if the example has failed.
*
* @note   	None
*
******************************************************************************/
This function runs a test on the AXI Performance Monitor device using the
driver APIs.
This function does the following tasks:
Initiate the AXI Performance Monitor device driver instance
Run self-test on the device
Setup Interrupt System
Sets Agent Number
Sets Metric Set 0 as Metrics for Metric Counter 0
Sets Upper and Lower Ranges for Incrementer 0
Sets and loads Sample Interval
Enables Metric Counters
Calls Application for which Metrics need to be computed
Enables Sample Interval Counter Interrupt
Wait for interrupt and disables Interrupts after Interrupt occurs
Reads Sampled Metric Counter 0
Disables Metric Counters
This function runs a test on the AXI Performance Monitor device using the driver APIs . This function does the following tasks : Initiate the AXI Performance Monitor device driver instance Run self - test on the device Setup Interrupt System Sets Agent Number Sets Metric Set 0 as Metrics for Metric Counter 0 Sets Upper and Lower Ranges for Incrementer 0 Sets and loads Sample Interval Enables Metric Counters Calls Application for which Metrics need to be computed Enables Sample Interval Counter Interrupt Wait for interrupt and disables Interrupts after Interrupt occurs Reads Sampled Metric Counter 0 Disables Metric Counters
int AxiPmonInterruptExample(u16 AxiPmonDeviceId, u32 *Metrics)
{
	int Status;
	XAxiPmon_Config *ConfigPtr;
	u8 SlotId = 0x1;
	u16 Range2 = 0x10;	
	u16 Range1 = 0x08;	
	XAxiPmon *AxiPmonInstPtr = &AxiPmonInst;
	u32 SampleInterval  = 0x3FFFF;
	ConfigPtr = XAxiPmon_LookupConfig(AxiPmonDeviceId);
	if (ConfigPtr == NULL) {
		return XST_FAILURE;
	}
	XAxiPmon_CfgInitialize(AxiPmonInstPtr, ConfigPtr,
				ConfigPtr->BaseAddress);
	Status = XAxiPmon_SelfTest(AxiPmonInstPtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = AxiPmonSetupIntrSystem(&Intc, AxiPmonInstPtr,
					INTC_AXIPMON_INTERRUPT_ID);
	XAxiPmon_SetMetrics(AxiPmonInstPtr, SlotId, XAPM_METRIC_SET_0,
				XAPM_METRIC_COUNTER_0);
	XAxiPmon_SetIncrementerRange(AxiPmonInstPtr, XAPM_INCREMENTER_0,
							Range2, Range1);
	XAxiPmon_SetSampleInterval(AxiPmonInstPtr, SampleInterval);
	XAxiPmon_LoadSampleIntervalCounter(AxiPmonInstPtr);
	XAxiPmon_EnableMetricsCounter(AxiPmonInstPtr);
	XAxiPmon_IntrEnable(AxiPmonInstPtr, XAPM_IXR_SIC_OVERFLOW_MASK);
	XAxiPmon_IntrGlobalEnable(AxiPmonInstPtr);
	XAxiPmon_EnableSampleIntervalCounter(AxiPmonInstPtr);
	while(!(SampleCounterIntr));
	XAxiPmon_DisableSampleIntervalCounter(AxiPmonInstPtr);
	XAxiPmon_IntrDisable(AxiPmonInstPtr, XAPM_IXR_SIC_OVERFLOW_MASK);
	XAxiPmon_IntrGlobalDisable(AxiPmonInstPtr);
	*Metrics = XAxiPmon_GetSampledMetricCounter(AxiPmonInstPtr,
					XAPM_METRIC_COUNTER_0);
	XAxiPmon_DisableMetricsCounter(AxiPmonInstPtr);
	return XST_SUCCESS;
}
int AxiPmonInterruptExample ( u16 AxiPmonDeviceId , u32 * Metrics ) { int Status ; XAxiPmon_Config * ConfigPtr ; u8 SlotId = 0x1 ; u16 Range2 = 0x10 ; u16 Range1 = 0x08 ; XAxiPmon * AxiPmonInstPtr = & AxiPmonInst ; u32 SampleInterval = 0x3FFFF ; ConfigPtr = XAxiPmon_LookupConfig ( AxiPmonDeviceId ) ; if ( ConfigPtr == NULL ) { return XST_FAILURE ; } XAxiPmon_CfgInitialize ( AxiPmonInstPtr , ConfigPtr , ConfigPtr -> BaseAddress ) ; Status = XAxiPmon_SelfTest ( AxiPmonInstPtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = AxiPmonSetupIntrSystem ( & Intc , AxiPmonInstPtr , INTC_AXIPMON_INTERRUPT_ID ) ; XAxiPmon_SetMetrics ( AxiPmonInstPtr , SlotId , XAPM_METRIC_SET_0 , XAPM_METRIC_COUNTER_0 ) ; XAxiPmon_SetIncrementerRange ( AxiPmonInstPtr , XAPM_INCREMENTER_0 , Range2 , Range1 ) ; XAxiPmon_SetSampleInterval ( AxiPmonInstPtr , SampleInterval ) ; XAxiPmon_LoadSampleIntervalCounter ( AxiPmonInstPtr ) ; XAxiPmon_EnableMetricsCounter ( AxiPmonInstPtr ) ; XAxiPmon_IntrEnable ( AxiPmonInstPtr , XAPM_IXR_SIC_OVERFLOW_MASK ) ; XAxiPmon_IntrGlobalEnable ( AxiPmonInstPtr ) ; XAxiPmon_EnableSampleIntervalCounter ( AxiPmonInstPtr ) ; while ( ! ( SampleCounterIntr ) ) ; XAxiPmon_DisableSampleIntervalCounter ( AxiPmonInstPtr ) ; XAxiPmon_IntrDisable ( AxiPmonInstPtr , XAPM_IXR_SIC_OVERFLOW_MASK ) ; XAxiPmon_IntrGlobalDisable ( AxiPmonInstPtr ) ; * Metrics = XAxiPmon_GetSampledMetricCounter ( AxiPmonInstPtr , XAPM_METRIC_COUNTER_0 ) ; XAxiPmon_DisableMetricsCounter ( AxiPmonInstPtr ) ; return XST_SUCCESS ; }
This function runs a test on the AXI Performance Monitor device using the
driver APIs.
This function runs a test on the AXI Performance Monitor device using the driver APIs .
/* Range 2 - 16 */ /* Range 1 - 8 */ /*
	 * Initialize the AxiPmon driver.
	 */ /*
	 * Self Test the Axi Performance Monitor device
	 */ /*
	 * Select Agent and required set of Metrics for a Counter.
	 * We can select another agent,Metrics for another counter by
	 * calling below function again.
	 */ /*
	 * Set Incrementer Ranges
	 */ /*
	 * Enable Metric Counters.
	 */ /*
	 * Enable Sample Interval Counter Overflow Interrupt
	 */ /*
	 * Enable Global Interrupt
	 */ /*
	 * Application for which Metrics has to be computed should be
	 * called here
	 */ /*
	 * Enable Sample Interval Counter and wait for interrupt to occur
	 */ /** Wait until Sample Interval Overflow occurs */ /** Disable Sample Interval Counter */ /** Disable Sample Interval Counter Overflow Interrupt */ /** Disable Global Interrupt */ /* Get Sampled Metric Counter 0 in Metrics */ /*
	 * Disable Metric Counters.
	 */