Software Drivers

xadcps.h File Reference

#include "xil_types.h"
#include "xil_assert.h"
#include "xstatus.h"
#include "xadcps_hw.h"

Classes

struct  XAdcPs_Config
struct  XAdcPs

Defines

#define XADCPS_H
#define XAdcPs_IsEventSamplingModeSet(InstancePtr)
#define XAdcPs_IsExternalMuxModeSet(InstancePtr)
#define XAdcPs_RawToTemperature(AdcData)   ((((float)(AdcData)/65536.0f)/0.00198421639f ) - 273.15f)
#define XAdcPs_RawToVoltage(AdcData)   ((((float)(AdcData))* (3.0f))/65536.0f)
#define XAdcPs_TemperatureToRaw(Temperature)   ((int)(((Temperature) + 273.15f)*65536.0f*0.00198421639f))
#define XAdcPs_VoltageToRaw(Voltage)   ((int)((Voltage)*65536.0f/3.0f))
#define XAdcPs_WriteFifo(InstancePtr, Data)
#define XAdcPs_ReadFifo(InstancePtr)
Indexes for the different channels.



#define XADCPS_CH_TEMP   0x0
#define XADCPS_CH_VCCINT   0x1
#define XADCPS_CH_VCCAUX   0x2
#define XADCPS_CH_VPVN   0x3
#define XADCPS_CH_VREFP   0x4
#define XADCPS_CH_VREFN   0x5
#define XADCPS_CH_VBRAM   0x6
#define XADCPS_CH_SUPPLY_CALIB   0x07
#define XADCPS_CH_ADC_CALIB   0x08
#define XADCPS_CH_GAINERR_CALIB   0x09
#define XADCPS_CH_VCCPINT   0x0D
#define XADCPS_CH_VCCPAUX   0x0E
#define XADCPS_CH_VCCPDRO   0x0F
#define XADCPS_CH_AUX_MIN   16
#define XADCPS_CH_AUX_MAX   31
Indexes for reading the Calibration Coefficient Data.



#define XADCPS_CALIB_SUPPLY_COEFF   0
#define XADCPS_CALIB_ADC_COEFF   1
#define XADCPS_CALIB_GAIN_ERROR_COEFF   2
Indexes for reading the Minimum/Maximum Measurement Data.



#define XADCPS_MAX_TEMP   0
#define XADCPS_MAX_VCCINT   1
#define XADCPS_MAX_VCCAUX   2
#define XADCPS_MAX_VBRAM   3
#define XADCPS_MIN_TEMP   4
#define XADCPS_MIN_VCCINT   5
#define XADCPS_MIN_VCCAUX   6
#define XADCPS_MIN_VBRAM   7
#define XADCPS_MAX_VCCPINT   8
#define XADCPS_MAX_VCCPAUX   9
#define XADCPS_MAX_VCCPDRO   0xA
#define XADCPS_MIN_VCCPINT   0xC
#define XADCPS_MIN_VCCPAUX   0xD
#define XADCPS_MIN_VCCPDRO   0xE
Alarm Threshold(Limit) Register (ATR) indexes.



#define XADCPS_ATR_TEMP_UPPER   0
#define XADCPS_ATR_VCCINT_UPPER   1
#define XADCPS_ATR_VCCAUX_UPPER   2
#define XADCPS_ATR_OT_UPPER   3
#define XADCPS_ATR_TEMP_LOWER   4
#define XADCPS_ATR_VCCINT_LOWER   5
#define XADCPS_ATR_VCCAUX_LOWER   6
#define XADCPS_ATR_OT_LOWER   7
#define XADCPS_ATR_VBRAM_UPPER_   8
#define XADCPS_ATR_VCCPINT_UPPER   9
#define XADCPS_ATR_VCCPAUX_UPPER   0xA
#define XADCPS_ATR_VCCPDRO_UPPER   0xB
#define XADCPS_ATR_VBRAM_LOWER   0xC
#define XADCPS_ATR_VCCPINT_LOWER   0xD
#define XADCPS_ATR_VCCPAUX_LOWER   0xE
#define XADCPS_ATR_VCCPDRO_LOWER   0xF
Averaging to be done for the channels.



#define XADCPS_AVG_0_SAMPLES   0
#define XADCPS_AVG_16_SAMPLES   1
#define XADCPS_AVG_64_SAMPLES   2
#define XADCPS_AVG_256_SAMPLES   3
Channel Sequencer Modes of operation



#define XADCPS_SEQ_MODE_SAFE   0
#define XADCPS_SEQ_MODE_ONEPASS   1
#define XADCPS_SEQ_MODE_CONTINPASS   2
#define XADCPS_SEQ_MODE_SINGCHAN   3
#define XADCPS_SEQ_MODE_SIMUL_SAMPLING   4
#define XADCPS_SEQ_MODE_INDEPENDENT   8
Power Down Modes



#define XADCPS_PD_MODE_NONE   0
#define XADCPS_PD_MODE_ADCB   1
#define XADCPS_PD_MODE_XADC   2

Functions

XAdcPs_ConfigXAdcPs_LookupConfig (u16 DeviceId)
int XAdcPs_CfgInitialize (XAdcPs *InstancePtr, XAdcPs_Config *ConfigPtr, u32 EffectiveAddr)
u32 XAdcPs_GetStatus (XAdcPs *InstancePtr)
u32 XAdcPs_GetAlarmOutputStatus (XAdcPs *InstancePtr)
void XAdcPs_StartAdcConversion (XAdcPs *InstancePtr)
void XAdcPs_Reset (XAdcPs *InstancePtr)
u16 XAdcPs_GetAdcData (XAdcPs *InstancePtr, u8 Channel)
u16 XAdcPs_GetCalibCoefficient (XAdcPs *InstancePtr, u8 CoeffType)
u16 XAdcPs_GetMinMaxMeasurement (XAdcPs *InstancePtr, u8 MeasurementType)
void XAdcPs_SetAvg (XAdcPs *InstancePtr, u8 Average)
u8 XAdcPs_GetAvg (XAdcPs *InstancePtr)
int XAdcPs_SetSingleChParams (XAdcPs *InstancePtr, u8 Channel, int IncreaseAcqCycles, int IsEventMode, int IsDifferentialMode)
void XAdcPs_SetAlarmEnables (XAdcPs *InstancePtr, u16 AlmEnableMask)
u16 XAdcPs_GetAlarmEnables (XAdcPs *InstancePtr)
void XAdcPs_SetCalibEnables (XAdcPs *InstancePtr, u16 Calibration)
u16 XAdcPs_GetCalibEnables (XAdcPs *InstancePtr)
void XAdcPs_SetSequencerMode (XAdcPs *InstancePtr, u8 SequencerMode)
u8 XAdcPs_GetSequencerMode (XAdcPs *InstancePtr)
void XAdcPs_SetAdcClkDivisor (XAdcPs *InstancePtr, u8 Divisor)
u8 XAdcPs_GetAdcClkDivisor (XAdcPs *InstancePtr)
int XAdcPs_SetSeqChEnables (XAdcPs *InstancePtr, u32 ChEnableMask)
u32 XAdcPs_GetSeqChEnables (XAdcPs *InstancePtr)
int XAdcPs_SetSeqAvgEnables (XAdcPs *InstancePtr, u32 AvgEnableChMask)
u32 XAdcPs_GetSeqAvgEnables (XAdcPs *InstancePtr)
int XAdcPs_SetSeqInputMode (XAdcPs *InstancePtr, u32 InputModeChMask)
u32 XAdcPs_GetSeqInputMode (XAdcPs *InstancePtr)
int XAdcPs_SetSeqAcqTime (XAdcPs *InstancePtr, u32 AcqCyclesChMask)
u32 XAdcPs_GetSeqAcqTime (XAdcPs *InstancePtr)
void XAdcPs_SetAlarmThreshold (XAdcPs *InstancePtr, u8 AlarmThrReg, u16 Value)
u16 XAdcPs_GetAlarmThreshold (XAdcPs *InstancePtr, u8 AlarmThrReg)
void XAdcPs_EnableUserOverTemp (XAdcPs *InstancePtr)
void XAdcPs_DisableUserOverTemp (XAdcPs *InstancePtr)
void XAdcPs_SetSequencerEvent (XAdcPs *InstancePtr, int IsEventMode)
int XAdcPs_GetSamplingMode (XAdcPs *InstancePtr)
void XAdcPs_SetMuxMode (XAdcPs *InstancePtr, int MuxMode, u8 Channel)
void XAdcPs_SetPowerdownMode (XAdcPs *InstancePtr, u32 Mode)
u32 XAdcPs_GetPowerdownMode (XAdcPs *InstancePtr)
int XAdcPs_SelfTest (XAdcPs *InstancePtr)
void XAdcPs_IntrEnable (XAdcPs *InstancePtr, u32 Mask)
void XAdcPs_IntrDisable (XAdcPs *InstancePtr, u32 Mask)
u32 XAdcPs_IntrGetEnabled (XAdcPs *InstancePtr)
u32 XAdcPs_IntrGetStatus (XAdcPs *InstancePtr)
void XAdcPs_IntrClear (XAdcPs *InstancePtr, u32 Mask)

Detailed Description


Define Documentation

#define XADCPS_ATR_OT_LOWER   7

Lower Over Temperature limit

#define XADCPS_ATR_OT_UPPER   3

VCCAUX high voltage limit register

#define XADCPS_ATR_TEMP_LOWER   4

Upper Over Temperature limit Reg

#define XADCPS_ATR_TEMP_UPPER   0

High user Temperature

#define XADCPS_ATR_VBRAM_LOWER   0xC

VRBAM Lower Alarm Reg, 7 Series

#define XADCPS_ATR_VBRAM_UPPER_   8

VRBAM Upper Alarm Reg, 7 Series

#define XADCPS_ATR_VCCAUX_LOWER   6

VCCAUX low voltage limit register

#define XADCPS_ATR_VCCAUX_UPPER   2

VCCAUX high voltage limit register

#define XADCPS_ATR_VCCINT_LOWER   5

VCCINT high voltage limit register

#define XADCPS_ATR_VCCINT_UPPER   1

VCCINT high voltage limit register

#define XADCPS_ATR_VCCPAUX_LOWER   0xE

VCCPAUX Lower Alarm Reg , Zynq

#define XADCPS_ATR_VCCPAUX_UPPER   0xA

VCCPAUX Upper Alarm Reg, Zynq

#define XADCPS_ATR_VCCPDRO_LOWER   0xF

VCCPDRO Lower Alarm Reg , Zynq

#define XADCPS_ATR_VCCPDRO_UPPER   0xB

VCCPDRO Upper Alarm Reg, Zynq

#define XADCPS_ATR_VCCPINT_LOWER   0xD

VCCPINT Lower Alarm Reg , Zynq

#define XADCPS_ATR_VCCPINT_UPPER   9

VCCPINT Upper Alarm Reg, Zynq

#define XADCPS_AVG_0_SAMPLES   0

No Averaging

#define XADCPS_AVG_16_SAMPLES   1

Average 16 samples

#define XADCPS_AVG_256_SAMPLES   3

Average 256 samples

#define XADCPS_AVG_64_SAMPLES   2

Average 64 samples

#define XADCPS_CALIB_ADC_COEFF   1

ADC Offset Calib Coefficient

#define XADCPS_CALIB_GAIN_ERROR_COEFF   2

Gain Error Calib Coefficient

#define XADCPS_CALIB_SUPPLY_COEFF   0

Supply Offset Calib Coefficient

#define XADCPS_CH_ADC_CALIB   0x08

ADC Offset Channel Reg

#define XADCPS_CH_AUX_MAX   31

Channel number for Last Aux channel

#define XADCPS_CH_AUX_MIN   16

Channel number for 1st Aux Channel

#define XADCPS_CH_GAINERR_CALIB   0x09

Gain Error Channel Reg

#define XADCPS_CH_SUPPLY_CALIB   0x07

Supply Calib Data Reg

#define XADCPS_CH_TEMP   0x0

On Chip Temperature

#define XADCPS_CH_VBRAM   0x6

On-chip VBRAM Data Reg, 7 series

#define XADCPS_CH_VCCAUX   0x2

VCCAUX

#define XADCPS_CH_VCCINT   0x1

VCCINT

#define XADCPS_CH_VCCPAUX   0x0E

On-chip PS VCCPAUX Channel , Zynq

#define XADCPS_CH_VCCPDRO   0x0F

On-chip PS VCCPDRO Channel , Zynq

#define XADCPS_CH_VCCPINT   0x0D

On-chip PS VCCPINT Channel , Zynq

#define XADCPS_CH_VPVN   0x3

VP/VN Dedicated analog inputs

#define XADCPS_CH_VREFN   0x5

VREFN

#define XADCPS_CH_VREFP   0x4

VREFP

#define XADCPS_H
#define XAdcPs_IsEventSamplingModeSet ( InstancePtr   ) 
Value:
(((XAdcPs_ReadInternalReg(InstancePtr,                          \
                        XADCPS_CFR0_OFFSET) & XADCPS_CFR0_EC_MASK) ?    \
                        TRUE : FALSE))

This macro checks if the XADC device is in Event Sampling mode.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
  • TRUE if the device is in Event Sampling Mode.
  • FALSE if the device is in Continuous Sampling Mode.
Note:
C-Style signature: int XAdcPs_IsEventSamplingMode(XAdcPs *InstancePtr);
#define XAdcPs_IsExternalMuxModeSet ( InstancePtr   ) 
Value:
(((XAdcPs_ReadInternalReg(InstancePtr,                          \
                        XADCPS_CFR0_OFFSET) & XADCPS_CFR0_MUX_MASK) ?   \
                        TRUE : FALSE))

This macro checks if the XADC device is in External Mux mode.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
  • TRUE if the device is in External Mux Mode.
  • FALSE if the device is NOT in External Mux Mode.
Note:
C-Style signature: int XAdcPs_IsExternalMuxMode(XAdcPs *InstancePtr);
#define XADCPS_MAX_TEMP   0

Maximum Temperature Data

#define XADCPS_MAX_VBRAM   3

Maximum VBRAM Data

#define XADCPS_MAX_VCCAUX   2

Maximum VCCAUX Data

#define XADCPS_MAX_VCCINT   1

Maximum VCCINT Data

#define XADCPS_MAX_VCCPAUX   9

Maximum VCCPAUX Register , Zynq

#define XADCPS_MAX_VCCPDRO   0xA

Maximum VCCPDRO Register , Zynq

#define XADCPS_MAX_VCCPINT   8

Maximum VCCPINT Register , Zynq

#define XADCPS_MIN_TEMP   4

Minimum Temperature Data

#define XADCPS_MIN_VBRAM   7

Minimum VBRAM Data

#define XADCPS_MIN_VCCAUX   6

Minimum VCCAUX Data

#define XADCPS_MIN_VCCINT   5

Minimum VCCINT Data

#define XADCPS_MIN_VCCPAUX   0xD

Minimum VCCPAUX Register , Zynq

#define XADCPS_MIN_VCCPDRO   0xE

Minimum VCCPDRO Register , Zynq

#define XADCPS_MIN_VCCPINT   0xC

Minimum VCCPINT Register , Zynq

#define XADCPS_PD_MODE_ADCB   1

Power Down ADC B

#define XADCPS_PD_MODE_NONE   0

No Power Down

#define XADCPS_PD_MODE_XADC   2

Power Down ADC A and ADC B

#define XAdcPs_RawToTemperature ( AdcData   )     ((((float)(AdcData)/65536.0f)/0.00198421639f ) - 273.15f)

This macro converts XADC Raw Data to Temperature(centigrades).

Parameters:
AdcData is the Raw ADC Data from XADC.
Returns:
The Temperature in centigrades.
Note:
C-Style signature: float XAdcPs_RawToTemperature(u32 AdcData);
#define XAdcPs_RawToVoltage ( AdcData   )     ((((float)(AdcData))* (3.0f))/65536.0f)

This macro converts XADC/ADC Raw Data to Voltage(volts).

Parameters:
AdcData is the XADC/ADC Raw Data.
Returns:
The Voltage in volts.
Note:
C-Style signature: float XAdcPs_RawToVoltage(u32 AdcData);
#define XAdcPs_ReadFifo ( InstancePtr   ) 
Value:
XAdcPs_ReadReg((InstancePtr)->Config.BaseAddress,       \
                          XADCPS_RDFIFO_OFFSET);

This macro is used for reading from the XADC Registers using the data FIFO.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
Data read from the FIFO
Note:
C-Style signature: u32 XAdcPs_ReadFifo(XAdcPs *InstancePtr);
#define XADCPS_SEQ_MODE_CONTINPASS   2

Continuous Cycling Sequencer

#define XADCPS_SEQ_MODE_INDEPENDENT   8

Independent mode

#define XADCPS_SEQ_MODE_ONEPASS   1

Onepass through Sequencer

#define XADCPS_SEQ_MODE_SAFE   0

Default Safe Mode

#define XADCPS_SEQ_MODE_SIMUL_SAMPLING   4

Simultaneous sampling

#define XADCPS_SEQ_MODE_SINGCHAN   3

Single channel -No Sequencing

#define XAdcPs_TemperatureToRaw ( Temperature   )     ((int)(((Temperature) + 273.15f)*65536.0f*0.00198421639f))

This macro converts Temperature in centigrades to XADC/ADC Raw Data.

Parameters:
Temperature is the Temperature in centigrades to be converted to XADC/ADC Raw Data.
Returns:
The XADC/ADC Raw Data.
Note:
C-Style signature: int XAdcPs_TemperatureToRaw(float Temperature);
#define XAdcPs_VoltageToRaw ( Voltage   )     ((int)((Voltage)*65536.0f/3.0f))

This macro converts Voltage in Volts to XADC/ADC Raw Data.

Parameters:
Voltage is the Voltage in volts to be converted to XADC/ADC Raw Data.
Returns:
The XADC/ADC Raw Data.
Note:
C-Style signature: int XAdcPs_VoltageToRaw(float Voltage);
#define XAdcPs_WriteFifo ( InstancePtr,
Data   ) 
Value:
XAdcPs_WriteReg((InstancePtr)->Config.BaseAddress,              \
                          XADCPS_CMDFIFO_OFFSET, Data);

This macro is used for writing to the XADC Registers using the command FIFO.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
None.
Note:
C-Style signature: void XAdcPs_WriteFifo(XAdcPs *InstancePtr, u32 Data);

Function Documentation

int XAdcPs_CfgInitialize ( XAdcPs InstancePtr,
XAdcPs_Config ConfigPtr,
u32  EffectiveAddr 
)

Functions in xadcps.c

This function initializes a specific XAdcPs device/instance. This function must be called prior to using the XADC device.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
ConfigPtr points to the XAdcPs device configuration structure.
EffectiveAddr is the device base address in the virtual memory address space. If the address translation is not used then the physical address is passed. Unexpected errors may occur if the address mapping is changed after this function is invoked.
Returns:
  • XST_SUCCESS if successful.
Note:
The user needs to first call the XAdcPs_LookupConfig() API which returns the Configuration structure pointer which is passed as a parameter to the XAdcPs_CfgInitialize() API.
void XAdcPs_DisableUserOverTemp ( XAdcPs InstancePtr  ) 

This function disables programming of the powerdown temperature for the OverTemp signal in the OT Powerdown register.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
None.
Note:
None.
void XAdcPs_EnableUserOverTemp ( XAdcPs InstancePtr  ) 

This function enables programming of the powerdown temperature for the OverTemp signal in the OT Powerdown register.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
None.
Note:
None.
u8 XAdcPs_GetAdcClkDivisor ( XAdcPs InstancePtr  ) 

The function gets the ADCCLK divisor from the Configuration Register 2.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
The divisor read from the Configuration Register 2.
Note:
The ADCCLK is an internal clock used by the ADC and is synchronized to the DCLK clock. The ADCCLK is equal to DCLK divided by the user selection in the Configuration Register 2.
u16 XAdcPs_GetAdcData ( XAdcPs InstancePtr,
u8  Channel 
)

Get the ADC converted data for the specified channel.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Channel is the channel number. Use the XADCPS_CH_* defined in the file xadcps.h. The valid channels are

  • 0 to 6
  • 13 to 31
Returns:
A 16-bit value representing the ADC converted data for the specified channel. The XADC Monitor/ADC 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:
The channels 7,8,9 are used for calibration of the device and hence there is no associated data with this channel.
u16 XAdcPs_GetAlarmEnables ( XAdcPs InstancePtr  ) 

This function gets the status of the alarm output enables in the Configuration Register 1.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
This is the bit-mask of the enabled alarm outputs in the Configuration Register 1. Use the masks XADCPS_CFR1_ALM*_* and XADCPS_CFR1_OT_MASK defined in xadcps_hw.h to interpret the returned value. Bit positions of 1 indicate that the alarm output is enabled. Bit positions of 0 indicate that the alarm output is disabled.
Note:
The implementation of the alarm enables in the Configuration register 1 is such that alarms for the bit positions of 1 will be disabled and alarms for bit positions of 0 will be enabled. The enabled alarm outputs returned by this function is the negated value of the the data read from the Configuration Register 1.
u32 XAdcPs_GetAlarmOutputStatus ( XAdcPs InstancePtr  ) 
u16 XAdcPs_GetAlarmThreshold ( XAdcPs InstancePtr,
u8  AlarmThrReg 
)

This function returns the contents of the specified Alarm Threshold Register.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
AlarmThrReg is the index of an Alarm Threshold Register to be read. Use XADCPS_ATR_* constants defined in xadcps_hw.h to specify the index.
Returns:
A 16-bit value representing the contents of the selected Alarm Threshold Register.
Note:
None.
u8 XAdcPs_GetAvg ( XAdcPs InstancePtr  ) 

This function returns the number of samples of averaging configured for all the channels in the Configuration Register 0.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
The averaging read from the Configuration Register 0 is returned. Use the XADCPS_AVG_* bit definitions defined in xadcps.h file to interpret the returned value :
  • XADCPS_AVG_0_SAMPLES means no averaging
  • XADCPS_AVG_16_SAMPLES means 16 samples of averaging
  • XADCPS_AVG_64_SAMPLES means 64 samples of averaging
  • XADCPS_AVG_256_SAMPLES means 256 samples of averaging
Note:
None.
u16 XAdcPs_GetCalibCoefficient ( XAdcPs InstancePtr,
u8  CoeffType 
)

This function gets the calibration coefficient data for the specified parameter.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
CoeffType specifies the calibration coefficient to be read. Use XADCPS_CALIB_* constants defined in xadcps.h to specify the calibration coefficient to be read.
Returns:
A 16-bit value representing the calibration coefficient. The XADC 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:
None.
u16 XAdcPs_GetCalibEnables ( XAdcPs InstancePtr  ) 

This function reads the value of the calibration enables from the Configuration Register 1.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
The value of the calibration enables in the Configuration Register 1 :
  • XADCPS_CFR1_CAL_ADC_OFFSET_MASK : ADC offset correction
  • XADCPS_CFR1_CAL_ADC_GAIN_OFFSET_MASK : ADC gain and offset correction
  • XADCPS_CFR1_CAL_PS_OFFSET_MASK : Power Supply sensor offset correction
  • XADCPS_CFR1_CAL_PS_GAIN_OFFSET_MASK : Power Supply sensor gain and offset correction
  • XADCPS_CFR1_CAL_DISABLE_MASK : No Calibration
Note:
None.
u16 XAdcPs_GetMinMaxMeasurement ( XAdcPs InstancePtr,
u8  MeasurementType 
)

This function reads the Minimum/Maximum measurement for one of the specified parameters. Use XADCPS_MAX_* and XADCPS_MIN_* constants defined in xadcps.h to specify the parameters (Temperature, VccInt, VccAux, VBram, VccPInt, VccPAux and VccPDro).

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
MeasurementType specifies the parameter for which the Minimum/Maximum measurement has to be read. Use XADCPS_MAX_* and XADCPS_MIN_* constants defined in xadcps.h to specify the data to be read.
Returns:
A 16-bit value representing the maximum/minimum measurement for specified parameter. The XADC 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:
None.
u32 XAdcPs_GetPowerdownMode ( XAdcPs InstancePtr  ) 

This function gets the Power Down mode.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
Mode specifies the Power Down Mode
  • XADCPS_PD_MODE_NONE specifies NO Power Down (Both ADC A and ADC B are enabled)
  • XADCPS_PD_MODE_ADCB specfies the Power Down of ADC B
  • XADCPS_PD_MODE_XADC specifies the Power Down of both ADC A and ADC B.
Note:
None.
int XAdcPs_GetSamplingMode ( XAdcPs InstancePtr  ) 

This function returns the sampling mode.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
The sampling mode
  • 0 specifies continuous sampling
  • 1 specifies event driven sampling mode
Note:
None.
u32 XAdcPs_GetSeqAcqTime ( XAdcPs InstancePtr  ) 

This function gets the status of acquisition from the ADC Channel Acquisition Time Sequencer Registers.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
The acquisition time for all the channels. Use XADCPS_SEQ_CH__* defined in xadcps_hw.h to interpret the Channel numbers. Bit masks of 1 are the channels for which acquisition cycles are extended and bit mask of 0 are the channels for which acquisition cycles are not extended.
Note:
None
u32 XAdcPs_GetSeqAvgEnables ( XAdcPs InstancePtr  ) 

This function returns the channels for which the averaging has been enabled in the ADC Channel Averaging Enables Sequencer Registers.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
The status of averaging (enabled/disabled) for all the channels. Use XADCPS_SEQ_CH__* defined in xadcps_hw.h to interpret the Channel numbers. Bit masks of 1 are the channels for which averaging is enabled and bit mask of 0 are the channels for averaging is disabled
Note:
None
u32 XAdcPs_GetSeqChEnables ( XAdcPs InstancePtr  ) 

This function gets the channel enable bits status from the ADC Channel Selection Sequencer Registers.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
Gets the channel enable bits. Use XADCPS_SEQ_CH__* defined in xadcps_hw.h to interpret the Channel numbers. Bit masks of 1 are the channels that are enabled and bit mask of 0 are the channels that are disabled.
None
Note:
None
u32 XAdcPs_GetSeqInputMode ( XAdcPs InstancePtr  ) 

This function gets the Analog input mode for all the channels from the ADC Channel Analog-Input Mode Sequencer Registers.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
The input mode for all the channels. Use XADCPS_SEQ_CH_* defined in xadcps_hw.h to interpret the Channel numbers. Bit masks of 1 are the channels for which input mode is differential and bit mask of 0 are the channels for which input mode is unipolar.
Note:
None.
u8 XAdcPs_GetSequencerMode ( XAdcPs InstancePtr  ) 

This function gets the channel sequencer mode from the Configuration Register 1.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
The channel sequencer mode :
  • XADCPS_SEQ_MODE_SAFE : Default safe mode
  • XADCPS_SEQ_MODE_ONEPASS : One pass through sequence
  • XADCPS_SEQ_MODE_CONTINPASS : Continuous channel sequencing
  • XADCPS_SEQ_MODE_SINGCHAN : Single channel/Sequencer off
  • XADCPS_SEQ_MODE_SIMUL_SAMPLING : Simulataneous sampling mode
  • XADCPS_SEQ_MODE_INDEPENDENT : Independent mode
Note:
None.
u32 XAdcPs_GetStatus ( XAdcPs InstancePtr  ) 
void XAdcPs_IntrClear ( XAdcPs InstancePtr,
u32  Mask 
)

This function clears the specified interrupts in the Interrupt Status Register (IPISR).

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Mask is the bit-mask of the interrupts to be cleared. Bit positions of 1 will be cleared. Bit positions of 0 will not change the previous interrupt status. This mask is formed by OR'ing XADCPS_IPIXR_* bits which are defined in xadcps_hw.h.
Returns:
None.
Note:
None.
void XAdcPs_IntrDisable ( XAdcPs InstancePtr,
u32  Mask 
)

This function disables the specified interrupts in the device.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Mask is the bit-mask of the interrupts to be disabled. Bit positions of 1 will be disabled. Bit positions of 0 will keep the previous setting. This mask is formed by OR'ing XADCPS_INTX_* bits defined in xadcps_hw.h.
Returns:
None.
Note:
None
void XAdcPs_IntrEnable ( XAdcPs InstancePtr,
u32  Mask 
)

Functions in xadcps_intr.c

This function enables the specified interrupts in the device.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Mask is the bit-mask of the interrupts to be enabled. Bit positions of 1 will be enabled. Bit positions of 0 will keep the previous setting. This mask is formed by OR'ing XADCPS_INTX_* bits defined in xadcps_hw.h.
Returns:
None.
Note:
None.
u32 XAdcPs_IntrGetEnabled ( XAdcPs InstancePtr  ) 

This function returns the enabled interrupts read from the Interrupt Mask Register (IPIER). Use the XADCPS_IPIXR_* constants defined in xadcps_hw.h to interpret the returned value.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
A 32-bit value representing the contents of the I.
Note:
None.
u32 XAdcPs_IntrGetStatus ( XAdcPs InstancePtr  ) 

This function returns the interrupt status read from Interrupt Status Register(IPISR). Use the XADCPS_IPIXR_* constants defined in xadcps_hw.h to interpret the returned value.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
A 32-bit value representing the contents of the IPISR.
Note:
The device must be configured at hardware build time to include interrupt component for this function to work.
XAdcPs_Config* XAdcPs_LookupConfig ( u16  DeviceId  ) 

Functions in xadcps_sinit.c

This function looks up the device configuration based on the unique device ID. The table XAdcPs_ConfigTable contains the configuration info for each device in the system.

Parameters:
DeviceId contains the ID of the device for which the device configuration pointer is to be returned.
Returns:
  • A pointer to the configuration found.
  • NULL if the specified device ID was not found.
Note:
None.
void XAdcPs_Reset ( XAdcPs InstancePtr  ) 

This function resets the XADC Hard Macro in the device.

Parameters:
InstancePtr is a pointer to the Xxadc instance.
Returns:
None.
Note:
None.
int XAdcPs_SelfTest ( XAdcPs InstancePtr  ) 

Functions in xadcps_selftest.c

Run a self-test on the driver/device. The test

  • Resets the device,
  • Writes a value into the Alarm Threshold register and reads it back for comparison.
  • Resets the device again.
Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Returns:
  • XST_SUCCESS if the value read from the Alarm Threshold register is the same as the value written.
  • XST_FAILURE Otherwise
Note:
This is a destructive test in that resets of the device are performed. Refer to the device specification for the device status after the reset operation.
void XAdcPs_SetAdcClkDivisor ( XAdcPs InstancePtr,
u8  Divisor 
)

The function sets the frequency of the ADCCLK by configuring the DCLK to ADCCLK ratio in the Configuration Register #2

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Divisor is clock divisor used to derive ADCCLK from DCLK. Valid values of the divisor are

  • 0 to 255. Values 0, 1, 2 are all mapped to 2. Refer to the device specification for more details
Returns:
None.
Note:
- The ADCCLK is an internal clock used by the ADC and is synchronized to the DCLK clock. The ADCCLK is equal to DCLK divided by the user selection in the Configuration Register 2.
  • There is no Assert on the minimum value of the Divisor.
void XAdcPs_SetAlarmEnables ( XAdcPs InstancePtr,
u16  AlmEnableMask 
)

This function enables the alarm outputs for the specified alarms in the Configuration Register 1.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
AlmEnableMask is the bit-mask of the alarm outputs to be enabled in the Configuration Register 1. Bit positions of 1 will be enabled. Bit positions of 0 will be disabled. This mask is formed by OR'ing XADCPS_CFR1_ALM_*_MASK and XADCPS_CFR1_OT_MASK masks defined in xadcps_hw.h.
Returns:
None.
Note:
The implementation of the alarm enables in the Configuration register 1 is such that the alarms for bit positions of 1 will be disabled and alarms for bit positions of 0 will be enabled. The alarm outputs specified by the AlmEnableMask are negated before writing to the Configuration Register 1.
void XAdcPs_SetAlarmThreshold ( XAdcPs InstancePtr,
u8  AlarmThrReg,
u16  Value 
)

This functions sets the contents of the given Alarm Threshold Register.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
AlarmThrReg is the index of an Alarm Threshold Register to be set. Use XADCPS_ATR_* constants defined in xadcps.h to specify the index.
Value is the 16-bit threshold value to write into the register.
Returns:
None.
Note:
Use XAdcPs_SetOverTemp() to set the Over Temperature upper threshold value.
void XAdcPs_SetAvg ( XAdcPs InstancePtr,
u8  Average 
)

This function sets the number of samples of averaging that is to be done for all the channels in both the single channel mode and sequence mode of operations.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Average is the number of samples of averaging programmed to the Configuration Register 0. Use the XADCPS_AVG_* definitions defined in xadcps.h file :

  • XADCPS_AVG_0_SAMPLES for no averaging
  • XADCPS_AVG_16_SAMPLES for 16 samples of averaging
  • XADCPS_AVG_64_SAMPLES for 64 samples of averaging
  • XADCPS_AVG_256_SAMPLES for 256 samples of averaging
Returns:
None.
Note:
None.
void XAdcPs_SetCalibEnables ( XAdcPs InstancePtr,
u16  Calibration 
)

This function enables the specified calibration in the Configuration Register 1 :

  • XADCPS_CFR1_CAL_ADC_OFFSET_MASK : Calibration 0 -ADC offset correction
  • XADCPS_CFR1_CAL_ADC_GAIN_OFFSET_MASK : Calibration 1 -ADC gain and offset correction
  • XADCPS_CFR1_CAL_PS_OFFSET_MASK : Calibration 2 -Power Supply sensor offset correction
  • XADCPS_CFR1_CAL_PS_GAIN_OFFSET_MASK : Calibration 3 -Power Supply sensor gain and offset correction
  • XADCPS_CFR1_CAL_DISABLE_MASK : No Calibration
Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Calibration is the Calibration to be applied. Use XADCPS_CFR1_CAL*_* bits defined in xadcps_hw.h. Multiple calibrations can be enabled at a time by oring the XADCPS_CFR1_CAL_ADC_* and XADCPS_CFR1_CAL_PS_* bits. Calibration can be disabled by specifying XADCPS_CFR1_CAL_DISABLE_MASK;
Returns:
None.
Note:
None.
void XAdcPs_SetMuxMode ( XAdcPs InstancePtr,
int  MuxMode,
u8  Channel 
)

This function sets the External Mux mode.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
MuxMode specifies whether External Mux is used

  • FALSE specifies NO external MUX
  • TRUE specifies External Mux is used
Channel specifies the channel to be used for the external Mux. Please read the Device Spec for which channels are valid for which mode.
Returns:
None.
Note:
There is no Assert in this function for checking the channel number if the external Mux is used. The user should provide a valid channel number.
void XAdcPs_SetPowerdownMode ( XAdcPs InstancePtr,
u32  Mode 
)

This function sets the Power Down mode.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Mode specifies the Power Down Mode

  • XADCPS_PD_MODE_NONE specifies NO Power Down (Both ADC A and ADC B are enabled)
  • XADCPS_PD_MODE_ADCB specfies the Power Down of ADC B
  • XADCPS_PD_MODE_XADC specifies the Power Down of both ADC A and ADC B.
Returns:
None.
Note:
None.
int XAdcPs_SetSeqAcqTime ( XAdcPs InstancePtr,
u32  AcqCyclesChMask 
)

This function sets the number of Acquisition cycles in the ADC Channel Acquisition Time Sequencer Registers. The sequencer must be disabled before writing to these regsiters.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
AcqCyclesChMask is the bit mask of all the channels for which the number of acquisition cycles is to be extended. Use XADCPS_SEQ_CH__* defined in xadcps_hw.h to specify the Channel numbers. Acquisition cycles will be extended to 10 ADCCLK cycles for bit masks of 1 and will be the default 4 ADCCLK cycles for bit masks of 0. The AcqCyclesChMask is a 32 bit mask that is written to the two 16 bit ADC Channel Acquisition Time Sequencer Registers.
Returns:
  • XST_SUCCESS if the given values were written successfully to the Channel Sequencer Registers.
  • XST_FAILURE if the channel sequencer is enabled.
Note:
None.
int XAdcPs_SetSeqAvgEnables ( XAdcPs InstancePtr,
u32  AvgEnableChMask 
)

This function enables the averaging for the specified channels in the ADC Channel Averaging Enable Sequencer Registers. The sequencer must be disabled before writing to these regsiters.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
AvgEnableChMask is the bit mask of all the channels for which averaging is to be enabled. Use XADCPS_SEQ_CH__* defined in xadcps_hw.h to specify the Channel numbers. Averaging will be enabled for bit masks of 1 and disabled for bit mask of 0. The AvgEnableChMask is a 32 bit mask that is written to the two 16 bit ADC Channel Averaging Enable Sequencer Registers.
Returns:
  • XST_SUCCESS if the given values were written successfully to the ADC Channel Averaging Enables Sequencer Registers.
  • XST_FAILURE if the channel sequencer is enabled.
Note:
None
int XAdcPs_SetSeqChEnables ( XAdcPs InstancePtr,
u32  ChEnableMask 
)

This function enables the specified channels in the ADC Channel Selection Sequencer Registers. The sequencer must be disabled before writing to these regsiters.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
ChEnableMask is the bit mask of all the channels to be enabled. Use XADCPS_SEQ_CH__* defined in xadcps_hw.h to specify the Channel numbers. Bit masks of 1 will be enabled and bit mask of 0 will be disabled. The ChEnableMask is a 32 bit mask that is written to the two 16 bit ADC Channel Selection Sequencer Registers.
Returns:
  • XST_SUCCESS if the given values were written successfully to the ADC Channel Selection Sequencer Registers.
  • XST_FAILURE if the channel sequencer is enabled.
Note:
None
int XAdcPs_SetSeqInputMode ( XAdcPs InstancePtr,
u32  InputModeChMask 
)

This function sets the Analog input mode for the specified channels in the ADC Channel Analog-Input Mode Sequencer Registers. The sequencer must be disabled before writing to these regsiters.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
InputModeChMask is the bit mask of all the channels for which the input mode is differential mode. Use XADCPS_SEQ_CH__* defined in xadcps_hw.h to specify the channel numbers. Differential input mode will be set for bit masks of 1 and unipolar input mode for bit masks of 0. The InputModeChMask is a 32 bit mask that is written to the two 16 bit ADC Channel Analog-Input Mode Sequencer Registers.
Returns:
  • XST_SUCCESS if the given values were written successfully to the ADC Channel Analog-Input Mode Sequencer Registers.
  • XST_FAILURE if the channel sequencer is enabled.
Note:
None
void XAdcPs_SetSequencerEvent ( XAdcPs InstancePtr,
int  IsEventMode 
)

The function enables the Event mode or Continuous mode in the sequencer mode.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
IsEventMode is a boolean parameter that specifies continuous sampling (specify FALSE) or event driven sampling mode (specify TRUE) for the given channel.
Returns:
None.
Note:
None.
void XAdcPs_SetSequencerMode ( XAdcPs InstancePtr,
u8  SequencerMode 
)

This function sets the specified Channel Sequencer Mode in the Configuration Register 1 :

  • Default safe mode (XADCPS_SEQ_MODE_SAFE)
  • One pass through sequence (XADCPS_SEQ_MODE_ONEPASS)
  • Continuous channel sequencing (XADCPS_SEQ_MODE_CONTINPASS)
  • Single Channel/Sequencer off (XADCPS_SEQ_MODE_SINGCHAN)
  • Simulataneous sampling mode (XADCPS_SEQ_MODE_SIMUL_SAMPLING)
  • Independent mode (XADCPS_SEQ_MODE_INDEPENDENT)
Parameters:
InstancePtr is a pointer to the XAdcPs instance.
SequencerMode is the sequencer mode to be set. Use XADCPS_SEQ_MODE_* bits defined in xadcps.h.
Returns:
None.
Note:
Only one of the modes can be enabled at a time. Please read the Spec of the XADC for further information about the sequencer modes.
int XAdcPs_SetSingleChParams ( XAdcPs InstancePtr,
u8  Channel,
int  IncreaseAcqCycles,
int  IsEventMode,
int  IsDifferentialMode 
)

The function sets the given parameters in the Configuration Register 0 in the single channel mode.

Parameters:
InstancePtr is a pointer to the XAdcPs instance.
Channel is the channel number for the singel channel mode. The valid channels are 0 to 6, 8, and 13 to 31. If the external Mux is used then this specifies the channel oonnected to the external Mux. Please read the Device Spec to know which channels are valid.
IncreaseAcqCycles is a boolean parameter which specifies whether the Acquisition time for the external channels has to be increased to 10 ADCCLK cycles (specify TRUE) or remain at the default 4 ADCCLK cycles (specify FALSE). This parameter is only valid for the external channels.
IsDifferentialMode is a boolean parameter which specifies unipolar(specify FALSE) or differential mode (specify TRUE) for the analog inputs. The input mode is only valid for the external channels.
Returns:
  • XST_SUCCESS if the given values were written successfully to the Configuration Register 0.
  • XST_FAILURE if the channel sequencer is enabled or the input parameters are not valid for the selected channel.
Note:
  • The number of samples for the averaging for all the channels is set by using the function XAdcPs_SetAvg.
  • The calibration of the device is done by doing a ADC conversion on the calibration channel(channel 8). The input parameters IncreaseAcqCycles, IsDifferentialMode and IsEventMode are not valid for this channel
void XAdcPs_StartAdcConversion ( XAdcPs InstancePtr  )