ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
adi_adc.h
1 
45 #ifndef ADI_ADC_H
46 #define ADI_ADC_H
47 
48 #include <adi_processor.h>
49 #include <adi_callback.h>
50 #include <adi_adc_config.h>
51 #include <rtos_map/adi_rtos_map.h> /* for ADI_SEM_SIZE */
52 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
66 #define ADI_ADC_MEMORY_SIZE (48u + ADI_SEM_SIZE)
73 typedef enum {
91 
96 typedef enum {
102 
107 typedef enum {
114 
119 typedef uint32_t ADI_ADC_CHANNEL;
120 
124 #define ADI_ADC_CHANNEL_0 (1u << 0u)
125 #define ADI_ADC_CHANNEL_1 (1u << 1u)
126 #define ADI_ADC_CHANNEL_2 (1u << 2u)
127 #define ADI_ADC_CHANNEL_3 (1u << 3u)
128 #define ADI_ADC_CHANNEL_4 (1u << 4u)
129 #define ADI_ADC_CHANNEL_5 (1u << 5u)
130 #define ADI_ADC_CHANNEL_6 (1u << 6u)
131 #define ADI_ADC_CHANNEL_7 (1u << 7u)
137 typedef enum {
143 } ADI_ADC_EVENT;
144 
146 typedef struct __ADI_ADC_BUFFER {
147  uint32_t nChannels;
148  void* pDataBuffer;
159  uint32_t nBuffSize;
161 
162 /* Type def for the ADC Handle. */
163 typedef struct __ADI_ADC_DEVICE* ADI_ADC_HANDLE;
166 /*============= A P I F U N C T I O N S P R O T O T Y P E S =============*/
167 
168 /* Opens an ADC device instance. */
170  uint32_t nDeviceNum,
171  void* pMemory,
172  uint32_t nMemorySize,
173  ADI_ADC_HANDLE* phDevice
174 );
175 
176 /* Close the given device instance */
178 
179 /* Power up or power down the ADC */
180 ADI_ADC_RESULT adi_adc_PowerUp (ADI_ADC_HANDLE hDevice, bool bPowerUp);
181 
182 /* Register the callback */
184  ADI_ADC_HANDLE hDevice,
185  ADI_CALLBACK pfCallback,
186  void *pCBParam
187 );
188 
189 /* Enables/Disables the ADC Subsystem */
191  ADI_ADC_HANDLE hDevice,
192  bool bEnable
193 );
194 
195 /* Returns whether the ADC subsytem is ready */
197  ADI_ADC_HANDLE hDevice,
198  bool *pbReady
199 );
200 
201 /* Set the voltage reference source */
203  ADI_ADC_HANDLE hDevice,
204  ADI_ADC_VREF_SRC eVrefSrc
205 );
206 
207 /* Enable/Disable current sink */
209  ADI_ADC_HANDLE hDevice,
210  bool bEnable
211 );
212 
213 /* Start the ADC Calibration */
215  ADI_ADC_HANDLE hDevice
216 );
217 
219  ADI_ADC_HANDLE hDevice,
220  bool* pbCalibrationDone
221  );
222 
223 
224 /* Set the acquisition time of ADC in ADC clock cycles */
226  ADI_ADC_HANDLE hDevice,
227  uint32_t nAcqTimeInAClkCycles
228 );
229 
230 /* Set the delay time of ADC in ADC cycles for multi iteration mode */
232  ADI_ADC_HANDLE hDevice,
233  uint32_t nDelayInAClkCycles
234 );
235 
236 /* set the resolution of ADC. The default resolution of ADC is 12-bit and the ADC increases the resolution by oversampling */
238  ADI_ADC_HANDLE hDevice,
239  ADI_ADC_RESOLUTION eResolution
240 );
241 
242 /* Enable Averaging for all ADC channels */
244  ADI_ADC_HANDLE hDevice,
245  uint16_t nAveragingSamples
246 );
247 
248 /* Configure low limit for an ADC channel when it's used as a digital comparator. */
250  ADI_ADC_HANDLE hDevice,
251  ADI_ADC_CHANNEL eChannel,
252  bool bEnable,
253  uint16_t nLowLimit
254 );
255 
256 /* Configure high limit for an ADC channel when it's used as a digital comparator. */
258  ADI_ADC_HANDLE hDevice,
259  ADI_ADC_CHANNEL eChannel,
260  bool bEnable,
261  uint16_t nHighLimit
262 );
263 
264 
265 /* Configure hysteresis for an ADC channel when it's used as a digital comparator. */
267  ADI_ADC_HANDLE hDevice,
268  ADI_ADC_CHANNEL eChannel,
269  bool bEnable,
270  uint16_t nHysteresis
271 );
272 
273 /* Configure number of monitor cycles for an ADC channel when it's used as a digital comparator. */
275  ADI_ADC_HANDLE hDevice,
276  ADI_ADC_CHANNEL eChannel,
277  uint32_t nNumMonitorCycles
278 );
279 
280 /* Enable/Disable digital comparator for the given channel(s) */
282  ADI_ADC_HANDLE hDevice,
283  bool bEnableComparator
284 );
285 
286 /* Submit buffer for sampling */
288  ADI_ADC_HANDLE hDevice,
289  ADI_ADC_BUFFER* pBuffer
290 );
291 
292 /* Get a completed buffer from the driver */
294  ADI_ADC_HANDLE hDevice,
295  ADI_ADC_BUFFER** ppBuffer
296 );
297 
298 /* Enable/Disable buffer processing */
300  ADI_ADC_HANDLE hDevice,
301  bool bEnable
302 );
303 
304 /* Check whether a completed buffer is available in the driver */
306  ADI_ADC_HANDLE hDevice,
307  bool* pbIsBufferAvailable
308 );
309 
310 /* Read the given channels. This will only return once the given amount of samples are collected */
312  ADI_ADC_HANDLE hDevice,
313  uint32_t nChannels,
314  uint32_t nNumConversionPasses,
315  void* pBuffer,
316  uint32_t nBuffLength
317 );
318 
319 /* Get Battery Voltage */
321  ADI_ADC_HANDLE hDevice,
322  uint32_t nRefVoltage,
323  uint32_t* pnBatVoltage
324 );
325 
326 /* Enable/Disable Temperature Sensor */
328  ADI_ADC_HANDLE hDevice,
329  bool bEnable
330  );
331 
332 /* Get the Temperature Value */
334  ADI_ADC_HANDLE hDevice,
335  uint32_t nRefVoltage,
336  int32_t* pnTemperature
337  );
338 
339 #ifdef __cplusplus
340 }
341 #endif
342 
346 #endif /* ADI_ADC_H */
ADI_ADC_RESULT adi_adc_Close(ADI_ADC_HANDLE hDevice)
Close the given device instance.
Definition: adi_adc.c:255
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.
Definition: adi_adc.c:969
ADI_ADC_RESULT adi_adc_IsCalibrationDone(ADI_ADC_HANDLE hDevice, bool *pbCalibrationDone)
Returns the status of the calibration which was initiated.
Definition: adi_adc.c:701
ADI_ADC_RESULT adi_adc_EnableTemperatureSensor(ADI_ADC_HANDLE hDevice, bool bEnable)
Enable or disable the temperature sensor.
Definition: adi_adc.c:1667
ADI_ADC_RESULT adi_adc_EnableAveraging(ADI_ADC_HANDLE hDevice, uint16_t nAveragingSamples)
Enable Averaging for all ADC channels.
Definition: adi_adc.c:911
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&#39;s used as a digital comparator.
Definition: adi_adc.c:1085
uint32_t ADI_ADC_CHANNEL
Definition: adi_adc.h:119
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...
Definition: adi_adc.c:1479
ADI_ADC_RESULT adi_adc_SinkEnable(ADI_ADC_HANDLE hDevice, bool bEnable)
Enable/Disable Current Sink.
Definition: adi_adc.c:614
uint32_t nBuffSize
Definition: adi_adc.h:159
ADI_ADC_RESULT adi_adc_Open(uint32_t nDeviceNum, void *pMemory, uint32_t nMemorySize, ADI_ADC_HANDLE *phDevice)
Opens an ADC device instance.
Definition: adi_adc.c:179
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.
Definition: adi_adc.c:801
ADI_ADC_RESULT adi_adc_EnableADCSubSystem(ADI_ADC_HANDLE hDevice, bool bEnable)
Enable/Disables the ADC Subsystem.
Definition: adi_adc.c:438
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&#39;s used as a digital comparator...
Definition: adi_adc.c:1140
ADI_ADC_EVENT
Definition: adi_adc.h:137
ADI_ADC_VREF_SRC
Definition: adi_adc.h:96
ADI_ADC_RESULT adi_adc_PowerUp(ADI_ADC_HANDLE hDevice, bool bPowerUp)
Power up ADC.
Definition: adi_adc.c:309
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 onc...
Definition: adi_adc.c:1310
ADI_ADC_RESULT adi_adc_GetBatteryVoltage(ADI_ADC_HANDLE hDevice, uint32_t nRefVoltage, uint32_t *pnBatVoltage)
Returns the battery voltage.
Definition: adi_adc.c:1574
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&#39;s used as a digital comparator.
Definition: adi_adc.c:1028
void * pDataBuffer
Definition: adi_adc.h:148
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.
Definition: adi_adc.c:1419
uint32_t nNumConversionPasses
Definition: adi_adc.h:158
struct __ADI_ADC_BUFFER ADI_ADC_BUFFER
ADI_ADC_RESULT adi_adc_SetAcquisitionTime(ADI_ADC_HANDLE hDevice, uint32_t nAcqTimeInAClkCycles)
Set the acquisition time of ADC in ADC clock cycles.
Definition: adi_adc.c:753
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 resolutio...
Definition: adi_adc.c:843
ADI_ADC_RESULT adi_adc_SubmitBuffer(ADI_ADC_HANDLE hDevice, ADI_ADC_BUFFER *pBuffer)
Submit the ADC buffer for processing to the ADC Module.
Definition: adi_adc.c:1247
ADI_ADC_RESULT adi_adc_Enable(ADI_ADC_HANDLE hDevice, bool bEnable)
Enable/Disable ADC for sampling.
Definition: adi_adc.c:1364
ADI_ADC_RESULT adi_adc_IsReady(ADI_ADC_HANDLE hDevice, bool *pbReady)
Returns whether the ADC Subsystem is ready.
Definition: adi_adc.c:500
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.
Definition: adi_adc.c:1718
uint32_t nChannels
Definition: adi_adc.h:147
struct __ADI_ADC_DEVICE * ADI_ADC_HANDLE
Definition: adi_adc.h:163
ADI_ADC_RESULT adi_adc_RegisterCallback(ADI_ADC_HANDLE hDevice, ADI_CALLBACK pfCallback, void *pCBParam)
Registering a callback function.
Definition: adi_adc.c:389
ADI_ADC_RESULT adi_adc_EnableDigitalComparator(ADI_ADC_HANDLE hDevice, bool bEnableComparator)
Enable/Disable digital comparator for the given channel(s)
Definition: adi_adc.c:1192
ADI_ADC_RESULT
Definition: adi_adc.h:73
ADI_ADC_RESULT adi_adc_SetVrefSource(ADI_ADC_HANDLE hDevice, ADI_ADC_VREF_SRC eVrefSrc)
Set the Voltage Reference source.
Definition: adi_adc.c:552
ADI_ADC_RESOLUTION
Definition: adi_adc.h:107
ADI_ADC_RESULT adi_adc_StartCalibration(ADI_ADC_HANDLE hDevice)
Start the ADC calibration.
Definition: adi_adc.c:653