ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
ADC Driver

ADC Driver. More...

Modules

 Static Configuration
 

Data Structures

struct  __ADI_ADC_BUFFER
 

Macros

#define ADI_ADC_MEMORY_SIZE   (48u + ADI_SEM_SIZE)
 
#define ADI_ADC_CHANNEL_0   (1u << 0u)
 
#define ADI_ADC_CHANNEL_1   (1u << 1u)
 
#define ADI_ADC_CHANNEL_2   (1u << 2u)
 
#define ADI_ADC_CHANNEL_3   (1u << 3u)
 
#define ADI_ADC_CHANNEL_4   (1u << 4u)
 
#define ADI_ADC_CHANNEL_5   (1u << 5u)
 
#define ADI_ADC_CHANNEL_6   (1u << 6u)
 
#define ADI_ADC_CHANNEL_7   (1u << 7u)
 

Typedefs

typedef uint32_t ADI_ADC_CHANNEL
 
typedef struct __ADI_ADC_BUFFER ADI_ADC_BUFFER
 
typedef struct __ADI_ADC_DEVICE * ADI_ADC_HANDLE
 

Enumerations

enum  ADI_ADC_RESULT {
  ADI_ADC_SUCCESS = 0,
  ADI_ADC_INVALID_DEVICE_NUM,
  ADI_ADC_INVALID_DEVICE_HANDLE,
  ADI_ADC_INVALID_STATE,
  ADI_ADC_INSUFFICIENT_MEMORY,
  ADI_ADC_IN_USE,
  ADI_ADC_INVALID_PARAMETER,
  ADI_ADC_NULL_POINTER,
  ADI_ADC_FAILURE,
  ADI_ADC_INVALID_SEQUENCE,
  ADI_ADC_ERR_RTOS,
  ADI_ADC_INVALID_OPERATION,
  ADI_ADC_INVALID_BUFFER,
  ADI_ADC_BUFFER_OVERFLOW,
  ADI_ADC_DMA_ERROR,
  ADI_ADC_BAD_SYS_CLOCK
}
 
enum  ADI_ADC_VREF_SRC {
  ADI_ADC_VREF_SRC_INT_1_25_V,
  ADI_ADC_VREF_SRC_INT_2_50_V,
  ADI_ADC_VREF_SRC_EXT,
  ADI_ADC_VREF_SRC_VBAT
}
 
enum  ADI_ADC_RESOLUTION {
  ADI_ADC_RESOLUTION_12_BIT,
  ADI_ADC_RESOLUTION_13_BIT,
  ADI_ADC_RESOLUTION_14_BIT,
  ADI_ADC_RESOLUTION_15_BIT,
  ADI_ADC_RESOLUTION_16_BIT
}
 
enum  ADI_ADC_EVENT {
  ADI_ADC_EVENT_CALIBRATION_DONE,
  ADI_ADC_EVENT_ADC_READY,
  ADI_ADC_EVENT_OVERFLOW,
  ADI_ADC_EVENT_HIGH_LIMIT_CROSSED,
  ADI_ADC_EVENT_LOW_LIMIT_CROSSED
}
 

Functions

ADI_ADC_RESULT adi_adc_Open (uint32_t nDeviceNum, void *pMemory, uint32_t nMemorySize, ADI_ADC_HANDLE *phDevice)
 Opens an ADC device instance. More...
 
ADI_ADC_RESULT adi_adc_Close (ADI_ADC_HANDLE hDevice)
 Close the given device instance. More...
 
ADI_ADC_RESULT adi_adc_PowerUp (ADI_ADC_HANDLE hDevice, bool bPowerUp)
 Power up ADC. More...
 
ADI_ADC_RESULT adi_adc_RegisterCallback (ADI_ADC_HANDLE hDevice, ADI_CALLBACK pfCallback, void *pCBParam)
 Registering a callback function. More...
 
ADI_ADC_RESULT adi_adc_EnableADCSubSystem (ADI_ADC_HANDLE hDevice, bool bEnable)
 Enable/Disables the ADC Subsystem. More...
 
ADI_ADC_RESULT adi_adc_IsReady (ADI_ADC_HANDLE hDevice, bool *pbReady)
 Returns whether the ADC Subsystem is ready. More...
 
ADI_ADC_RESULT adi_adc_SetVrefSource (ADI_ADC_HANDLE hDevice, ADI_ADC_VREF_SRC eVrefSrc)
 Set the Voltage Reference source. More...
 
ADI_ADC_RESULT adi_adc_SinkEnable (ADI_ADC_HANDLE hDevice, bool bEnable)
 Enable/Disable Current Sink. More...
 
ADI_ADC_RESULT adi_adc_StartCalibration (ADI_ADC_HANDLE hDevice)
 Start the ADC calibration. More...
 
ADI_ADC_RESULT adi_adc_IsCalibrationDone (ADI_ADC_HANDLE hDevice, bool *pbCalibrationDone)
 Returns the status of the calibration which was initiated. More...
 
ADI_ADC_RESULT adi_adc_SetAcquisitionTime (ADI_ADC_HANDLE hDevice, uint32_t nAcqTimeInAClkCycles)
 Set the acquisition time of ADC in ADC clock cycles. More...
 
ADI_ADC_RESULT adi_adc_SetDelayTime (ADI_ADC_HANDLE hDevice, uint32_t nDelayInAClkCycles)
 Set the delay time of ADC in ADC cycles for multi iteration mode. More...
 
ADI_ADC_RESULT adi_adc_SetResolution (ADI_ADC_HANDLE hDevice, ADI_ADC_RESOLUTION eResolution)
 Set the resolution of ADC. he default resolution of ADC is 12-bit and the ADC increases the resolution by oversampling. Averaging will be disabled when the resolution is more than 12-bits. More...
 
ADI_ADC_RESULT adi_adc_EnableAveraging (ADI_ADC_HANDLE hDevice, uint16_t nAveragingSamples)
 Enable Averaging for all ADC channels. More...
 
ADI_ADC_RESULT adi_adc_SetLowLimit (ADI_ADC_HANDLE hDevice, ADI_ADC_CHANNEL eChannel, bool bEnable, uint16_t nLowLimit)
 Configure low limit for an ADC channel when it is used as a digital comparator. More...
 
ADI_ADC_RESULT adi_adc_SetHighLimit (ADI_ADC_HANDLE hDevice, ADI_ADC_CHANNEL eChannel, bool bEnable, uint16_t nHighLimit)
 Configure high limit for an ADC channel when it's used as a digital comparator. More...
 
ADI_ADC_RESULT adi_adc_SetHysteresis (ADI_ADC_HANDLE hDevice, ADI_ADC_CHANNEL eChannel, bool bEnable, uint16_t nHysteresis)
 Configure hysteresis for an ADC channel when it's used as a digital comparator. More...
 
ADI_ADC_RESULT adi_adc_SetNumMonitorCycles (ADI_ADC_HANDLE hDevice, ADI_ADC_CHANNEL eChannel, uint32_t nNumMonitorCycles)
 Configure number of monitor cycles for an ADC channel when it's used as a digital comparator. More...
 
ADI_ADC_RESULT adi_adc_EnableDigitalComparator (ADI_ADC_HANDLE hDevice, bool bEnableComparator)
 Enable/Disable digital comparator for the given channel(s) More...
 
ADI_ADC_RESULT adi_adc_SubmitBuffer (ADI_ADC_HANDLE hDevice, ADI_ADC_BUFFER *pBuffer)
 Submit the ADC buffer for processing to the ADC Module. More...
 
ADI_ADC_RESULT adi_adc_GetBuffer (ADI_ADC_HANDLE hDevice, ADI_ADC_BUFFER **ppBuffer)
 Get a processed buffer from the ADC Driver. This function is a blocking call and will only return once it has the buffer or if any error occurred. If a callback is registered then any call to this function will fail. More...
 
ADI_ADC_RESULT adi_adc_Enable (ADI_ADC_HANDLE hDevice, bool bEnable)
 Enable/Disable ADC for sampling. More...
 
ADI_ADC_RESULT adi_adc_IsBufferAvailable (ADI_ADC_HANDLE hDevice, bool *pbIsBufferAvailable)
 This function return whether a filled buffer is available to be returned to the user. If this function return true, then a call to adi_adc_GetBuffer will not block. More...
 
ADI_ADC_RESULT adi_adc_ReadChannels (ADI_ADC_HANDLE hDevice, uint32_t nChannels, uint32_t nNumConversionPasses, void *pBuffer, uint32_t nBuffLength)
 Sample the given channels for the given number of conversion passes and put it into the given buffer. This function only return after the channels are sampled the given number of conversion times or if any error occurs. More...
 
ADI_ADC_RESULT adi_adc_GetBatteryVoltage (ADI_ADC_HANDLE hDevice, uint32_t nRefVoltage, uint32_t *pnBatVoltage)
 Returns the battery voltage. More...
 
ADI_ADC_RESULT adi_adc_EnableTemperatureSensor (ADI_ADC_HANDLE hDevice, bool bEnable)
 Enable or disable the temperature sensor. More...
 
ADI_ADC_RESULT adi_adc_GetTemperature (ADI_ADC_HANDLE hDevice, uint32_t nRefVoltage, int32_t *pnTemperature)
 Return the temperature in fixed point format in degree Celcius. More...
 

Detailed Description

ADC Driver.

The ADC driver manages all instances of the ADC peripheral.

Note
- The application must include drivers/adc/adi_adc.h to use this driver.
- This driver also requires the DMA driver. The application must include the DMA driver sources to avoid link errors.
- This documentation presented here is API documentation only. The device drive user's guide, located in the Documents folder, explains how to use these APIs in an application.

Macro Definition Documentation

◆ ADI_ADC_MEMORY_SIZE

#define ADI_ADC_MEMORY_SIZE   (48u + ADI_SEM_SIZE)

Amount of memory(In bytes) required by the ADC device driver for managing the operation of a ADC controller. The memory is passed to the driver when the driver is opended. The memory is completely owned by the driver till the the driver is closed.Memory Size of the buffer required by the ADC driver

Definition at line 66 of file adi_adc.h.

Referenced by adi_adc_Open().

◆ ADI_ADC_CHANNEL_0

#define ADI_ADC_CHANNEL_0   (1u << 0u)

defines for ADC ChannelsADC Channel 0

Definition at line 124 of file adi_adc.h.

◆ ADI_ADC_CHANNEL_1

#define ADI_ADC_CHANNEL_1   (1u << 1u)

ADC Channel 1

Definition at line 125 of file adi_adc.h.

◆ ADI_ADC_CHANNEL_2

#define ADI_ADC_CHANNEL_2   (1u << 2u)

ADC Channel 2

Definition at line 126 of file adi_adc.h.

◆ ADI_ADC_CHANNEL_3

#define ADI_ADC_CHANNEL_3   (1u << 3u)

ADC Channel 3

Definition at line 127 of file adi_adc.h.

◆ ADI_ADC_CHANNEL_4

#define ADI_ADC_CHANNEL_4   (1u << 4u)

ADC Channel 4

Definition at line 128 of file adi_adc.h.

◆ ADI_ADC_CHANNEL_5

#define ADI_ADC_CHANNEL_5   (1u << 5u)

ADC Channel 5

Definition at line 129 of file adi_adc.h.

◆ ADI_ADC_CHANNEL_6

#define ADI_ADC_CHANNEL_6   (1u << 6u)

ADC Channel 6

Definition at line 130 of file adi_adc.h.

◆ ADI_ADC_CHANNEL_7

#define ADI_ADC_CHANNEL_7   (1u << 7u)

ADC Channel 7

Definition at line 131 of file adi_adc.h.

Typedef Documentation

◆ ADI_ADC_CHANNEL

Typedef for ADC Channels

Definition at line 119 of file adi_adc.h.

◆ ADI_ADC_BUFFER

Structure which hold the details of the buffer and sampling details

◆ ADI_ADC_HANDLE

typedef struct __ADI_ADC_DEVICE* ADI_ADC_HANDLE

ADC Device Handler

Definition at line 163 of file adi_adc.h.

Enumeration Type Documentation

◆ ADI_ADC_RESULT

ADC API return codes

Enumerator
ADI_ADC_SUCCESS 

No Error, API suceeded

ADI_ADC_INVALID_DEVICE_NUM 

Invalid device number passed

ADI_ADC_INVALID_DEVICE_HANDLE 

Invalid device handle passed

ADI_ADC_INVALID_STATE 

Invalid State

ADI_ADC_INSUFFICIENT_MEMORY 

Insufficient memory passed to the driver

ADI_ADC_IN_USE 

ADC is alreaady in use

ADI_ADC_INVALID_PARAMETER 

Invalid parameter passed to the driver

ADI_ADC_NULL_POINTER 

Null pointer passed when expecting a valid pointer

ADI_ADC_FAILURE 

General ADC Failure

ADI_ADC_INVALID_SEQUENCE 

Invalid sequence of API calls

ADI_ADC_ERR_RTOS 

RTOS error occurred

ADI_ADC_INVALID_OPERATION 

API call is an invalid operation

ADI_ADC_INVALID_BUFFER 

Buffer passed to the application is invalid

ADI_ADC_BUFFER_OVERFLOW 

Buffer overflow occurred

ADI_ADC_DMA_ERROR 

DMA Error occurred

ADI_ADC_BAD_SYS_CLOCK 

Could not retrieve core clock value.

Definition at line 73 of file adi_adc.h.

◆ ADI_ADC_VREF_SRC

Voltage Reference source selection.

Enumerator
ADI_ADC_VREF_SRC_INT_1_25_V 

1.25V Internal Voltage Reference

ADI_ADC_VREF_SRC_INT_2_50_V 

2.50V Internal Voltage Reference

ADI_ADC_VREF_SRC_EXT 

External Voltage Reference

ADI_ADC_VREF_SRC_VBAT 

Battery Voltage as Voltage Reference source

Definition at line 96 of file adi_adc.h.

◆ ADI_ADC_RESOLUTION

Resolution of the ADC.

Enumerator
ADI_ADC_RESOLUTION_12_BIT 

12-bit ADC Resolution

ADI_ADC_RESOLUTION_13_BIT 

13-bit ADC Resolution

ADI_ADC_RESOLUTION_14_BIT 

14-bit ADC Resolution

ADI_ADC_RESOLUTION_15_BIT 

15-bit ADC Resolution

ADI_ADC_RESOLUTION_16_BIT 

16-bit ADC Resolution

Definition at line 107 of file adi_adc.h.

◆ ADI_ADC_EVENT

Callback events from the ADC driver.

Enumerator
ADI_ADC_EVENT_CALIBRATION_DONE 

Calibration done event. arg to the callback function will be NULL.

ADI_ADC_EVENT_ADC_READY 

ADC Ready event. arg to the callback function will be null

ADI_ADC_EVENT_OVERFLOW 

Overflow event occurred. The channel(ADI_ADC_CHANNEL) for which the overflow occurred will be passed as arg to the callback function.

ADI_ADC_EVENT_HIGH_LIMIT_CROSSED 

High Limit crossed event. The channel(ADI_ADC_CHANNEL) for which the limit is crossed will be passed as arg to the callback function.

ADI_ADC_EVENT_LOW_LIMIT_CROSSED 

Low Limit crossed event. The channel(ADI_ADC_CHANNEL) for which the limit is crossed will be passed as arg to the callback function.

Definition at line 137 of file adi_adc.h.

Function Documentation

◆ adi_adc_Open()

ADI_ADC_RESULT adi_adc_Open ( uint32_t  nDeviceNum,
void *  pMemory,
uint32_t  nMemorySize,
ADI_ADC_HANDLE phDevice 
)

Opens an ADC device instance.

Parameters
[in]nDeviceNumDevice number to open
[in]pMemoryPointer to a ADI_ADC_MEMORY_SIZE sized buffer to manage the device instance.
[in]nMemorySizeSize of the buffer to which "pMemory" points
[out]phDevicePointer to a location where ADC device handle is to be written.
Returns
Status

Definition at line 179 of file adi_adc.c.

◆ adi_adc_Close()

ADI_ADC_RESULT adi_adc_Close ( ADI_ADC_HANDLE  hDevice)

Close the given device instance.

Parameters
[in]hDeviceHandle to the device instance
Returns
Status

Definition at line 255 of file adi_adc.c.

◆ adi_adc_PowerUp()

ADI_ADC_RESULT adi_adc_PowerUp ( ADI_ADC_HANDLE  hDevice,
bool  bPowerUp 
)

Power up ADC.

Parameters
[in]hDeviceHandle to the device instance
[in]bPowerUp'true' to power up and 'false' to power down the ADC.
Returns
Status

Definition at line 309 of file adi_adc.c.

Referenced by adi_adc_Close().

◆ adi_adc_RegisterCallback()

ADI_ADC_RESULT adi_adc_RegisterCallback ( ADI_ADC_HANDLE  hDevice,
ADI_CALLBACK  pfCallback,
void *  pCBParam 
)

Registering a callback function.

Parameters
[in]hDeviceHandle to the device instance
[in]pfCallbackFunction pointer to callback function. Passing a NULL pointer will unregister the call back function.
[in]pCBParamCall back function parameter

This function registers a call back function. Registered function will be called when the given computation is over. It will also be called when the digital comparitor is being used and a limit has been broken.

Returns
Status

Definition at line 389 of file adi_adc.c.

◆ adi_adc_EnableADCSubSystem()

ADI_ADC_RESULT adi_adc_EnableADCSubSystem ( ADI_ADC_HANDLE  hDevice,
bool  bEnable 
)

Enable/Disables the ADC Subsystem.

Parameters
[in]hDeviceHandle to the device instance
[in]bEnable'true' to Enable and 'false' to Disable`

Enables/Disables the ADC Subsystem. The ADC subsystem need to be enabled before using the ADC for sampling the signal. The driver should check whether the ADC is ready by calling adi_adc_IsReady API before continuing. If internal reference buffer is used as voltage reference then application has to wait at least 3.5ms after enabling irrespective of whether adi_adc_IsReady returns ready or not.

Returns
Status

Definition at line 438 of file adi_adc.c.

Referenced by adi_adc_PowerUp().

◆ adi_adc_IsReady()

ADI_ADC_RESULT adi_adc_IsReady ( ADI_ADC_HANDLE  hDevice,
bool *  pbReady 
)

Returns whether the ADC Subsystem is ready.

Parameters
[in]hDeviceHandle to the device instance
[in]pbReadyPointer to a bool variable. The variable will be set to 'true' if the ADC is ready else 'false'

Returns whether the ADC is ready for sampling. This API should be called after enabling the ADC sub-system using adi_adc_EnableADCSubSystem API. If internal reference buffer is used as voltage reference then application has to wait at least 3.5ms after enabling irrespective of whether adi_adc_IsReady returns ready or not.

Returns
Status

Definition at line 500 of file adi_adc.c.

◆ adi_adc_SetVrefSource()

ADI_ADC_RESULT adi_adc_SetVrefSource ( ADI_ADC_HANDLE  hDevice,
ADI_ADC_VREF_SRC  eVrefSrc 
)

Set the Voltage Reference source.

Parameters
[in]hDeviceHandle to the device instance
[in]eVrefSrcVoltage Reference source to be used

The API can be used to select the voltage reference to be used by the ADC. This option need to be set before enabling the ADC subsystem.

Returns
Status

Definition at line 552 of file adi_adc.c.

◆ adi_adc_SinkEnable()

ADI_ADC_RESULT adi_adc_SinkEnable ( ADI_ADC_HANDLE  hDevice,
bool  bEnable 
)

Enable/Disable Current Sink.

Parameters
[in]hDeviceHandle to the device instance
[in]bEnable'true' to Enable and 'false' to Disable current sink

If the volatage reference is required to sink current then this option need to be enabled. The ADC subsystem has the capability to sink upto 50uA at Vref of 1.25V and 100uA at Vref of 2.5V

Returns
Status

Definition at line 614 of file adi_adc.c.

◆ adi_adc_StartCalibration()

ADI_ADC_RESULT adi_adc_StartCalibration ( ADI_ADC_HANDLE  hDevice)

Start the ADC calibration.

Parameters
[in]hDeviceHandle to the device instance

The call to this function initiate calibration of the ADC. The user is recommended to do calibration of the ADC after enabling the ADC subsystem. The status of the calibration can be checked using adi_adc_IsCalibrationDone API.

Returns
Status

Definition at line 653 of file adi_adc.c.

◆ adi_adc_IsCalibrationDone()

ADI_ADC_RESULT adi_adc_IsCalibrationDone ( ADI_ADC_HANDLE  hDevice,
bool *  pbCalibrationDone 
)

Returns the status of the calibration which was initiated.

Parameters
[in]hDeviceHandle to the device instance
[out]pbCalibrationDonePointer to the location to which the status of calibration is written. 'true' if the calibration started by call to is done else 'false'
Returns
Status

Definition at line 701 of file adi_adc.c.

◆ adi_adc_SetAcquisitionTime()

ADI_ADC_RESULT adi_adc_SetAcquisitionTime ( ADI_ADC_HANDLE  hDevice,
uint32_t  nAcqTimeInAClkCycles 
)

Set the acquisition time of ADC in ADC clock cycles.

Set the acquisition time of ADC in ADC clock cycles. The acquisition phase is (ADC_CNV_TIME.SAMPTIME + 1) ACLK cycles

Parameters
[in]hDeviceHandle to the device instance
[in]nAcqTimeInAClkCyclesAcquisition time in ADC clock cycles. A valid range is 1u to the width of the SAMPTIME field + 1.
Returns
Status

Definition at line 753 of file adi_adc.c.

◆ adi_adc_SetDelayTime()

ADI_ADC_RESULT adi_adc_SetDelayTime ( ADI_ADC_HANDLE  hDevice,
uint32_t  nDelayInAClkCycles 
)

Set the delay time of ADC in ADC cycles for multi iteration mode.

Parameters
[in]hDeviceHandle to the device instance
[in]nDelayInAClkCyclesDelay time in ADC clock cycles.
Returns
Status

Definition at line 801 of file adi_adc.c.

◆ adi_adc_SetResolution()

ADI_ADC_RESULT adi_adc_SetResolution ( ADI_ADC_HANDLE  hDevice,
ADI_ADC_RESOLUTION  eResolution 
)

Set the resolution of ADC. he default resolution of ADC is 12-bit and the ADC increases the resolution by oversampling. Averaging will be disabled when the resolution is more than 12-bits.

Parameters
[in]hDeviceHandle to the device instance
[in]eResolutionEnum of ADC resolution
Returns
Status

Definition at line 843 of file adi_adc.c.

◆ adi_adc_EnableAveraging()

ADI_ADC_RESULT adi_adc_EnableAveraging ( ADI_ADC_HANDLE  hDevice,
uint16_t  nAveragingSamples 
)

Enable Averaging for all ADC channels.

Parameters
[in]hDeviceHandle to the device instance
[in]nAveragingSamplesSpecifies the number of samples used for averaging. The valid value is between 1-256, in the steps of power of 2. 1 is for disabling averaging. The averaging require that the resolution of ADC is 12-bit.
Returns
Status

Definition at line 911 of file adi_adc.c.

◆ adi_adc_SetLowLimit()

ADI_ADC_RESULT adi_adc_SetLowLimit ( ADI_ADC_HANDLE  hDevice,
ADI_ADC_CHANNEL  eChannel,
bool  bEnable,
uint16_t  nLowLimit 
)

Configure low limit for an ADC channel when it is used as a digital comparator.

Parameters
[in]hDeviceHandle to the device instance
[in]eChannelThe ADC channel for which to configure the comparator
[in]bEnableEnable or disable the low limit of the digital comparator
[in]nLowLimitThe low limit of the digital comparator. If bEnable is false, this paramter is omitted.
Returns
Status

Definition at line 969 of file adi_adc.c.

◆ adi_adc_SetHighLimit()

ADI_ADC_RESULT adi_adc_SetHighLimit ( ADI_ADC_HANDLE  hDevice,
ADI_ADC_CHANNEL  eChannel,
bool  bEnable,
uint16_t  nHighLimit 
)

Configure high limit for an ADC channel when it's used as a digital comparator.

Parameters
[in]hDeviceHandle to the device instance
[in]eChannelThe ADC channel for which to configure the comparator
[in]bEnableEnable or disable the high limit of the digital comparator
[in]nHighLimitThe high limit of the digital comparator. If bEnable is false, this paramter is omitted.
Returns
Status

Definition at line 1028 of file adi_adc.c.

◆ adi_adc_SetHysteresis()

ADI_ADC_RESULT adi_adc_SetHysteresis ( ADI_ADC_HANDLE  hDevice,
ADI_ADC_CHANNEL  eChannel,
bool  bEnable,
uint16_t  nHysteresis 
)

Configure hysteresis for an ADC channel when it's used as a digital comparator.

Parameters
[in]hDeviceHandle to the device instance
[in]eChannelThe ADC channel for which to configure the comparator
[in]bEnableEnable or disable the hysteresis of the digital comparator
[in]nHysteresisThe hysteresis to be used. If bEnable is false, this paramter is omitted.
Returns
Status

Definition at line 1085 of file adi_adc.c.

◆ adi_adc_SetNumMonitorCycles()

ADI_ADC_RESULT adi_adc_SetNumMonitorCycles ( ADI_ADC_HANDLE  hDevice,
ADI_ADC_CHANNEL  eChannel,
uint32_t  nNumMonitorCycles 
)

Configure number of monitor cycles for an ADC channel when it's used as a digital comparator.

Parameters
[in]hDeviceHandle to the device instance
[in]eChannelThe ADC channel for which to configure the comparator
[in]nNumMonitorCyclesNumber of Monitor cycles before giving interrupt
Returns
Status

Definition at line 1140 of file adi_adc.c.

◆ adi_adc_EnableDigitalComparator()

ADI_ADC_RESULT adi_adc_EnableDigitalComparator ( ADI_ADC_HANDLE  hDevice,
bool  bEnableComparator 
)

Enable/Disable digital comparator for the given channel(s)

Parameters
[in]hDeviceHandle to the device instance
[in]bEnableComparator'true' to Enable and 'false' to disable
Returns
Status

Definition at line 1192 of file adi_adc.c.

◆ adi_adc_SubmitBuffer()

ADI_ADC_RESULT adi_adc_SubmitBuffer ( ADI_ADC_HANDLE  hDevice,
ADI_ADC_BUFFER pBuffer 
)

Submit the ADC buffer for processing to the ADC Module.

Parameters
[in]hDeviceHandle to the device instance.
[in]pBufferPointer to the ADI_ADC_BUFFER structure which contains details of the buffers required by the driver.
Returns
Status
Note
The driver will take ownership of the ADI_ADC_BUFFER structure passed to the driver. The application has to make sure the structure is not used and it's scope is valid till the structure is returned back to the application.

Definition at line 1247 of file adi_adc.c.

◆ adi_adc_GetBuffer()

ADI_ADC_RESULT adi_adc_GetBuffer ( ADI_ADC_HANDLE  hDevice,
ADI_ADC_BUFFER **  ppBuffer 
)

Get a processed buffer from the ADC Driver. This function is a blocking call and will only return once it has the buffer or if any error occurred. If a callback is registered then any call to this function will fail.

Parameters
[in]hDeviceHandle to the device instance.
[out]ppBufferPointer to a pointer to ADI_ADC_BUFFER structure. The returned pointer to ADI_ADC_BUFFER is written here.
Returns
Status

Definition at line 1310 of file adi_adc.c.

◆ adi_adc_Enable()

ADI_ADC_RESULT adi_adc_Enable ( ADI_ADC_HANDLE  hDevice,
bool  bEnable 
)

Enable/Disable ADC for sampling.

Parameters
[in]hDeviceHandle to the device instance
[in]bEnable'true' to Enable and 'false' to disable
Returns
Status

Definition at line 1364 of file adi_adc.c.

◆ adi_adc_IsBufferAvailable()

ADI_ADC_RESULT adi_adc_IsBufferAvailable ( ADI_ADC_HANDLE  hDevice,
bool *  pbIsBufferAvailable 
)

This function return whether a filled buffer is available to be returned to the user. If this function return true, then a call to adi_adc_GetBuffer will not block.

Parameters
[in]hDeviceHandle to the device instance.
[out]pbIsBufferAvailablePointer to a bool variable to which the availability of buffer will be written. The variable will be set to 'true' if buffer is available else 'false'
Returns
Status

Definition at line 1419 of file adi_adc.c.

◆ adi_adc_ReadChannels()

ADI_ADC_RESULT adi_adc_ReadChannels ( ADI_ADC_HANDLE  hDevice,
uint32_t  nChannels,
uint32_t  nNumConversionPasses,
void *  pBuffer,
uint32_t  nBuffLength 
)

Sample the given channels for the given number of conversion passes and put it into the given buffer. This function only return after the channels are sampled the given number of conversion times or if any error occurs.

Parameters
[in]hDeviceHandle to the device instance
[in]nChannelsChannels to sample. Should be an ORed value of ADI_ADC_CHANNEL types.
[in]nNumConversionPassesNumber of conversion passes. In one conversion pass, the ADC will sample all the given channel(s) once.
[in]pBufferPointer to the buffer to which the sampled data is put.
[in]nBuffLengthLength of the buffer. The length of the buffer should be at least 2*(Num of Channels)*nNumConversionPasses bytes.

Sample all the given channels for the given number of conversion passes and put the samples values into the given buffers. The channels will be sampled starting from the lower number. This function only return after the channels are sampled the given number of conversion times or if any error occurs.

Returns
Status

Definition at line 1479 of file adi_adc.c.

◆ adi_adc_GetBatteryVoltage()

ADI_ADC_RESULT adi_adc_GetBatteryVoltage ( ADI_ADC_HANDLE  hDevice,
uint32_t  nRefVoltage,
uint32_t *  pnBatVoltage 
)

Returns the battery voltage.

Parameters
[in]hDeviceHandle to the device instance.
[in]nRefVoltageReference voltage in fixed point(16.16) format.
[out]pnBatVoltagePointer to a variable to which the voltage of the battery will be written. The battery voltage will be in fixed point (16.16) format.
Returns
Status

Definition at line 1574 of file adi_adc.c.

◆ adi_adc_EnableTemperatureSensor()

ADI_ADC_RESULT adi_adc_EnableTemperatureSensor ( ADI_ADC_HANDLE  hDevice,
bool  bEnable 
)

Enable or disable the temperature sensor.

Parameters
[in]hDeviceHandle to the device instance.
[in]bEnable'true' to enable and 'false' to disable the temperature sensor
Returns
Status

Definition at line 1667 of file adi_adc.c.

◆ adi_adc_GetTemperature()

ADI_ADC_RESULT adi_adc_GetTemperature ( ADI_ADC_HANDLE  hDevice,
uint32_t  nRefVoltage,
int32_t *  pnTemperature 
)

Return the temperature in fixed point format in degree Celcius.

Parameters
[in]hDeviceHandle to the device instance.
[in]nRefVoltageReference voltage in fixed point(16.16) format.
[out]pnTemperaturePointer to a variable to which the ADC die temperature (in degree Celsius) will be written. The temperature will be in fixed point (16.16) format.
Returns
Status
  • ADI_ADC_SUCCESS Successfully retrieved the die temperature
  • ADI_ADC_BAD_SYS_CLOCK Unable to obtain CLK which is needed to calculate temperature conversion timing values.
  • ADI_ADC_INVALID_DEVICE_HANDLE [D] Invalid device handle passed to the API
  • ADI_ADC_NULL_POINTER [D] pnBatVoltage is NULL
  • ADI_ADC_INVALID_SEQUENCE [D] ADC sub system should be up and ADC should be free for getting the battery voltage. The Temperator sensor also need to be enabled.
  • ADI_ADC_INVALID_STATE [D] Temperature sensor require an aquisition time of 65us and that cannot be set with the current ACLK since only ACLK of 255 can be stored to the sampling register. Decrease the ACLK clock to rectify this.

Definition at line 1718 of file adi_adc.c.