XilinxProcessorIPLib/drivers/sysmon/examples/xsysmon_single_ch_intr_example.c
int SysMonSingleChannelIntrExample(INTC* IntcInstancePtr,
					XSysMon* SysMonInstPtr,
					u16 SysMonDeviceId,
					u16 SysMonIntrId)
{
	int Status;
	XSysMon_Config *ConfigPtr;
	u16 VccintData;
	u32 IntrStatus;

	/*
	 * Initialize the SysMon driver.
	 */
	ConfigPtr = XSysMon_LookupConfig(SysMonDeviceId);
	if (ConfigPtr == NULL) {
		return XST_FAILURE;
	}
	XSysMon_CfgInitialize(SysMonInstPtr, ConfigPtr, ConfigPtr->BaseAddress);

	/*
	 * Self Test the System Monitor/ADC device.
	 */
	Status = XSysMon_SelfTest(SysMonInstPtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Set the ADCCLK frequency equal to 1/32 of System clock for the System
	 * Monitor/ADC in the Configuration Register 2.
	 */
	XSysMon_SetAdcClkDivisor(SysMonInstPtr, 32);

	/*
	 * Set the sequencer in Single channel mode.
	 */
	XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SINGCHAN);

	/*
	 * Set the configuration registers for single channel continuous mode
	 * of operation for the VCCINT channel.
	 */
	Status=  XSysMon_SetSingleChParams(SysMonInstPtr, XSM_CH_VCCINT,
						FALSE, FALSE, FALSE);
	if(Status != XST_SUCCESS) {
		return XST_FAILURE;
	}


	/*
	 * Disable all the alarms in the Configuration Register 1.
	 */
	XSysMon_SetAlarmEnables(SysMonInstPtr, 0x0);

	/*
	 * Set up Alarm threshold registers for the VCCINT
	 * High limit and lower limit so that the alarm does not occur.
	 */
	XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_UPPER, 0xFFFF);
	XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_LOWER, 0x0);


	/*
	 * Setup the interrupt system.
	 */
	Status = SysMonSetupInterruptSystem(IntcInstancePtr,
					    SysMonInstPtr,
					    SysMonIntrId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}


	/*
	 * Clear any bits set in the Interrupt Status Register.
	 */
	IntrStatus = XSysMon_IntrGetStatus(SysMonInstPtr);
	XSysMon_IntrClear(SysMonInstPtr, IntrStatus);


	/*
	 * Enable EOC interrupt and Alarm 1 interrupt for on-chip VCCINT.
	 */
	XSysMon_IntrEnable(SysMonInstPtr, XSM_IPIXR_EOC_MASK |
						XSM_IPIXR_VCCINT_MASK);

	/*
	 * Enable global interrupt of System Monitor.
	 */
	XSysMon_IntrGlobalEnable(SysMonInstPtr);


	/*
	 * Wait till the End of Conversion occurs.
	 */
	EocFlag = FALSE; 		/* Clear the EOC Flag */
	while (EocFlag != TRUE);


	/*
	 * Read the ADC converted Data from the data registers for VCCINT.
	 */
	VccintData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCINT);


	/*
	 * Set up Alarm threshold registers for the VCCINT
	 * High limit and lower limit so that the alarm occurs.
	 */
	XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_UPPER,
						VccintData - 0x007F);
	XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_LOWER,
						VccintData - 0x007F);


	VccintIntr = FALSE;	/* Clear the flag */


	/*
	 * Enable Alarm 1 for VCCINT
	 */
	XSysMon_SetAlarmEnables(SysMonInstPtr, XSM_CFR1_ALM_VCCINT_MASK);

	/*
	 * Wait until an Alarm 1 interrupt occurs.
	 */
	while (1) {

		if (VccintIntr == TRUE) {
			/*
			 * Alarm 1 - VCCINT alarm interrupt has occurred.
			 * The required processing should be put here.
			 */
			break;
		}
	}

	/*
	 * Disable global interrupt of System Monitor.
	 */
	XSysMon_IntrGlobalDisable(SysMonInstPtr);

	return XST_SUCCESS;
}
/****************************************************************************/
/**
*
* This function runs a test on the System Monitor/ADC device using the
* driver APIs.
*
* The function does the following tasks:
*	- Initiate the System Monitor/ADC device driver instance
*	- Run self-test on the device
*	- Reset the device
*	- Set up alarm for VCCINT
*	- Set up the configuration registers for single channel continuous mode
*	for VCCINT channel
*	- Setup interrupt system
*	- Enable interrupts
*	- Wait until the VCCINT alarm interrupt occurs
*
* @param	IntcInstancePtr is a pointer to the Interrupt Controller
*		driver Instance.
* @param	SysMonInstPtr is a pointer to the XSysMon driver Instance.
* @param	SysMonDeviceId is the XPAR_<SYSMON_ADC_instance>_DEVICE_ID value
*		from xparameters.h.
* @param	SysMonIntrId is
*		XPAR_<INTC_instance>_<SYSMON_ADC_instance>_VEC_ID
*		value from xparameters.h
*
* @return
*		- XST_SUCCESS if the example has completed successfully.
*		- XST_FAILURE if the example has failed.
*
* @note		This function may never return if no interrupt occurs.
*
****************************************************************************/
This function runs a test on the System Monitor/ADC device using the
driver APIs.

The function does the following tasks:
Initiate the System Monitor/ADC device driver instance
Run self-test on the device
Reset the device
Set up alarm for VCCINT
Set up the configuration registers for single channel continuous mode
for VCCINT channel
Setup interrupt system
Enable interrupts
Wait until the VCCINT alarm interrupt occurs
This function runs a test on the System Monitor / ADC device using the driver APIs . The function does the following tasks : Initiate the System Monitor / ADC device driver instance Run self - test on the device Reset the device Set up alarm for VCCINT Set up the configuration registers for single channel continuous mode for VCCINT channel Setup interrupt system Enable interrupts Wait until the VCCINT alarm interrupt occurs
int SysMonSingleChannelIntrExample(INTC* IntcInstancePtr,
					XSysMon* SysMonInstPtr,
					u16 SysMonDeviceId,
					u16 SysMonIntrId)
{
	int Status;
	XSysMon_Config *ConfigPtr;
	u16 VccintData;
	u32 IntrStatus;
	ConfigPtr = XSysMon_LookupConfig(SysMonDeviceId);
	if (ConfigPtr == NULL) {
		return XST_FAILURE;
	}
	XSysMon_CfgInitialize(SysMonInstPtr, ConfigPtr, ConfigPtr->BaseAddress);
	Status = XSysMon_SelfTest(SysMonInstPtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XSysMon_SetAdcClkDivisor(SysMonInstPtr, 32);
	XSysMon_SetSequencerMode(SysMonInstPtr, XSM_SEQ_MODE_SINGCHAN);
	Status=  XSysMon_SetSingleChParams(SysMonInstPtr, XSM_CH_VCCINT,
						FALSE, FALSE, FALSE);
	if(Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XSysMon_SetAlarmEnables(SysMonInstPtr, 0x0);
	XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_UPPER, 0xFFFF);
	XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_LOWER, 0x0);
	Status = SysMonSetupInterruptSystem(IntcInstancePtr,
					    SysMonInstPtr,
					    SysMonIntrId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	IntrStatus = XSysMon_IntrGetStatus(SysMonInstPtr);
	XSysMon_IntrClear(SysMonInstPtr, IntrStatus);
	XSysMon_IntrEnable(SysMonInstPtr, XSM_IPIXR_EOC_MASK |
						XSM_IPIXR_VCCINT_MASK);
	XSysMon_IntrGlobalEnable(SysMonInstPtr);
	EocFlag = FALSE; 		
	while (EocFlag != TRUE);
	VccintData = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_VCCINT);
	XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_UPPER,
						VccintData - 0x007F);
	XSysMon_SetAlarmThreshold(SysMonInstPtr, XSM_ATR_VCCINT_LOWER,
						VccintData - 0x007F);
	VccintIntr = FALSE;	
	XSysMon_SetAlarmEnables(SysMonInstPtr, XSM_CFR1_ALM_VCCINT_MASK);
	while (1) {
		if (VccintIntr == TRUE) {
			break;
		}
	}
	XSysMon_IntrGlobalDisable(SysMonInstPtr);
	return XST_SUCCESS;
}
int SysMonSingleChannelIntrExample ( INTC * IntcInstancePtr , XSysMon * SysMonInstPtr , u16 SysMonDeviceId , u16 SysMonIntrId ) { int Status ; XSysMon_Config * ConfigPtr ; u16 VccintData ; u32 IntrStatus ; ConfigPtr = XSysMon_LookupConfig ( SysMonDeviceId ) ; if ( ConfigPtr == NULL ) { return XST_FAILURE ; } XSysMon_CfgInitialize ( SysMonInstPtr , ConfigPtr , ConfigPtr -> BaseAddress ) ; Status = XSysMon_SelfTest ( SysMonInstPtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XSysMon_SetAdcClkDivisor ( SysMonInstPtr , 32 ) ; XSysMon_SetSequencerMode ( SysMonInstPtr , XSM_SEQ_MODE_SINGCHAN ) ; Status = XSysMon_SetSingleChParams ( SysMonInstPtr , XSM_CH_VCCINT , FALSE , FALSE , FALSE ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XSysMon_SetAlarmEnables ( SysMonInstPtr , 0x0 ) ; XSysMon_SetAlarmThreshold ( SysMonInstPtr , XSM_ATR_VCCINT_UPPER , 0xFFFF ) ; XSysMon_SetAlarmThreshold ( SysMonInstPtr , XSM_ATR_VCCINT_LOWER , 0x0 ) ; Status = SysMonSetupInterruptSystem ( IntcInstancePtr , SysMonInstPtr , SysMonIntrId ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } IntrStatus = XSysMon_IntrGetStatus ( SysMonInstPtr ) ; XSysMon_IntrClear ( SysMonInstPtr , IntrStatus ) ; XSysMon_IntrEnable ( SysMonInstPtr , XSM_IPIXR_EOC_MASK | XSM_IPIXR_VCCINT_MASK ) ; XSysMon_IntrGlobalEnable ( SysMonInstPtr ) ; EocFlag = FALSE ; while ( EocFlag != TRUE ) ; VccintData = XSysMon_GetAdcData ( SysMonInstPtr , XSM_CH_VCCINT ) ; XSysMon_SetAlarmThreshold ( SysMonInstPtr , XSM_ATR_VCCINT_UPPER , VccintData - 0x007F ) ; XSysMon_SetAlarmThreshold ( SysMonInstPtr , XSM_ATR_VCCINT_LOWER , VccintData - 0x007F ) ; VccintIntr = FALSE ; XSysMon_SetAlarmEnables ( SysMonInstPtr , XSM_CFR1_ALM_VCCINT_MASK ) ; while ( 1 ) { if ( VccintIntr == TRUE ) { break ; } } XSysMon_IntrGlobalDisable ( SysMonInstPtr ) ; return XST_SUCCESS ; }
This function runs a test on the System Monitor/ADC device using the
driver APIs.
This function runs a test on the System Monitor / ADC device using the driver APIs .
/*
	 * Initialize the SysMon driver.
	 */ /*
	 * Self Test the System Monitor/ADC device.
	 */ /*
	 * Set the ADCCLK frequency equal to 1/32 of System clock for the System
	 * Monitor/ADC in the Configuration Register 2.
	 */ /*
	 * Set the sequencer in Single channel mode.
	 */ /*
	 * Set the configuration registers for single channel continuous mode
	 * of operation for the VCCINT channel.
	 */ /*
	 * Disable all the alarms in the Configuration Register 1.
	 */ /*
	 * Set up Alarm threshold registers for the VCCINT
	 * High limit and lower limit so that the alarm does not occur.
	 */ /*
	 * Setup the interrupt system.
	 */ /*
	 * Clear any bits set in the Interrupt Status Register.
	 */ /*
	 * Enable EOC interrupt and Alarm 1 interrupt for on-chip VCCINT.
	 */ /*
	 * Enable global interrupt of System Monitor.
	 */ /*
	 * Wait till the End of Conversion occurs.
	 */ /* Clear the EOC Flag */ /*
	 * Read the ADC converted Data from the data registers for VCCINT.
	 */ /*
	 * Set up Alarm threshold registers for the VCCINT
	 * High limit and lower limit so that the alarm occurs.
	 */ /* Clear the flag */ /*
	 * Enable Alarm 1 for VCCINT
	 */ /*
	 * Wait until an Alarm 1 interrupt occurs.
	 */ /*
			 * Alarm 1 - VCCINT alarm interrupt has occurred.
			 * The required processing should be put here.
			 */ /*
	 * Disable global interrupt of System Monitor.
	 */