XilinxProcessorIPLib/drivers/sysmonpsu/src/xsysmonpsu.c
u16 XSysMonPsu_GetAdcData(XSysMonPsu *InstancePtr, u8 Channel, u32 Block)
{
	u16 AdcData;
	UINTPTR EffectiveBaseAddress;

	/* Assert the arguments. */
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	Xil_AssertNonvoid((Channel <= XSM_CH_SUPPLY3) ||
			  ((Channel >= XSM_CH_SUPPLY_CALIB) &&
			  (Channel <= XSM_CH_GAINERR_CALIB)) ||
			  ((Channel >= XSM_CH_SUPPLY4) &&
			  (Channel <= XSM_CH_RESERVE1)));
	Xil_AssertNonvoid((Block == XSYSMON_PS)||(Block == XSYSMON_PL)
						||(Block == XSYSMON_AMS));

	/* Calculate the effective baseaddress based on the Sysmon instance. */
	EffectiveBaseAddress =
			XSysMonPsu_GetEffBaseAddress(InstancePtr->Config.BaseAddress,
					Block);

	/*
	 * Read the selected ADC converted data for the specified channel
	 * and return the value.
	 */
	if (Channel <= XSM_CH_AUX_MAX) {
		AdcData = (u16) (XSysmonPsu_ReadReg(EffectiveBaseAddress + ((UINTPTR)Channel << 2U)));
	} else if ((Channel >= XSM_CH_SUPPLY7) && (Channel <= XSM_CH_TEMP_REMTE)){
		AdcData = (u16) (XSysmonPsu_ReadReg(EffectiveBaseAddress + XSM_ADC_CH_OFFSET +
				(((u32)Channel - XSM_CH_SUPPLY7) << 2U)));
	} else {
		AdcData = (u16) (XSysmonPsu_ReadReg(EffectiveBaseAddress + XSM_AMS_CH_OFFSET +
				(((UINTPTR)Channel - XSM_CH_VCC_PSLL0) << 2U)));
	}

	return AdcData;
}
/****************************************************************************/
/**
*
* Get the ADC converted data for the specified channel.
*
* @param	InstancePtr is a pointer to the XSysMonPsu instance.
* @param	Channel is the channel number. Use the XSM_CH_* defined in
*		the file xsysmonpsu.h. The valid channels for PS / PL SysMon are 0 - 6,
*		8 - 10 and 13 - 37. For AMS, 38 - 53 channels are valid.
* @param	Block is the value that tells whether it is for PS Sysmon block
*       or PL Sysmon block or the AMS controller register region.
*
* @return	A 16-bit value representing the ADC converted data for the
*		specified channel. The System Monitor device guarantees
* 		a 10 bit resolution for the ADC converted data and data is the
*		10 MSB bits of the 16 data read from the device.
*
* @note		Please make sure that the proper channel number is passed.
*
*****************************************************************************/
Get the ADC converted data for the specified channel.
Get the ADC converted data for the specified channel .
u16 XSysMonPsu_GetAdcData(XSysMonPsu *InstancePtr, u8 Channel, u32 Block)
{
	u16 AdcData;
	UINTPTR EffectiveBaseAddress;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	Xil_AssertNonvoid((Channel <= XSM_CH_SUPPLY3) ||
			  ((Channel >= XSM_CH_SUPPLY_CALIB) &&
			  (Channel <= XSM_CH_GAINERR_CALIB)) ||
			  ((Channel >= XSM_CH_SUPPLY4) &&
			  (Channel <= XSM_CH_RESERVE1)));
	Xil_AssertNonvoid((Block == XSYSMON_PS)||(Block == XSYSMON_PL)
						||(Block == XSYSMON_AMS));
	EffectiveBaseAddress =
			XSysMonPsu_GetEffBaseAddress(InstancePtr->Config.BaseAddress,
					Block);
	if (Channel <= XSM_CH_AUX_MAX) {
		AdcData = (u16) (XSysmonPsu_ReadReg(EffectiveBaseAddress + ((UINTPTR)Channel << 2U)));
	} else if ((Channel >= XSM_CH_SUPPLY7) && (Channel <= XSM_CH_TEMP_REMTE)){
		AdcData = (u16) (XSysmonPsu_ReadReg(EffectiveBaseAddress + XSM_ADC_CH_OFFSET +
				(((u32)Channel - XSM_CH_SUPPLY7) << 2U)));
	} else {
		AdcData = (u16) (XSysmonPsu_ReadReg(EffectiveBaseAddress + XSM_AMS_CH_OFFSET +
				(((UINTPTR)Channel - XSM_CH_VCC_PSLL0) << 2U)));
	}
	return AdcData;
}
u16 XSysMonPsu_GetAdcData ( XSysMonPsu * InstancePtr , u8 Channel , u32 Block ) { u16 AdcData ; UINTPTR EffectiveBaseAddress ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( InstancePtr -> IsReady == XIL_COMPONENT_IS_READY ) ; Xil_AssertNonvoid ( ( Channel <= XSM_CH_SUPPLY3 ) || ( ( Channel >= XSM_CH_SUPPLY_CALIB ) && ( Channel <= XSM_CH_GAINERR_CALIB ) ) || ( ( Channel >= XSM_CH_SUPPLY4 ) && ( Channel <= XSM_CH_RESERVE1 ) ) ) ; Xil_AssertNonvoid ( ( Block == XSYSMON_PS ) || ( Block == XSYSMON_PL ) || ( Block == XSYSMON_AMS ) ) ; EffectiveBaseAddress = XSysMonPsu_GetEffBaseAddress ( InstancePtr -> Config . BaseAddress , Block ) ; if ( Channel <= XSM_CH_AUX_MAX ) { AdcData = ( u16 ) ( XSysmonPsu_ReadReg ( EffectiveBaseAddress + ( ( UINTPTR ) Channel << 2U ) ) ) ; } else if ( ( Channel >= XSM_CH_SUPPLY7 ) && ( Channel <= XSM_CH_TEMP_REMTE ) ) { AdcData = ( u16 ) ( XSysmonPsu_ReadReg ( EffectiveBaseAddress + XSM_ADC_CH_OFFSET + ( ( ( u32 ) Channel - XSM_CH_SUPPLY7 ) << 2U ) ) ) ; } else { AdcData = ( u16 ) ( XSysmonPsu_ReadReg ( EffectiveBaseAddress + XSM_AMS_CH_OFFSET + ( ( ( UINTPTR ) Channel - XSM_CH_VCC_PSLL0 ) << 2U ) ) ) ; } return AdcData ; }
Get the ADC converted data for the specified channel.
Get the ADC converted data for the specified channel .
/* Assert the arguments. */ /* Calculate the effective baseaddress based on the Sysmon instance. */ /*
	 * Read the selected ADC converted data for the specified channel
	 * and return the value.
	 */