2020-2021 Sunseeker Telemetry and Lighting System
adc12_a.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // adc12_a.h - Driver for the ADC12_A Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_ADC12_A_H__
8 #define __MSP430WARE_ADC12_A_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_ADC12_PLUS__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include "inc/hw_memmap.h"
26 //*****************************************************************************
27 //
30 //
31 //*****************************************************************************
32 typedef struct ADC12_A_configureMemoryParam {
51  uint8_t memoryBufferControlIndex;
71  uint8_t inputSourceSelect;
78  uint8_t positiveRefVoltageSourceSelect;
84  uint8_t negativeRefVoltageSourceSelect;
93  uint8_t endOfSequence;
94 } ADC12_A_configureMemoryParam;
95 
96 
97 //*****************************************************************************
98 //
99 // The following are values that can be passed to the clockSourceSelect
100 // parameter for functions: ADC12_A_init().
101 //
102 //*****************************************************************************
103 #define ADC12_A_CLOCKSOURCE_ADC12OSC (ADC12SSEL_0)
104 #define ADC12_A_CLOCKSOURCE_ACLK (ADC12SSEL_1)
105 #define ADC12_A_CLOCKSOURCE_MCLK (ADC12SSEL_2)
106 #define ADC12_A_CLOCKSOURCE_SMCLK (ADC12SSEL_3)
107 
108 //*****************************************************************************
109 //
110 // The following are values that can be passed to the clockSourceDivider
111 // parameter for functions: ADC12_A_init().
112 //
113 //*****************************************************************************
114 #define ADC12_A_CLOCKDIVIDER_1 (ADC12DIV_0)
115 #define ADC12_A_CLOCKDIVIDER_2 (ADC12DIV_1)
116 #define ADC12_A_CLOCKDIVIDER_3 (ADC12DIV_2)
117 #define ADC12_A_CLOCKDIVIDER_4 (ADC12DIV_3)
118 #define ADC12_A_CLOCKDIVIDER_5 (ADC12DIV_4)
119 #define ADC12_A_CLOCKDIVIDER_6 (ADC12DIV_5)
120 #define ADC12_A_CLOCKDIVIDER_7 (ADC12DIV_6)
121 #define ADC12_A_CLOCKDIVIDER_8 (ADC12DIV_7)
122 #define ADC12_A_CLOCKDIVIDER_12 (ADC12DIV_2 + ADC12PDIV)
123 #define ADC12_A_CLOCKDIVIDER_16 (ADC12DIV_3 + ADC12PDIV)
124 #define ADC12_A_CLOCKDIVIDER_20 (ADC12DIV_4 + ADC12PDIV)
125 #define ADC12_A_CLOCKDIVIDER_24 (ADC12DIV_5 + ADC12PDIV)
126 #define ADC12_A_CLOCKDIVIDER_28 (ADC12DIV_6 + ADC12PDIV)
127 #define ADC12_A_CLOCKDIVIDER_32 (ADC12DIV_7 + ADC12PDIV)
128 
129 //*****************************************************************************
130 //
131 // The following are values that can be passed to the
132 // sampleHoldSignalSourceSelect parameter for functions: ADC12_A_init().
133 //
134 //*****************************************************************************
135 #define ADC12_A_SAMPLEHOLDSOURCE_SC (ADC12SHS_0)
136 #define ADC12_A_SAMPLEHOLDSOURCE_1 (ADC12SHS_1)
137 #define ADC12_A_SAMPLEHOLDSOURCE_2 (ADC12SHS_2)
138 #define ADC12_A_SAMPLEHOLDSOURCE_3 (ADC12SHS_3)
139 
140 //*****************************************************************************
141 //
142 // The following are values that can be passed to the clockCycleHoldCountLowMem
143 // parameter for functions: ADC12_A_setupSamplingTimer(); the
144 // clockCycleHoldCountHighMem parameter for functions:
145 // ADC12_A_setupSamplingTimer().
146 //
147 //*****************************************************************************
148 #define ADC12_A_CYCLEHOLD_4_CYCLES (ADC12SHT0_0)
149 #define ADC12_A_CYCLEHOLD_8_CYCLES (ADC12SHT0_1)
150 #define ADC12_A_CYCLEHOLD_16_CYCLES (ADC12SHT0_2)
151 #define ADC12_A_CYCLEHOLD_32_CYCLES (ADC12SHT0_3)
152 #define ADC12_A_CYCLEHOLD_64_CYCLES (ADC12SHT0_4)
153 #define ADC12_A_CYCLEHOLD_96_CYCLES (ADC12SHT0_5)
154 #define ADC12_A_CYCLEHOLD_128_CYCLES (ADC12SHT0_6)
155 #define ADC12_A_CYCLEHOLD_192_CYCLES (ADC12SHT0_7)
156 #define ADC12_A_CYCLEHOLD_256_CYCLES (ADC12SHT0_8)
157 #define ADC12_A_CYCLEHOLD_384_CYCLES (ADC12SHT0_9)
158 #define ADC12_A_CYCLEHOLD_512_CYCLES (ADC12SHT0_10)
159 #define ADC12_A_CYCLEHOLD_768_CYCLES (ADC12SHT0_11)
160 #define ADC12_A_CYCLEHOLD_1024_CYCLES (ADC12SHT0_12)
161 
162 //*****************************************************************************
163 //
164 // The following are values that can be passed to the multipleSamplesEnabled
165 // parameter for functions: ADC12_A_setupSamplingTimer().
166 //
167 //*****************************************************************************
168 #define ADC12_A_MULTIPLESAMPLESDISABLE (!(ADC12MSC))
169 #define ADC12_A_MULTIPLESAMPLESENABLE (ADC12MSC)
170 
171 //*****************************************************************************
172 //
173 // The following are values that can be passed to the param parameter for
174 // functions: ADC12_A_configureMemory().
175 //
176 //*****************************************************************************
177 #define ADC12_A_VREFPOS_AVCC (!(ADC12SREF0 + ADC12SREF1))
178 #define ADC12_A_VREFPOS_EXT (ADC12SREF1)
179 #define ADC12_A_VREFPOS_INT (ADC12SREF0)
180 
181 //*****************************************************************************
182 //
183 // The following are values that can be passed to the param parameter for
184 // functions: ADC12_A_configureMemory().
185 //
186 //*****************************************************************************
187 #define ADC12_A_VREFNEG_AVSS (!(ADC12SREF2))
188 #define ADC12_A_VREFNEG_EXT (ADC12SREF2)
189 
190 //*****************************************************************************
191 //
192 // The following are values that can be passed to the param parameter for
193 // functions: ADC12_A_configureMemory().
194 //
195 //*****************************************************************************
196 #define ADC12_A_NOTENDOFSEQUENCE (!(ADC12EOS))
197 #define ADC12_A_ENDOFSEQUENCE (ADC12EOS)
198 
199 //*****************************************************************************
200 //
201 // The following are values that can be passed to the param parameter for
202 // functions: ADC12_A_configureMemory().
203 //
204 //*****************************************************************************
205 #define ADC12_A_INPUT_A0 (ADC12INCH_0)
206 #define ADC12_A_INPUT_A1 (ADC12INCH_1)
207 #define ADC12_A_INPUT_A2 (ADC12INCH_2)
208 #define ADC12_A_INPUT_A3 (ADC12INCH_3)
209 #define ADC12_A_INPUT_A4 (ADC12INCH_4)
210 #define ADC12_A_INPUT_A5 (ADC12INCH_5)
211 #define ADC12_A_INPUT_A6 (ADC12INCH_6)
212 #define ADC12_A_INPUT_A7 (ADC12INCH_7)
213 #define ADC12_A_INPUT_A8 (ADC12INCH_8)
214 #define ADC12_A_INPUT_A9 (ADC12INCH_9)
215 #define ADC12_A_INPUT_TEMPSENSOR (ADC12INCH_10)
216 #define ADC12_A_INPUT_BATTERYMONITOR (ADC12INCH_11)
217 #define ADC12_A_INPUT_A12 (ADC12INCH_12)
218 #define ADC12_A_INPUT_A13 (ADC12INCH_13)
219 #define ADC12_A_INPUT_A14 (ADC12INCH_14)
220 #define ADC12_A_INPUT_A15 (ADC12INCH_15)
221 
222 //*****************************************************************************
223 //
224 // The following are values that can be passed to the startingMemoryBufferIndex
225 // parameter for functions: ADC12_A_startConversion(); the memoryIndex
226 // parameter for functions: ADC12_A_getMemoryAddressForDMA(); the
227 // memoryBufferIndex parameter for functions: ADC12_A_getResults(); the param
228 // parameter for functions: ADC12_A_configureMemory().
229 //
230 //*****************************************************************************
231 #define ADC12_A_MEMORY_0 (0x0)
232 #define ADC12_A_MEMORY_1 (0x1)
233 #define ADC12_A_MEMORY_2 (0x2)
234 #define ADC12_A_MEMORY_3 (0x3)
235 #define ADC12_A_MEMORY_4 (0x4)
236 #define ADC12_A_MEMORY_5 (0x5)
237 #define ADC12_A_MEMORY_6 (0x6)
238 #define ADC12_A_MEMORY_7 (0x7)
239 #define ADC12_A_MEMORY_8 (0x8)
240 #define ADC12_A_MEMORY_9 (0x9)
241 #define ADC12_A_MEMORY_10 (0xA)
242 #define ADC12_A_MEMORY_11 (0xB)
243 #define ADC12_A_MEMORY_12 (0xC)
244 #define ADC12_A_MEMORY_13 (0xD)
245 #define ADC12_A_MEMORY_14 (0xE)
246 #define ADC12_A_MEMORY_15 (0xF)
247 
248 //*****************************************************************************
249 //
250 // The following are values that can be passed to the memoryInterruptFlagMask
251 // parameter for functions: ADC12_A_clearInterrupt(), and
252 // ADC12_A_getInterruptStatus().
253 //
254 //*****************************************************************************
255 #define ADC12_A_IFG0 (ADC12IFG0)
256 #define ADC12_A_IFG1 (ADC12IFG1)
257 #define ADC12_A_IFG2 (ADC12IFG2)
258 #define ADC12_A_IFG3 (ADC12IFG3)
259 #define ADC12_A_IFG4 (ADC12IFG4)
260 #define ADC12_A_IFG5 (ADC12IFG5)
261 #define ADC12_A_IFG6 (ADC12IFG6)
262 #define ADC12_A_IFG7 (ADC12IFG7)
263 #define ADC12_A_IFG8 (ADC12IFG8)
264 #define ADC12_A_IFG9 (ADC12IFG9)
265 #define ADC12_A_IFG10 (ADC12IFG10)
266 #define ADC12_A_IFG11 (ADC12IFG11)
267 #define ADC12_A_IFG12 (ADC12IFG12)
268 #define ADC12_A_IFG13 (ADC12IFG13)
269 #define ADC12_A_IFG14 (ADC12IFG14)
270 #define ADC12_A_IFG15 (ADC12IFG15)
271 
272 //*****************************************************************************
273 //
274 // The following are values that can be passed to the
275 // conversionSequenceModeSelect parameter for functions:
276 // ADC12_A_startConversion().
277 //
278 //*****************************************************************************
279 #define ADC12_A_SINGLECHANNEL (ADC12CONSEQ_0)
280 #define ADC12_A_SEQOFCHANNELS (ADC12CONSEQ_1)
281 #define ADC12_A_REPEATED_SINGLECHANNEL (ADC12CONSEQ_2)
282 #define ADC12_A_REPEATED_SEQOFCHANNELS (ADC12CONSEQ_3)
283 
284 //*****************************************************************************
285 //
286 // The following are values that can be passed to the preempt parameter for
287 // functions: ADC12_A_disableConversions().
288 //
289 //*****************************************************************************
290 #define ADC12_A_COMPLETECONVERSION false
291 #define ADC12_A_PREEMPTCONVERSION true
292 
293 //*****************************************************************************
294 //
295 // The following are values that can be passed to the resolutionSelect
296 // parameter for functions: ADC12_A_setResolution().
297 //
298 //*****************************************************************************
299 #define ADC12_A_RESOLUTION_8BIT (ADC12RES_0)
300 #define ADC12_A_RESOLUTION_10BIT (ADC12RES_1)
301 #define ADC12_A_RESOLUTION_12BIT (ADC12RES_2)
302 
303 //*****************************************************************************
304 //
305 // The following are values that can be passed to the invertedSignal parameter
306 // for functions: ADC12_A_setSampleHoldSignalInversion().
307 //
308 //*****************************************************************************
309 #define ADC12_A_NONINVERTEDSIGNAL (!(ADC12ISSH))
310 #define ADC12_A_INVERTEDSIGNAL (ADC12ISSH)
311 
312 //*****************************************************************************
313 //
314 // The following are values that can be passed to the readBackFormat parameter
315 // for functions: ADC12_A_setDataReadBackFormat().
316 //
317 //*****************************************************************************
318 #define ADC12_A_UNSIGNED_BINARY (!(ADC12DF))
319 #define ADC12_A_SIGNED_2SCOMPLEMENT (ADC12DF)
320 
321 //*****************************************************************************
322 //
323 // The following are values that can be passed to the samplingRateSelect
324 // parameter for functions: ADC12_A_setReferenceBufferSamplingRate().
325 //
326 //*****************************************************************************
327 #define ADC12_A_MAXSAMPLINGRATE_200KSPS (!(ADC12SR))
328 #define ADC12_A_MAXSAMPLINGRATE_50KSPS (ADC12SR)
329 
330 //*****************************************************************************
331 //
332 // The following are values that can be passed toThe following are values that
333 // can be returned by the ADC12_A_isBusy() function.
334 //
335 //*****************************************************************************
336 #define ADC12_A_NOTBUSY 0x00
337 #define ADC12_A_BUSY ADC12BUSY
338 
339 //*****************************************************************************
340 //
341 // The following are values that can be passed to the interruptMask parameter
342 // for functions: ADC12_A_enableInterrupt(), and ADC12_A_disableInterrupt().
343 //
344 //*****************************************************************************
345 #define ADC12_A_IE0 (ADC12IE0)
346 #define ADC12_A_IE1 (ADC12IE1)
347 #define ADC12_A_IE2 (ADC12IE2)
348 #define ADC12_A_IE3 (ADC12IE3)
349 #define ADC12_A_IE4 (ADC12IE4)
350 #define ADC12_A_IE5 (ADC12IE5)
351 #define ADC12_A_IE6 (ADC12IE6)
352 #define ADC12_A_IE7 (ADC12IE7)
353 #define ADC12_A_IE8 (ADC12IE8)
354 #define ADC12_A_IE9 (ADC12IE9)
355 #define ADC12_A_IE10 (ADC12IE10)
356 #define ADC12_A_IE11 (ADC12IE11)
357 #define ADC12_A_IE12 (ADC12IE12)
358 #define ADC12_A_IE13 (ADC12IE13)
359 #define ADC12_A_IE14 (ADC12IE14)
360 #define ADC12_A_IE15 (ADC12IE15)
361 #define ADC12_A_OVERFLOW_IE ((uint32_t)ADC12OVIE << 16)
362 #define ADC12_A_CONVERSION_TIME_OVERFLOW_IE ((uint32_t)ADC12TOVIE << 16)
363 
364 //*****************************************************************************
365 //
366 // Prototypes for the APIs.
367 //
368 //*****************************************************************************
369 
370 //*****************************************************************************
371 //
428 //
429 //*****************************************************************************
430 extern bool ADC12_A_init(uint16_t baseAddress,
431  uint16_t sampleHoldSignalSourceSelect,
432  uint8_t clockSourceSelect,
433  uint16_t clockSourceDivider);
434 
435 //*****************************************************************************
436 //
446 //
447 //*****************************************************************************
448 extern void ADC12_A_enable(uint16_t baseAddress);
449 
450 //*****************************************************************************
451 //
461 //
462 //*****************************************************************************
463 extern void ADC12_A_disable(uint16_t baseAddress);
464 
465 //*****************************************************************************
466 //
524 //
525 //*****************************************************************************
526 extern void ADC12_A_setupSamplingTimer(uint16_t baseAddress,
527  uint16_t clockCycleHoldCountLowMem,
528  uint16_t clockCycleHoldCountHighMem,
529  uint16_t multipleSamplesEnabled);
530 
531 //*****************************************************************************
532 //
544 //
545 //*****************************************************************************
546 extern void ADC12_A_disableSamplingTimer(uint16_t baseAddress);
547 
548 //*****************************************************************************
549 //
565 //
566 //*****************************************************************************
567 extern void ADC12_A_configureMemory(uint16_t baseAddress,
568  ADC12_A_configureMemoryParam *param);
569 
570 //*****************************************************************************
571 //
603 //
604 //*****************************************************************************
605 extern void ADC12_A_enableInterrupt(uint16_t baseAddress,
606  uint32_t interruptMask);
607 
608 //*****************************************************************************
609 //
641 //
642 //*****************************************************************************
643 extern void ADC12_A_disableInterrupt(uint16_t baseAddress,
644  uint32_t interruptMask);
645 
646 //*****************************************************************************
647 //
680 //
681 //*****************************************************************************
682 extern void ADC12_A_clearInterrupt(uint16_t baseAddress,
683  uint16_t memoryInterruptFlagMask);
684 
685 //*****************************************************************************
686 //
715 //
716 //*****************************************************************************
717 extern uint16_t ADC12_A_getInterruptStatus(uint16_t baseAddress,
718  uint16_t memoryInterruptFlagMask);
719 
720 //*****************************************************************************
721 //
779 //
780 //*****************************************************************************
781 extern void ADC12_A_startConversion(uint16_t baseAddress,
782  uint16_t startingMemoryBufferIndex,
783  uint8_t conversionSequenceModeSelect);
784 
785 //*****************************************************************************
786 //
813 //
814 //*****************************************************************************
815 extern void ADC12_A_disableConversions(uint16_t baseAddress,
816  bool preempt);
817 
818 //*****************************************************************************
819 //
850 //
851 //*****************************************************************************
852 extern uint16_t ADC12_A_getResults(uint16_t baseAddress,
853  uint8_t memoryBufferIndex);
854 
855 //*****************************************************************************
856 //
871 //
872 //*****************************************************************************
873 extern void ADC12_A_setResolution(uint16_t baseAddress,
874  uint8_t resolutionSelect);
875 
876 //*****************************************************************************
877 //
897 //
898 //*****************************************************************************
899 extern void ADC12_A_setSampleHoldSignalInversion(uint16_t baseAddress,
900  uint16_t invertedSignal);
901 
902 //*****************************************************************************
903 //
922 //
923 //*****************************************************************************
924 extern void ADC12_A_setDataReadBackFormat(uint16_t baseAddress,
925  uint8_t readBackFormat);
926 
927 //*****************************************************************************
928 //
938 //
939 //*****************************************************************************
940 extern void ADC12_A_enableReferenceBurst(uint16_t baseAddress);
941 
942 //*****************************************************************************
943 //
952 //
953 //*****************************************************************************
954 extern void ADC12_A_disableReferenceBurst(uint16_t baseAddress);
955 
956 //*****************************************************************************
957 //
972 //
973 //*****************************************************************************
974 extern void ADC12_A_setReferenceBufferSamplingRate(uint16_t baseAddress,
975  uint8_t samplingRateSelect);
976 
977 //*****************************************************************************
978 //
1006 //
1007 //*****************************************************************************
1008 extern uint32_t ADC12_A_getMemoryAddressForDMA(uint16_t baseAddress,
1009  uint8_t memoryIndex);
1010 
1011 //*****************************************************************************
1012 //
1024 //
1025 //*****************************************************************************
1026 extern uint16_t ADC12_A_isBusy(uint16_t baseAddress);
1027 
1028 //*****************************************************************************
1029 //
1030 // Mark the end of the C bindings section for C++ compilers.
1031 //
1032 //*****************************************************************************
1033 #ifdef __cplusplus
1034 }
1035 #endif
1036 
1037 #endif
1038 #endif // __MSP430WARE_ADC12_A_H__
MPU_initThreeSegmentsParam param