1 //*****************************************************************************
2 //
3 // adc.h - ADC headers for using the ADC driver functions.
4 //
5 // Copyright (c) 2005-2011 Texas Instruments Incorporated.  All rights reserved.
6 // Software License Agreement
7 //
8 // Texas Instruments (TI) is supplying this software for use solely and
9 // exclusively on TI's microcontroller products. The software is owned by
10 // TI and/or its suppliers, and is protected under applicable copyright
11 // laws. You may not combine this software with "viral" open-source
12 // software in order to form a larger program.
13 //
14 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
15 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
16 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
18 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
19 // DAMAGES, FOR ANY REASON WHATSOEVER.
20 //
21 // This is part of revision 8264 of the Stellaris Peripheral Driver Library.
22 //
23 //*****************************************************************************
24 
25 #ifndef __ADC_H__
26 #define __ADC_H__
27 
28 //*****************************************************************************
29 //
30 // If building with a C++ compiler, make all of the definitions in this header
31 // have a C binding.
32 //
33 //*****************************************************************************
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38 
39 //*****************************************************************************
40 //
41 // Values that can be passed to ADCSequenceConfigure as the ulTrigger
42 // parameter.
43 //
44 //*****************************************************************************
45 #define ADC_TRIGGER_PROCESSOR   0x00000000  // Processor event
46 #define ADC_TRIGGER_COMP0       0x00000001  // Analog comparator 0 event
47 #define ADC_TRIGGER_COMP1       0x00000002  // Analog comparator 1 event
48 #define ADC_TRIGGER_COMP2       0x00000003  // Analog comparator 2 event
49 #define ADC_TRIGGER_EXTERNAL    0x00000004  // External event
50 #define ADC_TRIGGER_TIMER       0x00000005  // Timer event
51 #define ADC_TRIGGER_PWM0        0x00000006  // PWM0 event
52 #define ADC_TRIGGER_PWM1        0x00000007  // PWM1 event
53 #define ADC_TRIGGER_PWM2        0x00000008  // PWM2 event
54 #define ADC_TRIGGER_PWM3        0x00000009  // PWM3 event
55 #define ADC_TRIGGER_ALWAYS      0x0000000F  // Always event
56 
57 //*****************************************************************************
58 //
59 // Values that can be passed to ADCSequenceStepConfigure as the ulConfig
60 // parameter.
61 //
62 //*****************************************************************************
63 #define ADC_CTL_TS              0x00000080  // Temperature sensor select
64 #define ADC_CTL_IE              0x00000040  // Interrupt enable
65 #define ADC_CTL_END             0x00000020  // Sequence end select
66 #define ADC_CTL_D               0x00000010  // Differential select
67 #define ADC_CTL_CH0             0x00000000  // Input channel 0
68 #define ADC_CTL_CH1             0x00000001  // Input channel 1
69 #define ADC_CTL_CH2             0x00000002  // Input channel 2
70 #define ADC_CTL_CH3             0x00000003  // Input channel 3
71 #define ADC_CTL_CH4             0x00000004  // Input channel 4
72 #define ADC_CTL_CH5             0x00000005  // Input channel 5
73 #define ADC_CTL_CH6             0x00000006  // Input channel 6
74 #define ADC_CTL_CH7             0x00000007  // Input channel 7
75 #define ADC_CTL_CH8             0x00000008  // Input channel 8
76 #define ADC_CTL_CH9             0x00000009  // Input channel 9
77 #define ADC_CTL_CH10            0x0000000A  // Input channel 10
78 #define ADC_CTL_CH11            0x0000000B  // Input channel 11
79 #define ADC_CTL_CH12            0x0000000C  // Input channel 12
80 #define ADC_CTL_CH13            0x0000000D  // Input channel 13
81 #define ADC_CTL_CH14            0x0000000E  // Input channel 14
82 #define ADC_CTL_CH15            0x0000000F  // Input channel 15
83 #define ADC_CTL_CH16            0x00000100  // Input channel 16
84 #define ADC_CTL_CH17            0x00000101  // Input channel 17
85 #define ADC_CTL_CH18            0x00000102  // Input channel 18
86 #define ADC_CTL_CH19            0x00000103  // Input channel 19
87 #define ADC_CTL_CH20            0x00000104  // Input channel 20
88 #define ADC_CTL_CH21            0x00000105  // Input channel 21
89 #define ADC_CTL_CH22            0x00000106  // Input channel 22
90 #define ADC_CTL_CH23            0x00000107  // Input channel 23
91 #define ADC_CTL_CMP0            0x00080000  // Select Comparator 0
92 #define ADC_CTL_CMP1            0x00090000  // Select Comparator 1
93 #define ADC_CTL_CMP2            0x000A0000  // Select Comparator 2
94 #define ADC_CTL_CMP3            0x000B0000  // Select Comparator 3
95 #define ADC_CTL_CMP4            0x000C0000  // Select Comparator 4
96 #define ADC_CTL_CMP5            0x000D0000  // Select Comparator 5
97 #define ADC_CTL_CMP6            0x000E0000  // Select Comparator 6
98 #define ADC_CTL_CMP7            0x000F0000  // Select Comparator 7
99 
100 //*****************************************************************************
101 //
102 // Values that can be passed to ADCComparatorConfigure as part of the
103 // ulConfig parameter.
104 //
105 //*****************************************************************************
106 #define ADC_COMP_TRIG_NONE      0x00000000  // Trigger Disabled
107 #define ADC_COMP_TRIG_LOW_ALWAYS \
108                                 0x00001000  // Trigger Low Always
109 #define ADC_COMP_TRIG_LOW_ONCE  0x00001100  // Trigger Low Once
110 #define ADC_COMP_TRIG_LOW_HALWAYS \
111                                 0x00001200  // Trigger Low Always (Hysteresis)
112 #define ADC_COMP_TRIG_LOW_HONCE 0x00001300  // Trigger Low Once (Hysteresis)
113 #define ADC_COMP_TRIG_MID_ALWAYS \
114                                 0x00001400  // Trigger Mid Always
115 #define ADC_COMP_TRIG_MID_ONCE  0x00001500  // Trigger Mid Once
116 #define ADC_COMP_TRIG_HIGH_ALWAYS \
117                                 0x00001C00  // Trigger High Always
118 #define ADC_COMP_TRIG_HIGH_ONCE 0x00001D00  // Trigger High Once
119 #define ADC_COMP_TRIG_HIGH_HALWAYS \
120                                 0x00001E00  // Trigger High Always (Hysteresis)
121 #define ADC_COMP_TRIG_HIGH_HONCE \
122                                 0x00001F00  // Trigger High Once (Hysteresis)
123 
124 #define ADC_COMP_INT_NONE       0x00000000  // Interrupt Disabled
125 #define ADC_COMP_INT_LOW_ALWAYS \
126                                 0x00000010  // Interrupt Low Always
127 #define ADC_COMP_INT_LOW_ONCE   0x00000011  // Interrupt Low Once
128 #define ADC_COMP_INT_LOW_HALWAYS \
129                                 0x00000012  // Interrupt Low Always
130                                             // (Hysteresis)
131 #define ADC_COMP_INT_LOW_HONCE  0x00000013  // Interrupt Low Once (Hysteresis)
132 #define ADC_COMP_INT_MID_ALWAYS \
133                                 0x00000014  // Interrupt Mid Always
134 #define ADC_COMP_INT_MID_ONCE   0x00000015  // Interrupt Mid Once
135 #define ADC_COMP_INT_HIGH_ALWAYS \
136                                 0x0000001C  // Interrupt High Always
137 #define ADC_COMP_INT_HIGH_ONCE  0x0000001D  // Interrupt High Once
138 #define ADC_COMP_INT_HIGH_HALWAYS \
139                                 0x0000001E  // Interrupt High Always
140                                             // (Hysteresis)
141 #define ADC_COMP_INT_HIGH_HONCE \
142                                 0x0000001F  // Interrupt High Once (Hysteresis)
143 
144 //*****************************************************************************
145 //
146 // Values that can be used to modify the sequence number passed to
147 // ADCProcessorTrigger in order to get cross-module synchronous processor
148 // triggers.
149 //
150 //*****************************************************************************
151 #define ADC_TRIGGER_WAIT        0x08000000  // Wait for the synchronous trigger
152 #define ADC_TRIGGER_SIGNAL      0x80000000  // Signal the synchronous trigger
153 
154 //*****************************************************************************
155 //
156 // Values that can be passed to ADCPhaseDelaySet as the ulPhase parameter and
157 // returned from ADCPhaseDelayGet.
158 //
159 //*****************************************************************************
160 #define ADC_PHASE_0             0x00000000  // 0 degrees
161 #define ADC_PHASE_22_5          0x00000001  // 22.5 degrees
162 #define ADC_PHASE_45            0x00000002  // 45 degrees
163 #define ADC_PHASE_67_5          0x00000003  // 67.5 degrees
164 #define ADC_PHASE_90            0x00000004  // 90 degrees
165 #define ADC_PHASE_112_5         0x00000005  // 112.5 degrees
166 #define ADC_PHASE_135           0x00000006  // 135 degrees
167 #define ADC_PHASE_157_5         0x00000007  // 157.5 degrees
168 #define ADC_PHASE_180           0x00000008  // 180 degrees
169 #define ADC_PHASE_202_5         0x00000009  // 202.5 degrees
170 #define ADC_PHASE_225           0x0000000A  // 225 degrees
171 #define ADC_PHASE_247_5         0x0000000B  // 247.5 degrees
172 #define ADC_PHASE_270           0x0000000C  // 270 degrees
173 #define ADC_PHASE_292_5         0x0000000D  // 292.5 degrees
174 #define ADC_PHASE_315           0x0000000E  // 315 degrees
175 #define ADC_PHASE_337_5         0x0000000F  // 337.5 degrees
176 
177 //*****************************************************************************
178 //
179 // Values that can be passed to ADCReferenceSet as the ulRef parameter.
180 //
181 //*****************************************************************************
182 #define ADC_REF_INT             0x00000000  // Internal reference
183 #define ADC_REF_EXT_3V          0x00000001  // External 3V reference
184 #define ADC_REF_EXT_1V          0x00000003  // External 1V reference
185 
186 //*****************************************************************************
187 //
188 // Values that can be passed to ADCResolutionSet as the ulResolution parameter.
189 //
190 //*****************************************************************************
191 #define ADC_RES_10BIT           0x00000000  // 10-bit resolution
192 #define ADC_RES_12BIT           0x00000010  // 12-bit resolution
193 
194 //*****************************************************************************
195 //
196 // Prototypes for the APIs.
197 //
198 //*****************************************************************************
199 extern void ADCIntRegister(unsigned long ulBase, unsigned long ulSequenceNum,
200                            void (*pfnHandler)(void));
201 extern void ADCIntUnregister(unsigned long ulBase,
202                              unsigned long ulSequenceNum);
203 extern void ADCIntDisable(unsigned long ulBase, unsigned long ulSequenceNum);
204 extern void ADCIntEnable(unsigned long ulBase, unsigned long ulSequenceNum);
205 extern unsigned long ADCIntStatus(unsigned long ulBase,
206                                   unsigned long ulSequenceNum,
207                                   tBoolean bMasked);
208 extern void ADCIntClear(unsigned long ulBase, unsigned long ulSequenceNum);
209 extern void ADCSequenceEnable(unsigned long ulBase,
210                               unsigned long ulSequenceNum);
211 extern void ADCSequenceDisable(unsigned long ulBase,
212                                unsigned long ulSequenceNum);
213 extern void ADCSequenceConfigure(unsigned long ulBase,
214                                  unsigned long ulSequenceNum,
215                                  unsigned long ulTrigger,
216                                  unsigned long ulPriority);
217 extern void ADCSequenceStepConfigure(unsigned long ulBase,
218                                      unsigned long ulSequenceNum,
219                                      unsigned long ulStep,
220                                      unsigned long ulConfig);
221 extern long ADCSequenceOverflow(unsigned long ulBase,
222                                 unsigned long ulSequenceNum);
223 extern void ADCSequenceOverflowClear(unsigned long ulBase,
224                                      unsigned long ulSequenceNum);
225 extern long ADCSequenceUnderflow(unsigned long ulBase,
226                                  unsigned long ulSequenceNum);
227 extern void ADCSequenceUnderflowClear(unsigned long ulBase,
228                                       unsigned long ulSequenceNum);
229 extern long ADCSequenceDataGet(unsigned long ulBase,
230                                unsigned long ulSequenceNum,
231                                unsigned long *pulBuffer);
232 extern void ADCProcessorTrigger(unsigned long ulBase,
233                                 unsigned long ulSequenceNum);
234 extern void ADCSoftwareOversampleConfigure(unsigned long ulBase,
235                                            unsigned long ulSequenceNum,
236                                            unsigned long ulFactor);
237 extern void ADCSoftwareOversampleStepConfigure(unsigned long ulBase,
238                                                unsigned long ulSequenceNum,
239                                                unsigned long ulStep,
240                                                unsigned long ulConfig);
241 extern void ADCSoftwareOversampleDataGet(unsigned long ulBase,
242                                          unsigned long ulSequenceNum,
243                                          unsigned long *pulBuffer,
244                                          unsigned long ulCount);
245 extern void ADCHardwareOversampleConfigure(unsigned long ulBase,
246                                            unsigned long ulFactor);
247 extern void ADCComparatorConfigure(unsigned long ulBase, unsigned long ulComp,
248                                    unsigned long ulConfig);
249 extern void ADCComparatorRegionSet(unsigned long ulBase, unsigned long ulComp,
250                                    unsigned long ulLowRef,
251                                    unsigned long ulHighRef);
252 extern void ADCComparatorReset(unsigned long ulBase, unsigned long ulComp,
253                                tBoolean bTrigger, tBoolean bInterrupt);
254 extern void ADCComparatorIntDisable(unsigned long ulBase,
255                                     unsigned long ulSequenceNum);
256 extern void ADCComparatorIntEnable(unsigned long ulBase,
257                                    unsigned long ulSequenceNum);
258 extern unsigned long ADCComparatorIntStatus(unsigned long ulBase);
259 extern void ADCComparatorIntClear(unsigned long ulBase,
260                                   unsigned long ulStatus);
261 extern void ADCReferenceSet(unsigned long ulBase, unsigned long ulRef);
262 extern unsigned long ADCReferenceGet(unsigned long ulBase);
263 extern void ADCResolutionSet(unsigned long ulBase, unsigned long ulResolution);
264 extern unsigned long ADCResolutionGet(unsigned long ulBase);
265 extern void ADCPhaseDelaySet(unsigned long ulBase, unsigned long ulPhase);
266 extern unsigned long ADCPhaseDelayGet(unsigned long ulBase);
267 
268 //*****************************************************************************
269 //
270 // Mark the end of the C bindings section for C++ compilers.
271 //
272 //*****************************************************************************
273 #ifdef __cplusplus
274 }
275 #endif
276 
277 #endif // __ADC_H__
278