2020-2021 Sunseeker Telemetry and Lighting System
adc10_a.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // adc10_a.h - Driver for the ADC10_A Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_ADC10_A_H__
8 #define __MSP430WARE_ADC10_A_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_ADC10_A__
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 //*****************************************************************************
26 //
27 // The following are values that can be passed to the clockSourceSelect
28 // parameter for functions: ADC10_A_init().
29 //
30 //*****************************************************************************
31 #define ADC10_A_CLOCKSOURCE_ADC10OSC (ADC10SSEL_0)
32 #define ADC10_A_CLOCKSOURCE_ACLK (ADC10SSEL_1)
33 #define ADC10_A_CLOCKSOURCE_MCLK (ADC10SSEL_2)
34 #define ADC10_A_CLOCKSOURCE_SMCLK (ADC10SSEL_3)
35 
36 //*****************************************************************************
37 //
38 // The following are values that can be passed to the clockSourceDivider
39 // parameter for functions: ADC10_A_init().
40 //
41 //*****************************************************************************
42 #define ADC10_A_CLOCKDIVIDER_1 (ADC10DIV_0 + ADC10PDIV_0)
43 #define ADC10_A_CLOCKDIVIDER_2 (ADC10DIV_1 + ADC10PDIV_0)
44 #define ADC10_A_CLOCKDIVIDER_3 (ADC10DIV_2 + ADC10PDIV_0)
45 #define ADC10_A_CLOCKDIVIDER_4 (ADC10DIV_3 + ADC10PDIV_0)
46 #define ADC10_A_CLOCKDIVIDER_5 (ADC10DIV_4 + ADC10PDIV_0)
47 #define ADC10_A_CLOCKDIVIDER_6 (ADC10DIV_5 + ADC10PDIV_0)
48 #define ADC10_A_CLOCKDIVIDER_7 (ADC10DIV_6 + ADC10PDIV_0)
49 #define ADC10_A_CLOCKDIVIDER_8 (ADC10DIV_7 + ADC10PDIV_0)
50 #define ADC10_A_CLOCKDIVIDER_12 (ADC10DIV_2 + ADC10PDIV_1)
51 #define ADC10_A_CLOCKDIVIDER_16 (ADC10DIV_3 + ADC10PDIV_1)
52 #define ADC10_A_CLOCKDIVIDER_20 (ADC10DIV_4 + ADC10PDIV_1)
53 #define ADC10_A_CLOCKDIVIDER_24 (ADC10DIV_5 + ADC10PDIV_1)
54 #define ADC10_A_CLOCKDIVIDER_28 (ADC10DIV_6 + ADC10PDIV_1)
55 #define ADC10_A_CLOCKDIVIDER_32 (ADC10DIV_7 + ADC10PDIV_1)
56 #define ADC10_A_CLOCKDIVIDER_64 (ADC10DIV_0 + ADC10PDIV_2)
57 #define ADC10_A_CLOCKDIVIDER_128 (ADC10DIV_1 + ADC10PDIV_2)
58 #define ADC10_A_CLOCKDIVIDER_192 (ADC10DIV_2 + ADC10PDIV_2)
59 #define ADC10_A_CLOCKDIVIDER_256 (ADC10DIV_3 + ADC10PDIV_2)
60 #define ADC10_A_CLOCKDIVIDER_320 (ADC10DIV_4 + ADC10PDIV_2)
61 #define ADC10_A_CLOCKDIVIDER_384 (ADC10DIV_5 + ADC10PDIV_2)
62 #define ADC10_A_CLOCKDIVIDER_448 (ADC10DIV_6 + ADC10PDIV_2)
63 #define ADC10_A_CLOCKDIVIDER_512 (ADC10DIV_7 + ADC10PDIV_2)
64 
65 //*****************************************************************************
66 //
67 // The following are values that can be passed to the
68 // sampleHoldSignalSourceSelect parameter for functions: ADC10_A_init().
69 //
70 //*****************************************************************************
71 #define ADC10_A_SAMPLEHOLDSOURCE_SC (ADC10SHS_0)
72 #define ADC10_A_SAMPLEHOLDSOURCE_1 (ADC10SHS_1)
73 #define ADC10_A_SAMPLEHOLDSOURCE_2 (ADC10SHS_2)
74 #define ADC10_A_SAMPLEHOLDSOURCE_3 (ADC10SHS_3)
75 
76 //*****************************************************************************
77 //
78 // The following are values that can be passed to the multipleSamplesEnabled
79 // parameter for functions: ADC10_A_setupSamplingTimer().
80 //
81 //*****************************************************************************
82 #define ADC10_A_MULTIPLESAMPLESDISABLE (!(ADC10MSC))
83 #define ADC10_A_MULTIPLESAMPLESENABLE (ADC10MSC)
84 
85 //*****************************************************************************
86 //
87 // The following are values that can be passed to the clockCycleHoldCount
88 // parameter for functions: ADC10_A_setupSamplingTimer().
89 //
90 //*****************************************************************************
91 #define ADC10_A_CYCLEHOLD_4_CYCLES (ADC10SHT_0)
92 #define ADC10_A_CYCLEHOLD_8_CYCLES (ADC10SHT_1)
93 #define ADC10_A_CYCLEHOLD_16_CYCLES (ADC10SHT_2)
94 #define ADC10_A_CYCLEHOLD_32_CYCLES (ADC10SHT_3)
95 #define ADC10_A_CYCLEHOLD_64_CYCLES (ADC10SHT_4)
96 #define ADC10_A_CYCLEHOLD_96_CYCLES (ADC10SHT_5)
97 #define ADC10_A_CYCLEHOLD_128_CYCLES (ADC10SHT_6)
98 #define ADC10_A_CYCLEHOLD_192_CYCLES (ADC10SHT_7)
99 #define ADC10_A_CYCLEHOLD_256_CYCLES (ADC10SHT_8)
100 #define ADC10_A_CYCLEHOLD_384_CYCLES (ADC10SHT_9)
101 #define ADC10_A_CYCLEHOLD_512_CYCLES (ADC10SHT_10)
102 #define ADC10_A_CYCLEHOLD_768_CYCLES (ADC10SHT_11)
103 #define ADC10_A_CYCLEHOLD_1024_CYCLES (ADC10SHT_12)
104 
105 //*****************************************************************************
106 //
107 // The following are values that can be passed to the
108 // positiveRefVoltageSourceSelect parameter for functions:
109 // ADC10_A_configureMemory().
110 //
111 //*****************************************************************************
112 #define ADC10_A_VREFPOS_AVCC (!(ADC10SREF0 + ADC10SREF1))
113 #define ADC10_A_VREFPOS_EXT (ADC10SREF1)
114 #define ADC10_A_VREFPOS_INT (ADC10SREF0)
115 
116 //*****************************************************************************
117 //
118 // The following are values that can be passed to the inputSourceSelect
119 // parameter for functions: ADC10_A_configureMemory().
120 //
121 //*****************************************************************************
122 #define ADC10_A_INPUT_A0 (ADC10INCH_0)
123 #define ADC10_A_INPUT_A1 (ADC10INCH_1)
124 #define ADC10_A_INPUT_A2 (ADC10INCH_2)
125 #define ADC10_A_INPUT_A3 (ADC10INCH_3)
126 #define ADC10_A_INPUT_A4 (ADC10INCH_4)
127 #define ADC10_A_INPUT_A5 (ADC10INCH_5)
128 #define ADC10_A_INPUT_A6 (ADC10INCH_6)
129 #define ADC10_A_INPUT_A7 (ADC10INCH_7)
130 #define ADC10_A_INPUT_A8 (ADC10INCH_8)
131 #define ADC10_A_INPUT_A9 (ADC10INCH_9)
132 #define ADC10_A_INPUT_TEMPSENSOR (ADC10INCH_10)
133 #define ADC10_A_INPUT_BATTERYMONITOR (ADC10INCH_11)
134 #define ADC10_A_INPUT_A12 (ADC10INCH_12)
135 #define ADC10_A_INPUT_A13 (ADC10INCH_13)
136 #define ADC10_A_INPUT_A14 (ADC10INCH_14)
137 #define ADC10_A_INPUT_A15 (ADC10INCH_15)
138 
139 //*****************************************************************************
140 //
141 // The following are values that can be passed to the
142 // negativeRefVoltageSourceSelect parameter for functions:
143 // ADC10_A_configureMemory().
144 //
145 //*****************************************************************************
146 #define ADC10_A_VREFNEG_AVSS (!(ADC10SREF2))
147 #define ADC10_A_VREFNEG_EXT (ADC10SREF2)
148 
149 //*****************************************************************************
150 //
151 // The following are values that can be passed to the interruptMask parameter
152 // for functions: ADC10_A_enableInterrupt(), and ADC10_A_disableInterrupt().
153 //
154 //*****************************************************************************
155 #define ADC10_A_TIMEOVERFLOW_INT (ADC10TOVIE)
156 #define ADC10_A_OVERFLOW_INT (ADC10OVIE)
157 #define ADC10_A_ABOVETHRESHOLD_INT (ADC10HIIE)
158 #define ADC10_A_BELOWTHRESHOLD_INT (ADC10LOIE)
159 #define ADC10_A_INSIDEWINDOW_INT (ADC10INIE)
160 #define ADC10_A_COMPLETED_INT (ADC10IE0)
161 
162 //*****************************************************************************
163 //
164 // The following are values that can be passed to the interruptFlagMask
165 // parameter for functions: ADC10_A_clearInterrupt(), and
166 // ADC10_A_getInterruptStatus().
167 //
168 //*****************************************************************************
169 #define ADC10_A_TIMEOVERFLOW_INTFLAG (ADC10TOVIFG)
170 #define ADC10_A_OVERFLOW_INTFLAG (ADC10OVIFG)
171 #define ADC10_A_ABOVETHRESHOLD_INTFLAG (ADC10HIIFG)
172 #define ADC10_A_BELOWTHRESHOLD_INTFLAG (ADC10LOIFG)
173 #define ADC10_A_INSIDEWINDOW_INTFLAG (ADC10INIFG)
174 #define ADC10_A_COMPLETED_INTFLAG (ADC10IFG0)
175 
176 //*****************************************************************************
177 //
178 // The following are values that can be passed to the
179 // conversionSequenceModeSelect parameter for functions:
180 // ADC10_A_startConversion().
181 //
182 //*****************************************************************************
183 #define ADC10_A_SINGLECHANNEL (ADC10CONSEQ_0)
184 #define ADC10_A_SEQOFCHANNELS (ADC10CONSEQ_1)
185 #define ADC10_A_REPEATED_SINGLECHANNEL (ADC10CONSEQ_2)
186 #define ADC10_A_REPEATED_SEQOFCHANNELS (ADC10CONSEQ_3)
187 
188 //*****************************************************************************
189 //
190 // The following are values that can be passed to the preempt parameter for
191 // functions: ADC10_A_disableConversions().
192 //
193 //*****************************************************************************
194 #define ADC10_A_COMPLETECONVERSION false
195 #define ADC10_A_PREEMPTCONVERSION true
196 
197 //*****************************************************************************
198 //
199 // The following are values that can be passed to the resolutionSelect
200 // parameter for functions: ADC10_A_setResolution().
201 //
202 //*****************************************************************************
203 #define ADC10_A_RESOLUTION_8BIT (!(ADC10RES))
204 #define ADC10_A_RESOLUTION_10BIT (ADC10RES)
205 
206 //*****************************************************************************
207 //
208 // The following are values that can be passed to the invertedSignal parameter
209 // for functions: ADC10_A_setSampleHoldSignalInversion().
210 //
211 //*****************************************************************************
212 #define ADC10_A_NONINVERTEDSIGNAL (!(ADC10ISSH))
213 #define ADC10_A_INVERTEDSIGNAL (ADC10ISSH)
214 
215 //*****************************************************************************
216 //
217 // The following are values that can be passed to the readBackFormat parameter
218 // for functions: ADC10_A_setDataReadBackFormat().
219 //
220 //*****************************************************************************
221 #define ADC10_A_UNSIGNED_BINARY (!(ADC10DF))
222 #define ADC10_A_SIGNED_2SCOMPLEMENT (ADC10DF)
223 
224 //*****************************************************************************
225 //
226 // The following are values that can be passed to the samplingRateSelect
227 // parameter for functions: ADC10_A_setReferenceBufferSamplingRate().
228 //
229 //*****************************************************************************
230 #define ADC10_A_MAXSAMPLINGRATE_200KSPS (!(ADC10SR))
231 #define ADC10_A_MAXSAMPLINGRATE_50KSPS (ADC10SR)
232 
233 //*****************************************************************************
234 //
235 // The following are values that can be passed toThe following are values that
236 // can be returned by the ADC10_A_isBusy() function.
237 //
238 //*****************************************************************************
239 #define ADC10_A_BUSY ADC10BUSY
240 #define ADC10_A_NOTBUSY 0x00
241 
242 //*****************************************************************************
243 //
244 // Prototypes for the APIs.
245 //
246 //*****************************************************************************
247 
248 //*****************************************************************************
249 //
313 //
314 //*****************************************************************************
315 extern bool ADC10_A_init(uint16_t baseAddress,
316  uint16_t sampleHoldSignalSourceSelect,
317  uint8_t clockSourceSelect,
318  uint16_t clockSourceDivider);
319 
320 //*****************************************************************************
321 //
331 //
332 //*****************************************************************************
333 extern void ADC10_A_enable(uint16_t baseAddress);
334 
335 //*****************************************************************************
336 //
346 //
347 //*****************************************************************************
348 extern void ADC10_A_disable(uint16_t baseAddress);
349 
350 //*****************************************************************************
351 //
391 //
392 //*****************************************************************************
393 extern void ADC10_A_setupSamplingTimer(uint16_t baseAddress,
394  uint16_t clockCycleHoldCount,
395  uint16_t multipleSamplesEnabled);
396 
397 //*****************************************************************************
398 //
408 //
409 //*****************************************************************************
410 extern void ADC10_A_disableSamplingTimer(uint16_t baseAddress);
411 
412 //*****************************************************************************
413 //
463 //
464 //*****************************************************************************
465 extern void ADC10_A_configureMemory(uint16_t baseAddress,
466  uint8_t inputSourceSelect,
467  uint8_t positiveRefVoltageSourceSelect,
468  uint8_t negativeRefVoltageSourceSelect);
469 
470 //*****************************************************************************
471 //
498 //
499 //*****************************************************************************
500 extern void ADC10_A_enableInterrupt(uint16_t baseAddress,
501  uint8_t interruptMask);
502 
503 //*****************************************************************************
504 //
531 //
532 //*****************************************************************************
533 extern void ADC10_A_disableInterrupt(uint16_t baseAddress,
534  uint8_t interruptMask);
535 
536 //*****************************************************************************
537 //
566 //
567 //*****************************************************************************
568 extern void ADC10_A_clearInterrupt(uint16_t baseAddress,
569  uint8_t interruptFlagMask);
570 
571 //*****************************************************************************
572 //
597 //
598 //*****************************************************************************
599 extern uint16_t ADC10_A_getInterruptStatus(uint16_t baseAddress,
600  uint8_t interruptFlagMask);
601 
602 //*****************************************************************************
603 //
644 //
645 //*****************************************************************************
646 extern void ADC10_A_startConversion(uint16_t baseAddress,
647  uint8_t conversionSequenceModeSelect);
648 
649 //*****************************************************************************
650 //
678 //
679 //*****************************************************************************
680 extern void ADC10_A_disableConversions(uint16_t baseAddress,
681  bool preempt);
682 
683 //*****************************************************************************
684 //
697 //
698 //*****************************************************************************
699 extern int16_t ADC10_A_getResults(uint16_t baseAddress);
700 
701 //*****************************************************************************
702 //
716 //
717 //*****************************************************************************
718 extern void ADC10_A_setResolution(uint16_t baseAddress,
719  uint8_t resolutionSelect);
720 
721 //*****************************************************************************
722 //
742 //
743 //*****************************************************************************
744 extern void ADC10_A_setSampleHoldSignalInversion(uint16_t baseAddress,
745  uint16_t invertedSignal);
746 
747 //*****************************************************************************
748 //
767 //
768 //*****************************************************************************
769 extern void ADC10_A_setDataReadBackFormat(uint16_t baseAddress,
770  uint16_t readBackFormat);
771 
772 //*****************************************************************************
773 //
783 //
784 //*****************************************************************************
785 extern void ADC10_A_enableReferenceBurst(uint16_t baseAddress);
786 
787 //*****************************************************************************
788 //
797 //
798 //*****************************************************************************
799 extern void ADC10_A_disableReferenceBurst(uint16_t baseAddress);
800 
801 //*****************************************************************************
802 //
817 //
818 //*****************************************************************************
819 extern void ADC10_A_setReferenceBufferSamplingRate(uint16_t baseAddress,
820  uint16_t samplingRateSelect);
821 
822 //*****************************************************************************
823 //
836 //
837 //*****************************************************************************
838 extern void ADC10_A_setWindowComp(uint16_t baseAddress,
839  uint16_t highThreshold,
840  uint16_t lowThreshold);
841 
842 //*****************************************************************************
843 //
852 //
853 //*****************************************************************************
854 extern uint32_t ADC10_A_getMemoryAddressForDMA(uint16_t baseAddress);
855 
856 //*****************************************************************************
857 //
869 //
870 //*****************************************************************************
871 extern uint16_t ADC10_A_isBusy(uint16_t baseAddress);
872 
873 //*****************************************************************************
874 //
875 // Mark the end of the C bindings section for C++ compilers.
876 //
877 //*****************************************************************************
878 #ifdef __cplusplus
879 }
880 #endif
881 
882 #endif
883 #endif // __MSP430WARE_ADC10_A_H__