ADuCM4x50 Device Drivers API Reference Manual  Release 4.0.0.0
adi_adc.h
1 
13 #ifndef ADI_ADC_H
14 #define ADI_ADC_H
15 
16 #include <adi_processor.h>
17 #include <adi_callback.h>
18 #include <adi_adc_config.h>
19 #include <rtos_map/adi_rtos_map.h> /* for ADI_SEM_SIZE */
20 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
34 #define ADI_ADC_MEMORY_SIZE (48u + ADI_SEM_SIZE)
41 typedef enum {
59 
64 typedef enum {
70 
75 typedef enum {
82 
87 typedef uint32_t ADI_ADC_CHANNEL;
88 
92 #define ADI_ADC_CHANNEL_0 (1u << 0u)
93 #define ADI_ADC_CHANNEL_1 (1u << 1u)
94 #define ADI_ADC_CHANNEL_2 (1u << 2u)
95 #define ADI_ADC_CHANNEL_3 (1u << 3u)
96 #define ADI_ADC_CHANNEL_4 (1u << 4u)
97 #define ADI_ADC_CHANNEL_5 (1u << 5u)
98 #define ADI_ADC_CHANNEL_6 (1u << 6u)
99 #define ADI_ADC_CHANNEL_7 (1u << 7u)
105 typedef enum {
111 } ADI_ADC_EVENT;
112 
114 typedef struct __ADI_ADC_BUFFER {
115  uint32_t nChannels;
116  void* pDataBuffer;
127  uint32_t nBuffSize;
129 
130 /* Type def for the ADC Handle. */
131 typedef struct __ADI_ADC_DEVICE* ADI_ADC_HANDLE;
134 /*============= A P I F U N C T I O N S P R O T O T Y P E S =============*/
135 
136 /* Opens an ADC device instance. */
138  uint32_t nDeviceNum,
139  void* pMemory,
140  uint32_t nMemorySize,
141  ADI_ADC_HANDLE* phDevice
142 );
143 
144 /* Close the given device instance */
146 
147 /* Power up or power down the ADC */
148 ADI_ADC_RESULT adi_adc_PowerUp (ADI_ADC_HANDLE hDevice, bool bPowerUp);
149 
150 /* Register the callback */
152  ADI_ADC_HANDLE hDevice,
153  ADI_CALLBACK pfCallback,
154  void *pCBParam
155 );
156 
157 /* Enables/Disables the ADC Subsystem */
159  ADI_ADC_HANDLE hDevice,
160  bool bEnable
161 );
162 
163 /* Returns whether the ADC subsytem is ready */
165  ADI_ADC_HANDLE hDevice,
166  bool *pbReady
167 );
168 
169 /* Set the voltage reference source */
171  ADI_ADC_HANDLE hDevice,
172  ADI_ADC_VREF_SRC eVrefSrc
173 );
174 
175 /* Enable/Disable current sink */
177  ADI_ADC_HANDLE hDevice,
178  bool bEnable
179 );
180 
181 /* Start the ADC Calibration */
183  ADI_ADC_HANDLE hDevice
184 );
185 
187  ADI_ADC_HANDLE hDevice,
188  bool* pbCalibrationDone
189  );
190 
191 
192 /* Set the acquisition time of ADC in ADC clock cycles */
194  ADI_ADC_HANDLE hDevice,
195  uint32_t nAcqTimeInAClkCycles
196 );
197 
198 /* Set the delay time of ADC in ADC cycles for multi iteration mode */
200  ADI_ADC_HANDLE hDevice,
201  uint32_t nDelayInAClkCycles
202 );
203 
204 /* set the resolution of ADC. The default resolution of ADC is 12-bit and the ADC increases the resolution by oversampling */
206  ADI_ADC_HANDLE hDevice,
207  ADI_ADC_RESOLUTION eResolution
208 );
209 
210 /* Enable Averaging for all ADC channels */
212  ADI_ADC_HANDLE hDevice,
213  uint16_t nAveragingSamples
214 );
215 
216 /* Configure low limit for an ADC channel when it's used as a digital comparator. */
218  ADI_ADC_HANDLE hDevice,
219  ADI_ADC_CHANNEL eChannel,
220  bool bEnable,
221  uint16_t nLowLimit
222 );
223 
224 /* Configure high limit for an ADC channel when it's used as a digital comparator. */
226  ADI_ADC_HANDLE hDevice,
227  ADI_ADC_CHANNEL eChannel,
228  bool bEnable,
229  uint16_t nHighLimit
230 );
231 
232 
233 /* Configure hysteresis for an ADC channel when it's used as a digital comparator. */
235  ADI_ADC_HANDLE hDevice,
236  ADI_ADC_CHANNEL eChannel,
237  bool bEnable,
238  uint16_t nHysteresis
239 );
240 
241 /* Configure number of monitor cycles for an ADC channel when it's used as a digital comparator. */
243  ADI_ADC_HANDLE hDevice,
244  ADI_ADC_CHANNEL eChannel,
245  uint32_t nNumMonitorCycles
246 );
247 
248 /* Enable/Disable digital comparator for the given channel(s) */
250  ADI_ADC_HANDLE hDevice,
251  bool bEnableComparator
252 );
253 
254 /* Submit buffer for sampling */
256  ADI_ADC_HANDLE hDevice,
257  ADI_ADC_BUFFER* pBuffer
258 );
259 
260 /* Get a completed buffer from the driver */
262  ADI_ADC_HANDLE hDevice,
263  ADI_ADC_BUFFER** ppBuffer
264 );
265 
266 /* Enable/Disable buffer processing */
268  ADI_ADC_HANDLE hDevice,
269  bool bEnable
270 );
271 
272 /* Check whether a completed buffer is available in the driver */
274  ADI_ADC_HANDLE hDevice,
275  bool* pbIsBufferAvailable
276 );
277 
278 /* Read the given channels. This will only return once the given amount of samples are collected */
280  ADI_ADC_HANDLE hDevice,
281  uint32_t nChannels,
282  uint32_t nNumConversionPasses,
283  void* pBuffer,
284  uint32_t nBuffLength
285 );
286 
287 /* Get Battery Voltage */
289  ADI_ADC_HANDLE hDevice,
290  uint32_t nRefVoltage,
291  uint32_t* pnBatVoltage
292 );
293 
294 /* Enable/Disable Temperature Sensor */
296  ADI_ADC_HANDLE hDevice,
297  bool bEnable
298  );
299 
300 /* Get the Temperature Value */
302  ADI_ADC_HANDLE hDevice,
303  uint32_t nRefVoltage,
304  int32_t* pnTemperature
305  );
306 
307 /* Enable/Disable Interrupts */
309  ADI_ADC_HANDLE hDevice,
310  bool bEnable
311 );
312 
313 #ifdef __cplusplus
314 }
315 #endif
316 
320 #endif /* ADI_ADC_H */
ADI_ADC_RESULT adi_adc_Close(ADI_ADC_HANDLE hDevice)
Close the given device instance.
Definition: adi_adc.c:224
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:938
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:670
ADI_ADC_RESULT adi_adc_EnableIRQ(ADI_ADC_HANDLE hDevice, bool bEnable)
Enable/Disable ADC Interrupts.
Definition: adi_adc.c:1536
ADI_ADC_RESULT adi_adc_EnableTemperatureSensor(ADI_ADC_HANDLE hDevice, bool bEnable)
Enable or disable the temperature sensor.
Definition: adi_adc.c:1678
ADI_ADC_RESULT adi_adc_EnableAveraging(ADI_ADC_HANDLE hDevice, uint16_t nAveragingSamples)
Enable Averaging for all ADC channels.
Definition: adi_adc.c:880
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.
Definition: adi_adc.c:1054
uint32_t ADI_ADC_CHANNEL
Definition: adi_adc.h:87
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:1448
ADI_ADC_RESULT adi_adc_SinkEnable(ADI_ADC_HANDLE hDevice, bool bEnable)
Enable/Disable Current Sink.
Definition: adi_adc.c:583
uint32_t nBuffSize
Definition: adi_adc.h:127
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:148
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:770
ADI_ADC_RESULT adi_adc_EnableADCSubSystem(ADI_ADC_HANDLE hDevice, bool bEnable)
Enable/Disables the ADC Subsystem.
Definition: adi_adc.c:407
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.
Definition: adi_adc.c:1109
ADI_ADC_EVENT
Definition: adi_adc.h:105
ADI_ADC_VREF_SRC
Definition: adi_adc.h:64
ADI_ADC_RESULT adi_adc_PowerUp(ADI_ADC_HANDLE hDevice, bool bPowerUp)
Power up ADC.
Definition: adi_adc.c:278
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:1279
ADI_ADC_RESULT adi_adc_GetBatteryVoltage(ADI_ADC_HANDLE hDevice, uint32_t nRefVoltage, uint32_t *pnBatVoltage)
Returns the battery voltage.
Definition: adi_adc.c:1585
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.
Definition: adi_adc.c:997
void * pDataBuffer
Definition: adi_adc.h:116
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....
Definition: adi_adc.c:1388
uint32_t nNumConversionPasses
Definition: adi_adc.h:126
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:722
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:812
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:1216
ADI_ADC_RESULT adi_adc_Enable(ADI_ADC_HANDLE hDevice, bool bEnable)
Enable/Disable ADC for sampling.
Definition: adi_adc.c:1333
ADI_ADC_RESULT adi_adc_IsReady(ADI_ADC_HANDLE hDevice, bool *pbReady)
Returns whether the ADC Subsystem is ready.
Definition: adi_adc.c:469
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:1729
uint32_t nChannels
Definition: adi_adc.h:115
struct __ADI_ADC_DEVICE * ADI_ADC_HANDLE
Definition: adi_adc.h:131
ADI_ADC_RESULT adi_adc_RegisterCallback(ADI_ADC_HANDLE hDevice, ADI_CALLBACK pfCallback, void *pCBParam)
Registering a callback function.
Definition: adi_adc.c:358
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:1161
ADI_ADC_RESULT
Definition: adi_adc.h:41
ADI_ADC_RESULT adi_adc_SetVrefSource(ADI_ADC_HANDLE hDevice, ADI_ADC_VREF_SRC eVrefSrc)
Set the Voltage Reference source.
Definition: adi_adc.c:521
ADI_ADC_RESOLUTION
Definition: adi_adc.h:75
ADI_ADC_RESULT adi_adc_StartCalibration(ADI_ADC_HANDLE hDevice)
Start the ADC calibration.
Definition: adi_adc.c:622