CC13xx Driver Library
aux_adc.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: aux_adc.h
3 * Revised: 2015-07-16 12:12:04 +0200 (Thu, 16 Jul 2015)
4 * Revision: 44151
5 *
6 * Description: Defines and prototypes for the AUX Analog-to-Digital
7 * Converter
8 *
9 * Copyright (c) 2015, 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 //
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 <driverlib/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 AUXADCDisableInputScaling NOROM_AUXADCDisableInputScaling
91  #define AUXADCFlushFifo NOROM_AUXADCFlushFifo
92  #define AUXADCReadFifo NOROM_AUXADCReadFifo
93  #define AUXADCPopFifo NOROM_AUXADCPopFifo
94  #define AUXADCGetAdjustmentGain NOROM_AUXADCGetAdjustmentGain
95  #define AUXADCGetAdjustmentOffset NOROM_AUXADCGetAdjustmentOffset
96  #define AUXADCValueToMicrovolts NOROM_AUXADCValueToMicrovolts
97  #define AUXADCMicrovoltsToValue NOROM_AUXADCMicrovoltsToValue
98  #define AUXADCAdjustValueForGainAndOffset NOROM_AUXADCAdjustValueForGainAndOffset
99  #define AUXADCUnadjustValueForGainAndOffset NOROM_AUXADCUnadjustValueForGainAndOffset
100 #endif
101 
102 //*****************************************************************************
103 //
104 // Defines for ADC reference sources.
105 //
106 //*****************************************************************************
107 #define AUXADC_REF_FIXED (0 << ADI_4_AUX_ADCREF0_SRC_S)
108 #define AUXADC_REF_VDDS_REL (1 << ADI_4_AUX_ADCREF0_SRC_S)
109 
110 //*****************************************************************************
111 //
112 // Defines for the ADC FIFO status bits.
113 //
114 //*****************************************************************************
115 #define AUXADC_FIFO_EMPTY_M (AUX_ANAIF_ADCFIFOSTAT_EMPTY_M)
116 #define AUXADC_FIFO_ALMOST_FULL_M (AUX_ANAIF_ADCFIFOSTAT_ALMOST_FULL_M)
117 #define AUXADC_FIFO_FULL_M (AUX_ANAIF_ADCFIFOSTAT_FULL_M)
118 #define AUXADC_FIFO_UNDERFLOW_M (AUX_ANAIF_ADCFIFOSTAT_UNDERFLOW_M)
119 #define AUXADC_FIFO_OVERFLOW_M (AUX_ANAIF_ADCFIFOSTAT_OVERFLOW_M)
120 
121 //*****************************************************************************
122 //
123 // Defines for supported ADC triggers.
124 //
125 //*****************************************************************************
126 #define AUXADC_TRIGGER_MANUAL (EVENT_AUXSEL0_EV_NONE)
127 #define AUXADC_TRIGGER_GPT0A (EVENT_AUXSEL0_EV_GPT0A)
128 #define AUXADC_TRIGGER_GPT0B (EVENT_AUXSEL0_EV_GPT0B)
129 #define AUXADC_TRIGGER_GPT1A (EVENT_AUXSEL0_EV_GPT1A)
130 #define AUXADC_TRIGGER_GPT1B (EVENT_AUXSEL0_EV_GPT1B)
131 #define AUXADC_TRIGGER_GPT2A (EVENT_AUXSEL0_EV_GPT2A)
132 #define AUXADC_TRIGGER_GPT2B (EVENT_AUXSEL0_EV_GPT2B)
133 #define AUXADC_TRIGGER_GPT3A (EVENT_AUXSEL0_EV_GPT3A)
134 #define AUXADC_TRIGGER_GPT3B (EVENT_AUXSEL0_EV_GPT3B)
135 
136 //*****************************************************************************
137 //
138 // Defines for ADC sampling type for synchronous operation.
139 //
140 //*****************************************************************************
141 #define AUXADC_SAMPLE_TIME_2P7_US 3
142 #define AUXADC_SAMPLE_TIME_5P3_US 4
143 #define AUXADC_SAMPLE_TIME_10P6_US 5
144 #define AUXADC_SAMPLE_TIME_21P3_US 6
145 #define AUXADC_SAMPLE_TIME_42P6_US 7
146 #define AUXADC_SAMPLE_TIME_85P3_US 8
147 #define AUXADC_SAMPLE_TIME_170_US 9
148 #define AUXADC_SAMPLE_TIME_341_US 10
149 #define AUXADC_SAMPLE_TIME_682_US 11
150 #define AUXADC_SAMPLE_TIME_1P37_MS 12
151 #define AUXADC_SAMPLE_TIME_2P73_MS 13
152 #define AUXADC_SAMPLE_TIME_5P46_MS 14
153 #define AUXADC_SAMPLE_TIME_10P9_MS 15
154 
155 //*****************************************************************************
156 //
157 // Equivalent voltages for fixed ADC reference, in microvolts.
158 //
159 //*****************************************************************************
160 #define AUXADC_FIXED_REF_VOLTAGE_NORMAL 4300000
161 #define AUXADC_FIXED_REF_VOLTAGE_UNSCALED 1478500
162 
163 
164 //*****************************************************************************
165 //
166 // API Functions and prototypes
167 //
168 //*****************************************************************************
169 
170 
171 //*****************************************************************************
172 //
179 //
180 //*****************************************************************************
181 extern void AUXADCDisable(void);
182 
183 //*****************************************************************************
184 //
212 //
213 //*****************************************************************************
214 extern void AUXADCEnableAsync(uint32_t refSource, uint32_t trigger);
215 
216 //*****************************************************************************
217 //
261 //
262 //*****************************************************************************
263 extern void AUXADCEnableSync(uint32_t refSource, uint32_t sampleTime, uint32_t trigger);
264 
265 //*****************************************************************************
266 //
278 //
279 //*****************************************************************************
280 extern void AUXADCDisableInputScaling(void);
281 
282 //*****************************************************************************
283 //
289 //
290 //*****************************************************************************
291 extern void AUXADCFlushFifo(void);
292 
293 //*****************************************************************************
294 //
299 //
300 //*****************************************************************************
301 __STATIC_INLINE void
303 {
304  HWREG(AUX_ANAIF_BASE + AUX_ANAIF_O_ADCTRIG) = 0;
305 }
306 
307 //*****************************************************************************
308 //
321 //
322 //*****************************************************************************
323 __STATIC_INLINE uint32_t
325 {
326  return HWREG(AUX_ANAIF_BASE + AUX_ANAIF_O_ADCFIFOSTAT);
327 }
328 
329 //*****************************************************************************
330 //
341 //
342 //*****************************************************************************
343 extern uint32_t AUXADCReadFifo(void);
344 
345 //*****************************************************************************
346 //
355 //
356 //*****************************************************************************
357 extern uint32_t AUXADCPopFifo(void);
358 
359 //*****************************************************************************
360 //
378 //
379 //*****************************************************************************
380 __STATIC_INLINE void
381 AUXADCSelectInput(uint32_t input)
382 {
384 }
385 
386 //*****************************************************************************
387 //
402 //
403 //*****************************************************************************
404 extern int32_t AUXADCGetAdjustmentGain(uint32_t refSource);
405 
406 //*****************************************************************************
407 //
423 //
424 //*****************************************************************************
425 extern int32_t AUXADCGetAdjustmentOffset(uint32_t refSource);
426 
427 //*****************************************************************************
428 //
444 //
445 //*****************************************************************************
446 extern int32_t AUXADCValueToMicrovolts(int32_t fixedRefVoltage, int32_t adcValue);
447 
448 //*****************************************************************************
449 //
465 //
466 //*****************************************************************************
467 extern int32_t AUXADCMicrovoltsToValue(int32_t fixedRefVoltage, int32_t microvolts);
468 
469 //*****************************************************************************
470 //
485 //
486 //*****************************************************************************
487 extern int32_t AUXADCAdjustValueForGainAndOffset(int32_t adcValue, int32_t gain, int32_t offset);
488 
489 //*****************************************************************************
490 //
507 //
508 //*****************************************************************************
509 extern int32_t AUXADCUnadjustValueForGainAndOffset(int32_t adcValue, int32_t gain, int32_t offset);
510 
511 //*****************************************************************************
512 //
513 // Support for DriverLib in ROM:
514 // Redirect to implementation in ROM when available.
515 //
516 //*****************************************************************************
517 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
518  #include <driverlib/rom.h>
519  #ifdef ROM_AUXADCDisable
520  #undef AUXADCDisable
521  #define AUXADCDisable ROM_AUXADCDisable
522  #endif
523  #ifdef ROM_AUXADCEnableAsync
524  #undef AUXADCEnableAsync
525  #define AUXADCEnableAsync ROM_AUXADCEnableAsync
526  #endif
527  #ifdef ROM_AUXADCEnableSync
528  #undef AUXADCEnableSync
529  #define AUXADCEnableSync ROM_AUXADCEnableSync
530  #endif
531  #ifdef ROM_AUXADCDisableInputScaling
532  #undef AUXADCDisableInputScaling
533  #define AUXADCDisableInputScaling ROM_AUXADCDisableInputScaling
534  #endif
535  #ifdef ROM_AUXADCFlushFifo
536  #undef AUXADCFlushFifo
537  #define AUXADCFlushFifo ROM_AUXADCFlushFifo
538  #endif
539  #ifdef ROM_AUXADCReadFifo
540  #undef AUXADCReadFifo
541  #define AUXADCReadFifo ROM_AUXADCReadFifo
542  #endif
543  #ifdef ROM_AUXADCPopFifo
544  #undef AUXADCPopFifo
545  #define AUXADCPopFifo ROM_AUXADCPopFifo
546  #endif
547  #ifdef ROM_AUXADCGetAdjustmentGain
548  #undef AUXADCGetAdjustmentGain
549  #define AUXADCGetAdjustmentGain ROM_AUXADCGetAdjustmentGain
550  #endif
551  #ifdef ROM_AUXADCGetAdjustmentOffset
552  #undef AUXADCGetAdjustmentOffset
553  #define AUXADCGetAdjustmentOffset ROM_AUXADCGetAdjustmentOffset
554  #endif
555  #ifdef ROM_AUXADCValueToMicrovolts
556  #undef AUXADCValueToMicrovolts
557  #define AUXADCValueToMicrovolts ROM_AUXADCValueToMicrovolts
558  #endif
559  #ifdef ROM_AUXADCMicrovoltsToValue
560  #undef AUXADCMicrovoltsToValue
561  #define AUXADCMicrovoltsToValue ROM_AUXADCMicrovoltsToValue
562  #endif
563  #ifdef ROM_AUXADCAdjustValueForGainAndOffset
564  #undef AUXADCAdjustValueForGainAndOffset
565  #define AUXADCAdjustValueForGainAndOffset ROM_AUXADCAdjustValueForGainAndOffset
566  #endif
567  #ifdef ROM_AUXADCUnadjustValueForGainAndOffset
568  #undef AUXADCUnadjustValueForGainAndOffset
569  #define AUXADCUnadjustValueForGainAndOffset ROM_AUXADCUnadjustValueForGainAndOffset
570  #endif
571 #endif
572 
573 //*****************************************************************************
574 //
575 // Mark the end of the C bindings section for C++ compilers.
576 //
577 //*****************************************************************************
578 #ifdef __cplusplus
579 }
580 #endif
581 
582 #endif // __AUX_ADC_H__
583 
584 //*****************************************************************************
585 //
589 //
590 //*****************************************************************************
int32_t AUXADCAdjustValueForGainAndOffset(int32_t adcValue, int32_t gain, int32_t offset)
Performs ADC value gain and offset adjustment.
Definition: aux_adc.c:299
int32_t AUXADCGetAdjustmentGain(uint32_t refSource)
Returns the gain value used when adjusting for ADC gain/offset.
Definition: aux_adc.c:234
void AUXADCEnableAsync(uint32_t refSource, uint32_t trigger)
Enables the ADC for asynchronous operation.
Definition: aux_adc.c:111
void AUXADCDisable(void)
Disables the ADC.
Definition: aux_adc.c:87
static void AUXADCGenManualTrigger(void)
Generates a single manual ADC trigger.
Definition: aux_adc.h:302
int32_t AUXADCMicrovoltsToValue(int32_t fixedRefVoltage, int32_t microvolts)
Converts a number of microvolts to corresponding "adjusted" ADC value.
Definition: aux_adc.c:285
static uint32_t AUXADCGetFifoStatus(void)
Returns flags indicating the status of the ADC FIFO.
Definition: aux_adc.h:324
int32_t AUXADCUnadjustValueForGainAndOffset(int32_t adcValue, int32_t gain, int32_t offset)
Performs the inverse of the ADC value gain and offset adjustment.
Definition: aux_adc.c:320
uint32_t AUXADCPopFifo(void)
Returns the first sample in the ADC FIFO, without waiting.
Definition: aux_adc.c:221
#define HapiSelectADCCompBInput(a)
Definition: rom.h:170
void AUXADCEnableSync(uint32_t refSource, uint32_t sampleTime, uint32_t trigger)
Enables the ADC for synchronous operation.
Definition: aux_adc.c:145
void AUXADCDisableInputScaling(void)
Disables scaling of the ADC input.
Definition: aux_adc.c:183
int32_t AUXADCValueToMicrovolts(int32_t fixedRefVoltage, int32_t adcValue)
Converts an "adjusted" ADC value to microvolts.
Definition: aux_adc.c:272
static void AUXADCSelectInput(uint32_t input)
Selects internal or external input for the ADC.
Definition: aux_adc.h:381
int32_t AUXADCGetAdjustmentOffset(uint32_t refSource)
Returns the offset value used when adjusting for ADC gain/offset.
Definition: aux_adc.c:253
void AUXADCFlushFifo(void)
Flushes the ADC FIFO.
Definition: aux_adc.c:194
uint32_t AUXADCReadFifo(void)
Waits for and returns the first sample in the ADC FIFO.
Definition: aux_adc.c:206