1 //***************************************************************************** 2 // 3 // adc.h - ADC headers for using the ADC driver functions. 4 // 5 // Copyright (c) 2005-2012 Texas Instruments Incorporated. All rights reserved. 6 // Software License Agreement 7 // 8 // Redistribution and use in source and binary forms, with or without 9 // modification, are permitted provided that the following conditions 10 // are met: 11 // 12 // Redistributions of source code must retain the above copyright 13 // notice, this list of conditions and the following disclaimer. 14 // 15 // Redistributions in binary form must reproduce the above copyright 16 // notice, this list of conditions and the following disclaimer in the 17 // documentation and/or other materials provided with the 18 // distribution. 19 // 20 // Neither the name of Texas Instruments Incorporated nor the names of 21 // its contributors may be used to endorse or promote products derived 22 // from this software without specific prior written permission. 23 // 24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 // 36 // This is part of revision 9453 of the Stellaris Peripheral Driver Library. 37 // 38 //***************************************************************************** 39 40 #ifndef __ADC_H__ 41 #define __ADC_H__ 42 43 //***************************************************************************** 44 // 45 // If building with a C++ compiler, make all of the definitions in this header 46 // have a C binding. 47 // 48 //***************************************************************************** 49 #ifdef __cplusplus 50 extern "C" 51 { 52 #endif 53 54 //***************************************************************************** 55 // 56 // Values that can be passed to ADCSequenceConfigure as the ulTrigger 57 // parameter. 58 // 59 //***************************************************************************** 60 #define ADC_TRIGGER_PROCESSOR 0x00000000 // Processor event 61 #define ADC_TRIGGER_COMP0 0x00000001 // Analog comparator 0 event 62 #define ADC_TRIGGER_COMP1 0x00000002 // Analog comparator 1 event 63 #define ADC_TRIGGER_COMP2 0x00000003 // Analog comparator 2 event 64 #define ADC_TRIGGER_EXTERNAL 0x00000004 // External event 65 #define ADC_TRIGGER_TIMER 0x00000005 // Timer event 66 #define ADC_TRIGGER_PWM0 0x00000006 // PWM0 event 67 #define ADC_TRIGGER_PWM1 0x00000007 // PWM1 event 68 #define ADC_TRIGGER_PWM2 0x00000008 // PWM2 event 69 #define ADC_TRIGGER_PWM3 0x00000009 // PWM3 event 70 #define ADC_TRIGGER_ALWAYS 0x0000000F // Always event 71 72 //***************************************************************************** 73 // 74 // Values that can be passed to ADCSequenceStepConfigure as the ulConfig 75 // parameter. 76 // 77 //***************************************************************************** 78 #define ADC_CTL_TS 0x00000080 // Temperature sensor select 79 #define ADC_CTL_IE 0x00000040 // Interrupt enable 80 #define ADC_CTL_END 0x00000020 // Sequence end select 81 #define ADC_CTL_D 0x00000010 // Differential select 82 #define ADC_CTL_CH0 0x00000000 // Input channel 0 83 #define ADC_CTL_CH1 0x00000001 // Input channel 1 84 #define ADC_CTL_CH2 0x00000002 // Input channel 2 85 #define ADC_CTL_CH3 0x00000003 // Input channel 3 86 #define ADC_CTL_CH4 0x00000004 // Input channel 4 87 #define ADC_CTL_CH5 0x00000005 // Input channel 5 88 #define ADC_CTL_CH6 0x00000006 // Input channel 6 89 #define ADC_CTL_CH7 0x00000007 // Input channel 7 90 #define ADC_CTL_CH8 0x00000008 // Input channel 8 91 #define ADC_CTL_CH9 0x00000009 // Input channel 9 92 #define ADC_CTL_CH10 0x0000000A // Input channel 10 93 #define ADC_CTL_CH11 0x0000000B // Input channel 11 94 #define ADC_CTL_CH12 0x0000000C // Input channel 12 95 #define ADC_CTL_CH13 0x0000000D // Input channel 13 96 #define ADC_CTL_CH14 0x0000000E // Input channel 14 97 #define ADC_CTL_CH15 0x0000000F // Input channel 15 98 #define ADC_CTL_CH16 0x00000100 // Input channel 16 99 #define ADC_CTL_CH17 0x00000101 // Input channel 17 100 #define ADC_CTL_CH18 0x00000102 // Input channel 18 101 #define ADC_CTL_CH19 0x00000103 // Input channel 19 102 #define ADC_CTL_CH20 0x00000104 // Input channel 20 103 #define ADC_CTL_CH21 0x00000105 // Input channel 21 104 #define ADC_CTL_CH22 0x00000106 // Input channel 22 105 #define ADC_CTL_CH23 0x00000107 // Input channel 23 106 #define ADC_CTL_CMP0 0x00080000 // Select Comparator 0 107 #define ADC_CTL_CMP1 0x00090000 // Select Comparator 1 108 #define ADC_CTL_CMP2 0x000A0000 // Select Comparator 2 109 #define ADC_CTL_CMP3 0x000B0000 // Select Comparator 3 110 #define ADC_CTL_CMP4 0x000C0000 // Select Comparator 4 111 #define ADC_CTL_CMP5 0x000D0000 // Select Comparator 5 112 #define ADC_CTL_CMP6 0x000E0000 // Select Comparator 6 113 #define ADC_CTL_CMP7 0x000F0000 // Select Comparator 7 114 115 //***************************************************************************** 116 // 117 // Values that can be passed to ADCComparatorConfigure as part of the 118 // ulConfig parameter. 119 // 120 //***************************************************************************** 121 #define ADC_COMP_TRIG_NONE 0x00000000 // Trigger Disabled 122 #define ADC_COMP_TRIG_LOW_ALWAYS \ 123 0x00001000 // Trigger Low Always 124 #define ADC_COMP_TRIG_LOW_ONCE 0x00001100 // Trigger Low Once 125 #define ADC_COMP_TRIG_LOW_HALWAYS \ 126 0x00001200 // Trigger Low Always (Hysteresis) 127 #define ADC_COMP_TRIG_LOW_HONCE 0x00001300 // Trigger Low Once (Hysteresis) 128 #define ADC_COMP_TRIG_MID_ALWAYS \ 129 0x00001400 // Trigger Mid Always 130 #define ADC_COMP_TRIG_MID_ONCE 0x00001500 // Trigger Mid Once 131 #define ADC_COMP_TRIG_HIGH_ALWAYS \ 132 0x00001C00 // Trigger High Always 133 #define ADC_COMP_TRIG_HIGH_ONCE 0x00001D00 // Trigger High Once 134 #define ADC_COMP_TRIG_HIGH_HALWAYS \ 135 0x00001E00 // Trigger High Always (Hysteresis) 136 #define ADC_COMP_TRIG_HIGH_HONCE \ 137 0x00001F00 // Trigger High Once (Hysteresis) 138 139 #define ADC_COMP_INT_NONE 0x00000000 // Interrupt Disabled 140 #define ADC_COMP_INT_LOW_ALWAYS \ 141 0x00000010 // Interrupt Low Always 142 #define ADC_COMP_INT_LOW_ONCE 0x00000011 // Interrupt Low Once 143 #define ADC_COMP_INT_LOW_HALWAYS \ 144 0x00000012 // Interrupt Low Always 145 // (Hysteresis) 146 #define ADC_COMP_INT_LOW_HONCE 0x00000013 // Interrupt Low Once (Hysteresis) 147 #define ADC_COMP_INT_MID_ALWAYS \ 148 0x00000014 // Interrupt Mid Always 149 #define ADC_COMP_INT_MID_ONCE 0x00000015 // Interrupt Mid Once 150 #define ADC_COMP_INT_HIGH_ALWAYS \ 151 0x0000001C // Interrupt High Always 152 #define ADC_COMP_INT_HIGH_ONCE 0x0000001D // Interrupt High Once 153 #define ADC_COMP_INT_HIGH_HALWAYS \ 154 0x0000001E // Interrupt High Always 155 // (Hysteresis) 156 #define ADC_COMP_INT_HIGH_HONCE \ 157 0x0000001F // Interrupt High Once (Hysteresis) 158 159 //***************************************************************************** 160 // 161 // Values that can be used to modify the sequence number passed to 162 // ADCProcessorTrigger in order to get cross-module synchronous processor 163 // triggers. 164 // 165 //***************************************************************************** 166 #define ADC_TRIGGER_WAIT 0x08000000 // Wait for the synchronous trigger 167 #define ADC_TRIGGER_SIGNAL 0x80000000 // Signal the synchronous trigger 168 169 //***************************************************************************** 170 // 171 // Values that can be passed to ADCPhaseDelaySet as the ulPhase parameter and 172 // returned from ADCPhaseDelayGet. 173 // 174 //***************************************************************************** 175 #define ADC_PHASE_0 0x00000000 // 0 degrees 176 #define ADC_PHASE_22_5 0x00000001 // 22.5 degrees 177 #define ADC_PHASE_45 0x00000002 // 45 degrees 178 #define ADC_PHASE_67_5 0x00000003 // 67.5 degrees 179 #define ADC_PHASE_90 0x00000004 // 90 degrees 180 #define ADC_PHASE_112_5 0x00000005 // 112.5 degrees 181 #define ADC_PHASE_135 0x00000006 // 135 degrees 182 #define ADC_PHASE_157_5 0x00000007 // 157.5 degrees 183 #define ADC_PHASE_180 0x00000008 // 180 degrees 184 #define ADC_PHASE_202_5 0x00000009 // 202.5 degrees 185 #define ADC_PHASE_225 0x0000000A // 225 degrees 186 #define ADC_PHASE_247_5 0x0000000B // 247.5 degrees 187 #define ADC_PHASE_270 0x0000000C // 270 degrees 188 #define ADC_PHASE_292_5 0x0000000D // 292.5 degrees 189 #define ADC_PHASE_315 0x0000000E // 315 degrees 190 #define ADC_PHASE_337_5 0x0000000F // 337.5 degrees 191 192 //***************************************************************************** 193 // 194 // Values that can be passed to ADCReferenceSet as the ulRef parameter. 195 // 196 //***************************************************************************** 197 #define ADC_REF_INT 0x00000000 // Internal reference 198 #define ADC_REF_EXT_3V 0x00000001 // External 3V reference 199 #define ADC_REF_EXT_1V 0x00000003 // External 1V reference 200 201 //***************************************************************************** 202 // 203 // Values that can be passed to ADCResolutionSet as the ulResolution parameter. 204 // 205 //***************************************************************************** 206 #define ADC_RES_10BIT 0x00000000 // 10-bit resolution 207 #define ADC_RES_12BIT 0x00000010 // 12-bit resolution 208 209 //***************************************************************************** 210 // 211 // Values that can be passed to ADCIntDisableEx(), ADCIntEnableEx(), 212 // ADCIntClearEx() and ADCIntStatusEx(). 213 // 214 //***************************************************************************** 215 #define ADC_INT_SS0 0x00000001 216 #define ADC_INT_SS1 0x00000002 217 #define ADC_INT_SS2 0x00000004 218 #define ADC_INT_SS3 0x00000008 219 #define ADC_INT_DMA_SS0 0x00000100 220 #define ADC_INT_DMA_SS1 0x00000200 221 #define ADC_INT_DMA_SS2 0x00000400 222 #define ADC_INT_DMA_SS3 0x00000800 223 #define ADC_INT_DCON_SS0 0x00010000 224 #define ADC_INT_DCON_SS1 0x00020000 225 #define ADC_INT_DCON_SS2 0x00040000 226 #define ADC_INT_DCON_SS3 0x00080000 227 228 //***************************************************************************** 229 // 230 // Prototypes for the APIs. 231 // 232 //***************************************************************************** 233 extern void ADCIntRegister(unsigned long ulBase, unsigned long ulSequenceNum, 234 void (*pfnHandler)(void)); 235 extern void ADCIntUnregister(unsigned long ulBase, 236 unsigned long ulSequenceNum); 237 extern void ADCIntDisable(unsigned long ulBase, unsigned long ulSequenceNum); 238 extern void ADCIntEnable(unsigned long ulBase, unsigned long ulSequenceNum); 239 extern unsigned long ADCIntStatus(unsigned long ulBase, 240 unsigned long ulSequenceNum, 241 tBoolean bMasked); 242 extern void ADCIntClear(unsigned long ulBase, unsigned long ulSequenceNum); 243 extern void ADCSequenceEnable(unsigned long ulBase, 244 unsigned long ulSequenceNum); 245 extern void ADCSequenceDisable(unsigned long ulBase, 246 unsigned long ulSequenceNum); 247 extern void ADCSequenceConfigure(unsigned long ulBase, 248 unsigned long ulSequenceNum, 249 unsigned long ulTrigger, 250 unsigned long ulPriority); 251 extern void ADCSequenceStepConfigure(unsigned long ulBase, 252 unsigned long ulSequenceNum, 253 unsigned long ulStep, 254 unsigned long ulConfig); 255 extern long ADCSequenceOverflow(unsigned long ulBase, 256 unsigned long ulSequenceNum); 257 extern void ADCSequenceOverflowClear(unsigned long ulBase, 258 unsigned long ulSequenceNum); 259 extern long ADCSequenceUnderflow(unsigned long ulBase, 260 unsigned long ulSequenceNum); 261 extern void ADCSequenceUnderflowClear(unsigned long ulBase, 262 unsigned long ulSequenceNum); 263 extern long ADCSequenceDataGet(unsigned long ulBase, 264 unsigned long ulSequenceNum, 265 unsigned long *pulBuffer); 266 extern void ADCProcessorTrigger(unsigned long ulBase, 267 unsigned long ulSequenceNum); 268 extern void ADCSoftwareOversampleConfigure(unsigned long ulBase, 269 unsigned long ulSequenceNum, 270 unsigned long ulFactor); 271 extern void ADCSoftwareOversampleStepConfigure(unsigned long ulBase, 272 unsigned long ulSequenceNum, 273 unsigned long ulStep, 274 unsigned long ulConfig); 275 extern void ADCSoftwareOversampleDataGet(unsigned long ulBase, 276 unsigned long ulSequenceNum, 277 unsigned long *pulBuffer, 278 unsigned long ulCount); 279 extern void ADCHardwareOversampleConfigure(unsigned long ulBase, 280 unsigned long ulFactor); 281 extern void ADCComparatorConfigure(unsigned long ulBase, unsigned long ulComp, 282 unsigned long ulConfig); 283 extern void ADCComparatorRegionSet(unsigned long ulBase, unsigned long ulComp, 284 unsigned long ulLowRef, 285 unsigned long ulHighRef); 286 extern void ADCComparatorReset(unsigned long ulBase, unsigned long ulComp, 287 tBoolean bTrigger, tBoolean bInterrupt); 288 extern void ADCComparatorIntDisable(unsigned long ulBase, 289 unsigned long ulSequenceNum); 290 extern void ADCComparatorIntEnable(unsigned long ulBase, 291 unsigned long ulSequenceNum); 292 extern unsigned long ADCComparatorIntStatus(unsigned long ulBase); 293 extern void ADCComparatorIntClear(unsigned long ulBase, 294 unsigned long ulStatus); 295 extern void ADCReferenceSet(unsigned long ulBase, unsigned long ulRef); 296 extern unsigned long ADCReferenceGet(unsigned long ulBase); 297 extern void ADCResolutionSet(unsigned long ulBase, unsigned long ulResolution); 298 extern unsigned long ADCResolutionGet(unsigned long ulBase); 299 extern void ADCPhaseDelaySet(unsigned long ulBase, unsigned long ulPhase); 300 extern unsigned long ADCPhaseDelayGet(unsigned long ulBase); 301 302 //***************************************************************************** 303 // 304 // Mark the end of the C bindings section for C++ compilers. 305 // 306 //***************************************************************************** 307 #ifdef __cplusplus 308 } 309 #endif 310 311 #endif // __ADC_H__ 312