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