1 /******************************************************************************
2 *  Filename:       aux_adc.h
3 *  Revised:        2020-10-02 17:15:55 +0200 (Fri, 02 Oct 2020)
4 *  Revision:       58927
5 *
6 *  Description:    Defines and prototypes for the AUX Analog-to-Digital
7 *                  Converter
8 *
9 *  Copyright (c) 2015 - 2020, Texas Instruments Incorporated
10 *  All rights reserved.
11 *
12 *  Redistribution and use in source and binary forms, with or without
13 *  modification, are permitted provided that the following conditions are met:
14 *
15 *  1) Redistributions of source code must retain the above copyright notice,
16 *     this list of conditions and the following disclaimer.
17 *
18 *  2) Redistributions in binary form must reproduce the above copyright notice,
19 *     this list of conditions and the following disclaimer in the documentation
20 *     and/or other materials provided with the distribution.
21 *
22 *  3) Neither the name of the ORGANIZATION nor the names of its contributors may
23 *     be used to endorse or promote products derived from this software without
24 *     specific prior written permission.
25 *
26 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
30 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 *  POSSIBILITY OF SUCH DAMAGE.
37 *
38 ******************************************************************************/
39 
40 //*****************************************************************************
41 //
42 //! \addtogroup aux_group
43 //! @{
44 //! \addtogroup auxadc_api
45 //! @{
46 //
47 //*****************************************************************************
48 
49 #ifndef __AUX_ADC_H__
50 #define __AUX_ADC_H__
51 
52 //*****************************************************************************
53 //
54 // If building with a C++ compiler, make all of the definitions in this header
55 // have a C binding.
56 //
57 //*****************************************************************************
58 #ifdef __cplusplus
59 extern "C"
60 {
61 #endif
62 
63 #include <stdbool.h>
64 #include <stdint.h>
65 #include "../inc/hw_types.h"
66 #include "../inc/hw_memmap.h"
67 #include "../inc/hw_event.h"
68 #include "../inc/hw_adi.h"
69 #include "../inc/hw_adi_4_aux.h"
70 #include "../inc/hw_aux_anaif.h"
71 #include "rom.h"
72 
73 //*****************************************************************************
74 //
75 // Support for DriverLib in ROM:
76 // This section renames all functions that are not "static inline", so that
77 // calling these functions will default to implementation in flash. At the end
78 // of this file a second renaming will change the defaults to implementation in
79 // ROM for available functions.
80 //
81 // To force use of the implementation in flash, e.g. for debugging:
82 // - Globally: Define DRIVERLIB_NOROM at project level
83 // - Per function: Use prefix "NOROM_" when calling the function
84 //
85 //*****************************************************************************
86 #if !defined(DOXYGEN)
87     #define AUXADCDisable                   NOROM_AUXADCDisable
88     #define AUXADCEnableAsync               NOROM_AUXADCEnableAsync
89     #define AUXADCEnableSync                NOROM_AUXADCEnableSync
90     #define AUXADCEnableSyncNoBugWorkaround NOROM_AUXADCEnableSyncNoBugWorkaround
91     #define AUXADCDisableInputScaling       NOROM_AUXADCDisableInputScaling
92     #define AUXADCFlushFifo                 NOROM_AUXADCFlushFifo
93     #define AUXADCReadFifo                  NOROM_AUXADCReadFifo
94     #define AUXADCPopFifo                   NOROM_AUXADCPopFifo
95     #define AUXADCGetAdjustmentGain         NOROM_AUXADCGetAdjustmentGain
96     #define AUXADCGetAdjustmentOffset       NOROM_AUXADCGetAdjustmentOffset
97     #define AUXADCValueToMicrovolts         NOROM_AUXADCValueToMicrovolts
98     #define AUXADCMicrovoltsToValue         NOROM_AUXADCMicrovoltsToValue
99     #define AUXADCAdjustValueForGainAndOffset NOROM_AUXADCAdjustValueForGainAndOffset
100     #define AUXADCUnadjustValueForGainAndOffset NOROM_AUXADCUnadjustValueForGainAndOffset
101 #endif
102 
103 //*****************************************************************************
104 //
105 // Defines for ADC reference sources.
106 //
107 //*****************************************************************************
108 #define AUXADC_REF_FIXED                    (0 << ADI_4_AUX_ADCREF0_SRC_S)
109 #define AUXADC_REF_VDDS_REL                 (1 << ADI_4_AUX_ADCREF0_SRC_S)
110 
111 //*****************************************************************************
112 //
113 // Defines for the ADC FIFO status bits.
114 //
115 //*****************************************************************************
116 #define AUXADC_FIFO_EMPTY_M                 (AUX_ANAIF_ADCFIFOSTAT_EMPTY_M)
117 #define AUXADC_FIFO_ALMOST_FULL_M           (AUX_ANAIF_ADCFIFOSTAT_ALMOST_FULL_M)
118 #define AUXADC_FIFO_FULL_M                  (AUX_ANAIF_ADCFIFOSTAT_FULL_M)
119 #define AUXADC_FIFO_UNDERFLOW_M             (AUX_ANAIF_ADCFIFOSTAT_UNDERFLOW_M)
120 #define AUXADC_FIFO_OVERFLOW_M              (AUX_ANAIF_ADCFIFOSTAT_OVERFLOW_M)
121 
122 //*****************************************************************************
123 //
124 // Defines for supported ADC triggers.
125 //
126 //*****************************************************************************
127 #define AUXADC_TRIGGER_MANUAL               (EVENT_AUXSEL0_EV_NONE)
128 #define AUXADC_TRIGGER_GPT0A                (EVENT_AUXSEL0_EV_GPT0A)
129 #define AUXADC_TRIGGER_GPT0B                (EVENT_AUXSEL0_EV_GPT0B)
130 #define AUXADC_TRIGGER_GPT1A                (EVENT_AUXSEL0_EV_GPT1A)
131 #define AUXADC_TRIGGER_GPT1B                (EVENT_AUXSEL0_EV_GPT1B)
132 #define AUXADC_TRIGGER_GPT2A                (EVENT_AUXSEL0_EV_GPT2A)
133 #define AUXADC_TRIGGER_GPT2B                (EVENT_AUXSEL0_EV_GPT2B)
134 #define AUXADC_TRIGGER_GPT3A                (EVENT_AUXSEL0_EV_GPT3A)
135 #define AUXADC_TRIGGER_GPT3B                (EVENT_AUXSEL0_EV_GPT3B)
136 #define AUXADC_TRIGGER_GPT0A_CMP            (EVENT_AUXSEL0_EV_GPT0A_CMP)
137 #define AUXADC_TRIGGER_GPT0B_CMP            (EVENT_AUXSEL0_EV_GPT0B_CMP)
138 #define AUXADC_TRIGGER_GPT1A_CMP            (EVENT_AUXSEL0_EV_GPT1A_CMP)
139 #define AUXADC_TRIGGER_GPT1B_CMP            (EVENT_AUXSEL0_EV_GPT1B_CMP)
140 #define AUXADC_TRIGGER_GPT2A_CMP            (EVENT_AUXSEL0_EV_GPT2A_CMP)
141 #define AUXADC_TRIGGER_GPT2B_CMP            (EVENT_AUXSEL0_EV_GPT2B_CMP)
142 #define AUXADC_TRIGGER_GPT3A_CMP            (EVENT_AUXSEL0_EV_GPT3A_CMP)
143 #define AUXADC_TRIGGER_GPT3B_CMP            (EVENT_AUXSEL0_EV_GPT3B_CMP)
144 
145 //*****************************************************************************
146 //
147 // Defines for ADC sampling type for synchronous operation.
148 //
149 //*****************************************************************************
150 #define AUXADC_SAMPLE_TIME_2P7_US           3
151 #define AUXADC_SAMPLE_TIME_5P3_US           4
152 #define AUXADC_SAMPLE_TIME_10P6_US          5
153 #define AUXADC_SAMPLE_TIME_21P3_US          6
154 #define AUXADC_SAMPLE_TIME_42P6_US          7
155 #define AUXADC_SAMPLE_TIME_85P3_US          8
156 #define AUXADC_SAMPLE_TIME_170_US           9
157 #define AUXADC_SAMPLE_TIME_341_US           10
158 #define AUXADC_SAMPLE_TIME_682_US           11
159 #define AUXADC_SAMPLE_TIME_1P37_MS          12
160 #define AUXADC_SAMPLE_TIME_2P73_MS          13
161 #define AUXADC_SAMPLE_TIME_5P46_MS          14
162 #define AUXADC_SAMPLE_TIME_10P9_MS          15
163 
164 //*****************************************************************************
165 //
166 // Equivalent voltages for fixed ADC reference, in microvolts.
167 //
168 //*****************************************************************************
169 #define AUXADC_FIXED_REF_VOLTAGE_NORMAL     4300000
170 #define AUXADC_FIXED_REF_VOLTAGE_UNSCALED   1478500
171 
172 
173 //*****************************************************************************
174 //
175 // API Functions and prototypes
176 //
177 //*****************************************************************************
178 
179 
180 //*****************************************************************************
181 //
182 //! \brief Disables the ADC.
183 //!
184 //! This function must be called:
185 //! - Before re-enabling the ADC using \ref AUXADCEnableAsync() or
186 //!   \ref AUXADCEnableSync()
187 //! - Before entering system standby
188 //
189 //*****************************************************************************
190 extern void AUXADCDisable(void);
191 
192 //*****************************************************************************
193 //
194 //! \brief Enables the ADC for asynchronous operation.
195 //!
196 //! In asynchronous operation, the ADC samples continuously between
197 //! conversions.
198 //!
199 //! The ADC trigger starts the conversion. Note that the first conversion may
200 //! be invalid if the sampling period is too short.
201 //!
202 //! ADC input scaling is enabled by default after device reset, and is also re-
203 //! enabled by \ref AUXADCDisable(). To disable input scaling, call
204 //! \ref AUXADCDisableInputScaling() before calling \ref AUXADCEnableAsync().
205 //!
206 //! \param refSource
207 //!     ADC reference source:
208 //!     - \ref AUXADC_REF_FIXED (nominally 4.3 V)
209 //!     - \ref AUXADC_REF_VDDS_REL (nominally VDDS)
210 //! \param trigger
211 //!     ADC conversion trigger:
212 //!     - \ref AUXADC_TRIGGER_MANUAL
213 //!     - \ref AUXADC_TRIGGER_GPT0A
214 //!     - \ref AUXADC_TRIGGER_GPT0B
215 //!     - \ref AUXADC_TRIGGER_GPT1A
216 //!     - \ref AUXADC_TRIGGER_GPT1B
217 //!     - \ref AUXADC_TRIGGER_GPT2A
218 //!     - \ref AUXADC_TRIGGER_GPT2B
219 //!     - \ref AUXADC_TRIGGER_GPT3A
220 //!     - \ref AUXADC_TRIGGER_GPT3B
221 //
222 //*****************************************************************************
223 extern void AUXADCEnableAsync(uint32_t refSource, uint32_t trigger);
224 
225 //*****************************************************************************
226 //
227 //! \brief Enables the ADC for synchronous operation.
228 //!
229 //! In synchronous operation, the ADC is idle between a conversion and
230 //! subsequent samplings.
231 //!
232 //! The ADC trigger starts sampling with specified duration, followed by the
233 //! conversion. Note that the first conversion may be invalid if the initial
234 //! sampling period is too short.
235 //!
236 //! ADC input scaling is enabled by default after device reset, and is also re-
237 //! enabled by \ref AUXADCDisable(). To disable input scaling, call
238 //! \ref AUXADCDisableInputScaling() before calling \ref AUXADCEnableSync().
239 //!
240 //! \param refSource
241 //!     ADC reference source:
242 //!     - \ref AUXADC_REF_FIXED (nominally 4.3 V)
243 //!     - \ref AUXADC_REF_VDDS_REL (nominally VDDS)
244 //! \param sampleTime
245 //!     ADC sampling time:
246 //!     - \ref AUXADC_SAMPLE_TIME_2P7_US
247 //!     - \ref AUXADC_SAMPLE_TIME_5P3_US
248 //!     - \ref AUXADC_SAMPLE_TIME_10P6_US
249 //!     - \ref AUXADC_SAMPLE_TIME_21P3_US
250 //!     - \ref AUXADC_SAMPLE_TIME_42P6_US
251 //!     - \ref AUXADC_SAMPLE_TIME_85P3_US
252 //!     - \ref AUXADC_SAMPLE_TIME_170_US
253 //!     - \ref AUXADC_SAMPLE_TIME_341_US
254 //!     - \ref AUXADC_SAMPLE_TIME_682_US
255 //!     - \ref AUXADC_SAMPLE_TIME_1P37_MS
256 //!     - \ref AUXADC_SAMPLE_TIME_2P73_MS
257 //!     - \ref AUXADC_SAMPLE_TIME_5P46_MS
258 //!     - \ref AUXADC_SAMPLE_TIME_10P9_MS
259 //! \param trigger
260 //!     ADC conversion trigger:
261 //!     - \ref AUXADC_TRIGGER_MANUAL
262 //!     - \ref AUXADC_TRIGGER_GPT0A
263 //!     - \ref AUXADC_TRIGGER_GPT0B
264 //!     - \ref AUXADC_TRIGGER_GPT1A
265 //!     - \ref AUXADC_TRIGGER_GPT1B
266 //!     - \ref AUXADC_TRIGGER_GPT2A
267 //!     - \ref AUXADC_TRIGGER_GPT2B
268 //!     - \ref AUXADC_TRIGGER_GPT3A
269 //!     - \ref AUXADC_TRIGGER_GPT3B
270 //
271 //*****************************************************************************
272 extern void AUXADCEnableSync(uint32_t refSource, uint32_t sampleTime, uint32_t trigger);
273 
274 //*****************************************************************************
275 //
276 //! The device can hang if we generate a manual ADC trigger
277 //! immediately after enabling the ADC with this function and the Sensor
278 //! Controller turns on or off the XOSC_HF as a reference for the TDC at the
279 //! same time.
280 //!
281 //! An application should be calling AUXADCEnableSync() instead.
282 //!
283 //! \brief Enables the ADC for synchronous operation.
284 //!
285 //! In synchronous operation, the ADC is idle between a conversion and
286 //! subsequent samplings.
287 //!
288 //! The ADC trigger starts sampling with specified duration, followed by the
289 //! conversion. Note that the first conversion may be invalid if the initial
290 //! sampling period is too short.
291 //!
292 //! ADC input scaling is enabled by default after device reset, and is also re-
293 //! enabled by \ref AUXADCDisable(). To disable input scaling, call
294 //! \ref AUXADCDisableInputScaling() before calling \ref AUXADCEnableSync().
295 //!
296 //!
297 //! \param refSource
298 //!     ADC reference source:
299 //!     - \ref AUXADC_REF_FIXED (nominally 4.3 V)
300 //!     - \ref AUXADC_REF_VDDS_REL (nominally VDDS)
301 //! \param sampleTime
302 //!     ADC sampling time:
303 //!     - \ref AUXADC_SAMPLE_TIME_2P7_US
304 //!     - \ref AUXADC_SAMPLE_TIME_5P3_US
305 //!     - \ref AUXADC_SAMPLE_TIME_10P6_US
306 //!     - \ref AUXADC_SAMPLE_TIME_21P3_US
307 //!     - \ref AUXADC_SAMPLE_TIME_42P6_US
308 //!     - \ref AUXADC_SAMPLE_TIME_85P3_US
309 //!     - \ref AUXADC_SAMPLE_TIME_170_US
310 //!     - \ref AUXADC_SAMPLE_TIME_341_US
311 //!     - \ref AUXADC_SAMPLE_TIME_682_US
312 //!     - \ref AUXADC_SAMPLE_TIME_1P37_MS
313 //!     - \ref AUXADC_SAMPLE_TIME_2P73_MS
314 //!     - \ref AUXADC_SAMPLE_TIME_5P46_MS
315 //!     - \ref AUXADC_SAMPLE_TIME_10P9_MS
316 //! \param trigger
317 //!     ADC conversion trigger:
318 //!     - \ref AUXADC_TRIGGER_MANUAL
319 //!     - \ref AUXADC_TRIGGER_GPT0A
320 //!     - \ref AUXADC_TRIGGER_GPT0B
321 //!     - \ref AUXADC_TRIGGER_GPT1A
322 //!     - \ref AUXADC_TRIGGER_GPT1B
323 //!     - \ref AUXADC_TRIGGER_GPT2A
324 //!     - \ref AUXADC_TRIGGER_GPT2B
325 //!     - \ref AUXADC_TRIGGER_GPT3A
326 //!     - \ref AUXADC_TRIGGER_GPT3B
327 //
328 //*****************************************************************************
329 extern void AUXADCEnableSyncNoBugWorkaround(uint32_t refSource, uint32_t sampleTime, uint32_t trigger);
330 
331 //*****************************************************************************
332 //
333 //! \brief Disables scaling of the ADC input.
334 //!
335 //! By default, the ADC operates internally on a version of the input signal
336 //! that has been scaled down by a factor <tt>1408 / 4095</tt>. This function
337 //! disables that scaling, allowing for a trade-off between dynamic range and
338 //! and resolution.
339 //!
340 //! \note This function must only be called while the ADC is disabled, before
341 //!       calling \ref AUXADCEnableSync() or \ref AUXADCEnableAsync().
342 //! \note Different input maximum ratings apply when input scaling is disabled.
343 //!       Violating these may damage the device.
344 //
345 //*****************************************************************************
346 extern void AUXADCDisableInputScaling(void);
347 
348 //*****************************************************************************
349 //
350 //! \brief Flushes the ADC FIFO.
351 //!
352 //! This empties the FIFO and clears the underflow/overflow flags.
353 //!
354 //! Note: This function must only be called while the ADC is enabled.
355 //
356 //*****************************************************************************
357 extern void AUXADCFlushFifo(void);
358 
359 //*****************************************************************************
360 //
361 //! \brief Generates a single manual ADC trigger.
362 //!
363 //! For synchronous mode, the trigger starts sampling followed by conversion.
364 //! For asynchronous mode, the trigger starts conversion.
365 //
366 //*****************************************************************************
367 __STATIC_INLINE void
AUXADCGenManualTrigger(void)368 AUXADCGenManualTrigger(void)
369 {
370     HWREG(AUX_ANAIF_BASE + AUX_ANAIF_O_ADCTRIG) = 0;
371 }
372 
373 //*****************************************************************************
374 //
375 //! \brief Returns flags indicating the status of the ADC FIFO.
376 //!
377 //! The flags indicate FIFO empty, full and almost full, and whether
378 //! overflow/underflow has occurred.
379 //!
380 //! \return
381 //!     A combination (bitwise OR) of the following flags:
382 //!     - \ref AUXADC_FIFO_EMPTY_M
383 //!     - \ref AUXADC_FIFO_ALMOST_FULL_M
384 //!     - \ref AUXADC_FIFO_FULL_M
385 //!     - \ref AUXADC_FIFO_UNDERFLOW_M
386 //!     - \ref AUXADC_FIFO_OVERFLOW_M
387 //
388 //*****************************************************************************
389 __STATIC_INLINE uint32_t
AUXADCGetFifoStatus(void)390 AUXADCGetFifoStatus(void)
391 {
392     return HWREG(AUX_ANAIF_BASE + AUX_ANAIF_O_ADCFIFOSTAT);
393 }
394 
395 //*****************************************************************************
396 //
397 //! \brief Waits for and returns the first sample in the ADC FIFO.
398 //!
399 //! This function waits until there is at least one sample in the ADC FIFO. It
400 //! then pops and returns the first sample from the FIFO.
401 //!
402 //! \note This procedure will deadlock if called without setting up ADC trigger
403 //!       generation in advance. The trigger can either be manual or periodical
404 //!       (using a GPT).
405 //!
406 //! \return The first (12-bit) sample from the ADC FIFO
407 //
408 //*****************************************************************************
409 extern uint32_t AUXADCReadFifo(void);
410 
411 //*****************************************************************************
412 //
413 //! \brief Returns the first sample in the ADC FIFO, without waiting.
414 //!
415 //! This function does not wait, and must only be called when there is at least
416 //! one sample in the ADC FIFO. Otherwise the call will generate FIFO underflow
417 //! (\ref AUXADC_FIFO_UNDERFLOW_M).
418 //!
419 //! \return The first (12-bit) sample from the ADC FIFO, or an undefined value
420 //!         if the FIFO is empty
421 //
422 //*****************************************************************************
423 extern uint32_t AUXADCPopFifo(void);
424 
425 //*****************************************************************************
426 //
427 //! \brief Selects internal or external input for the ADC.
428 //!
429 //! Note that calling this function also selects the same input for AUX_COMPB.
430 //!
431 //! \param input
432 //!     Internal/external input selection:
433 //!     - \ref ADC_COMPB_IN_DCOUPL
434 //!     - \ref ADC_COMPB_IN_VSS
435 //!     - \ref ADC_COMPB_IN_VDDS
436 //!     - \ref ADC_COMPB_IN_AUXIO7
437 //!     - \ref ADC_COMPB_IN_AUXIO6
438 //!     - \ref ADC_COMPB_IN_AUXIO5
439 //!     - \ref ADC_COMPB_IN_AUXIO4
440 //!     - \ref ADC_COMPB_IN_AUXIO3
441 //!     - \ref ADC_COMPB_IN_AUXIO2
442 //!     - \ref ADC_COMPB_IN_AUXIO1
443 //!     - \ref ADC_COMPB_IN_AUXIO0
444 //
445 //*****************************************************************************
446 __STATIC_INLINE void
AUXADCSelectInput(uint32_t input)447 AUXADCSelectInput(uint32_t input)
448 {
449     HapiSelectADCCompBInput(input);
450 }
451 
452 //*****************************************************************************
453 //
454 //! \brief Returns the gain value used when adjusting for ADC gain/offset.
455 //!
456 //! The function returns the gain value to be used with
457 //! \ref AUXADCAdjustValueForGainAndOffset() or
458 //! \ref AUXADCUnadjustValueForGainAndOffset(). The gain value is found during
459 //! chip manufacturing and is stored in the factory configuration, FCFG1.
460 //!
461 //! \param refSource
462 //!     ADC reference source:
463 //!     - \ref AUXADC_REF_FIXED (nominally 4.3 V)
464 //!     - \ref AUXADC_REF_VDDS_REL (nominally VDDS)
465 //!
466 //! \return
467 //!     The gain value to be used in adjustments
468 //
469 //*****************************************************************************
470 extern int32_t AUXADCGetAdjustmentGain(uint32_t refSource);
471 
472 //*****************************************************************************
473 //
474 //! \brief Returns the offset value used when adjusting for ADC gain/offset.
475 //!
476 //! The function returns the offset value to be used with
477 //! \ref AUXADCAdjustValueForGainAndOffset() or
478 //! \ref AUXADCUnadjustValueForGainAndOffset(). The offset value is found
479 //! during chip manufacturing and is stored in the factory configuration,
480 //! FCFG1.
481 //!
482 //! \param refSource
483 //!     ADC reference source:
484 //!     - \ref AUXADC_REF_FIXED (nominally 4.3 V)
485 //!     - \ref AUXADC_REF_VDDS_REL (nominally VDDS)
486 //!
487 //! \return
488 //!     The offset value to be used in adjustments
489 //
490 //*****************************************************************************
491 extern int32_t AUXADCGetAdjustmentOffset(uint32_t refSource);
492 
493 //*****************************************************************************
494 //
495 //! \brief Converts an "adjusted" ADC value to microvolts.
496 //!
497 //! This function can only be used when measuring with fixed ADC reference
498 //! (\ref AUXADC_REF_FIXED). The specified reference voltage accounts for
499 //! whether the sampled ADC input is scaled down before conversion or not.
500 //!
501 //! \param fixedRefVoltage
502 //!     Fixed reference voltage, in microvolts
503 //!     - \ref AUXADC_FIXED_REF_VOLTAGE_NORMAL when using scaled input (normal)
504 //!     - \ref AUXADC_FIXED_REF_VOLTAGE_UNSCALED when using unscaled input
505 //! \param adcValue
506 //!     The ADC value
507 //!
508 //! \return
509 //!     The corresponding number of microvolts
510 //
511 //*****************************************************************************
512 extern int32_t AUXADCValueToMicrovolts(int32_t fixedRefVoltage, int32_t adcValue);
513 
514 //*****************************************************************************
515 //
516 //! \brief Converts a number of microvolts to corresponding "adjusted" ADC value.
517 //!
518 //! This function can only be used when measuring with fixed ADC reference
519 //! (\ref AUXADC_REF_FIXED). The specified reference voltage accounts for
520 //! whether the sampled ADC input is scaled down before conversion or not.
521 //!
522 //! \param fixedRefVoltage
523 //!     Fixed reference voltage, in microvolts
524 //!     - \ref AUXADC_FIXED_REF_VOLTAGE_NORMAL when using scaled input (normal)
525 //!     - \ref AUXADC_FIXED_REF_VOLTAGE_UNSCALED when using unscaled input
526 //! \param microvolts
527 //!     The number of microvolts
528 //!
529 //! \return
530 //!     The corresponding expected ADC value (adjusted for ADC gain/offset)
531 //
532 //*****************************************************************************
533 extern int32_t AUXADCMicrovoltsToValue(int32_t fixedRefVoltage, int32_t microvolts);
534 
535 //*****************************************************************************
536 //
537 //! \brief Performs ADC value gain and offset adjustment.
538 //!
539 //! This function takes a measured ADC value compensates for the internal gain
540 //! and offset in the ADC.
541 //!
542 //! \param adcValue
543 //!     12-bit ADC unadjusted value
544 //! \param gain
545 //!     Gain adjustment value provided by \ref AUXADCGetAdjustmentGain()
546 //! \param offset
547 //!     Offset adjustment value provided by \ref AUXADCGetAdjustmentOffset()
548 //!
549 //! \return
550 //!     12-bit ADC adjusted value
551 //
552 //*****************************************************************************
553 extern int32_t AUXADCAdjustValueForGainAndOffset(int32_t adcValue, int32_t gain, int32_t offset);
554 
555 //*****************************************************************************
556 //
557 //! \brief Performs the inverse of the ADC value gain and offset adjustment.
558 //!
559 //! This function finds the expected measured ADC value, without gain and
560 //! offset compensation, for a given "ideal" ADC value. The function can for
561 //! example be used to find ADC value thresholds to be used in Sensor
562 //! Controller task configurations.
563 //!
564 //! \param adcValue
565 //!     12-bit ADC adjusted value
566 //! \param gain
567 //!     Gain adjustment value provided by \ref AUXADCGetAdjustmentGain()
568 //! \param offset
569 //!     Offset adjustment value provided by \ref AUXADCGetAdjustmentOffset()
570 //!
571 //! \return
572 //!     12-bit ADC unadjusted value
573 //
574 //*****************************************************************************
575 extern int32_t AUXADCUnadjustValueForGainAndOffset(int32_t adcValue, int32_t gain, int32_t offset);
576 
577 //*****************************************************************************
578 //
579 // Support for DriverLib in ROM:
580 // Redirect to implementation in ROM when available.
581 //
582 //*****************************************************************************
583 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
584     #include "../driverlib/rom.h"
585     #ifdef ROM_AUXADCDisable
586         #undef  AUXADCDisable
587         #define AUXADCDisable                   ROM_AUXADCDisable
588     #endif
589     #ifdef ROM_AUXADCEnableAsync
590         #undef  AUXADCEnableAsync
591         #define AUXADCEnableAsync               ROM_AUXADCEnableAsync
592     #endif
593     #ifdef ROM_AUXADCEnableSync
594         #undef  AUXADCEnableSync
595         #define AUXADCEnableSync                ROM_AUXADCEnableSync
596     #endif
597     #ifdef ROM_AUXADCEnableSyncNoBugWorkaround
598         #undef  AUXADCEnableSyncNoBugWorkaround
599         #define AUXADCEnableSyncNoBugWorkaround ROM_AUXADCEnableSyncNoBugWorkaround
600     #endif
601     #ifdef ROM_AUXADCDisableInputScaling
602         #undef  AUXADCDisableInputScaling
603         #define AUXADCDisableInputScaling       ROM_AUXADCDisableInputScaling
604     #endif
605     #ifdef ROM_AUXADCFlushFifo
606         #undef  AUXADCFlushFifo
607         #define AUXADCFlushFifo                 ROM_AUXADCFlushFifo
608     #endif
609     #ifdef ROM_AUXADCReadFifo
610         #undef  AUXADCReadFifo
611         #define AUXADCReadFifo                  ROM_AUXADCReadFifo
612     #endif
613     #ifdef ROM_AUXADCPopFifo
614         #undef  AUXADCPopFifo
615         #define AUXADCPopFifo                   ROM_AUXADCPopFifo
616     #endif
617     #ifdef ROM_AUXADCGetAdjustmentGain
618         #undef  AUXADCGetAdjustmentGain
619         #define AUXADCGetAdjustmentGain         ROM_AUXADCGetAdjustmentGain
620     #endif
621     #ifdef ROM_AUXADCGetAdjustmentOffset
622         #undef  AUXADCGetAdjustmentOffset
623         #define AUXADCGetAdjustmentOffset       ROM_AUXADCGetAdjustmentOffset
624     #endif
625     #ifdef ROM_AUXADCValueToMicrovolts
626         #undef  AUXADCValueToMicrovolts
627         #define AUXADCValueToMicrovolts         ROM_AUXADCValueToMicrovolts
628     #endif
629     #ifdef ROM_AUXADCMicrovoltsToValue
630         #undef  AUXADCMicrovoltsToValue
631         #define AUXADCMicrovoltsToValue         ROM_AUXADCMicrovoltsToValue
632     #endif
633     #ifdef ROM_AUXADCAdjustValueForGainAndOffset
634         #undef  AUXADCAdjustValueForGainAndOffset
635         #define AUXADCAdjustValueForGainAndOffset ROM_AUXADCAdjustValueForGainAndOffset
636     #endif
637     #ifdef ROM_AUXADCUnadjustValueForGainAndOffset
638         #undef  AUXADCUnadjustValueForGainAndOffset
639         #define AUXADCUnadjustValueForGainAndOffset ROM_AUXADCUnadjustValueForGainAndOffset
640     #endif
641 #endif
642 
643 //*****************************************************************************
644 //
645 // Mark the end of the C bindings section for C++ compilers.
646 //
647 //*****************************************************************************
648 #ifdef __cplusplus
649 }
650 #endif
651 
652 #endif // __AUX_ADC_H__
653 
654 //*****************************************************************************
655 //
656 //! Close the Doxygen group.
657 //! @}
658 //! @}
659 //
660 //*****************************************************************************
661