MSP430 DriverLib for MSP430F5xx_6xx Devices  2.91.13.01
adc10_a.h
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 //
250 //! \brief Initializes the ADC10_A Module.
251 //!
252 //! This function initializes the ADC module to allow for analog-to-digital
253 //! conversions. Specifically this function sets up the sample-and-hold signal
254 //! and clock sources for the ADC core to use for conversions. Upon successful
255 //! completion of the initialization all of the ADC control registers will be
256 //! reset, excluding the memory controls and reference module bits, the given
257 //! parameters will be set, and the ADC core will be turned on (Note, that the
258 //! ADC core only draws power during conversions and remains off when not
259 //! converting).Note that sample/hold signal sources are device dependent. Note
260 //! that if re-initializing the ADC after starting a conversion with the
261 //! startConversion() function, the disableConversion() must be called BEFORE
262 //! this function can be called.
263 //!
264 //! \param baseAddress is the base address of the ADC10_A module.
265 //! \param sampleHoldSignalSourceSelect is the signal that will trigger a
266 //! sample-and-hold for an input signal to be converted. This parameter
267 //! is device specific and sources should be found in the device's
268 //! datasheet
269 //! Valid values are:
270 //! - \b ADC10_A_SAMPLEHOLDSOURCE_SC
271 //! - \b ADC10_A_SAMPLEHOLDSOURCE_1
272 //! - \b ADC10_A_SAMPLEHOLDSOURCE_2
273 //! - \b ADC10_A_SAMPLEHOLDSOURCE_3
274 //! \n Modified bits are \b ADC10SHSx of \b ADC10CTL1 register.
275 //! \param clockSourceSelect selects the clock that will be used by the ADC10_A
276 //! core and the sampling timer if a sampling pulse mode is enabled.
277 //! Valid values are:
278 //! - \b ADC10_A_CLOCKSOURCE_ADC10OSC [Default] - MODOSC 5 MHz
279 //! oscillator from the UCS
280 //! - \b ADC10_A_CLOCKSOURCE_ACLK - The Auxiliary Clock
281 //! - \b ADC10_A_CLOCKSOURCE_MCLK - The Master Clock
282 //! - \b ADC10_A_CLOCKSOURCE_SMCLK - The Sub-Master Clock
283 //! \n Modified bits are \b ADC10SSELx of \b ADC10CTL1 register.
284 //! \param clockSourceDivider selects the amount that the clock will be
285 //! divided.
286 //! Valid values are:
287 //! - \b ADC10_A_CLOCKDIVIDER_1 [Default]
288 //! - \b ADC10_A_CLOCKDIVIDER_2
289 //! - \b ADC10_A_CLOCKDIVIDER_3
290 //! - \b ADC10_A_CLOCKDIVIDER_4
291 //! - \b ADC10_A_CLOCKDIVIDER_5
292 //! - \b ADC10_A_CLOCKDIVIDER_6
293 //! - \b ADC10_A_CLOCKDIVIDER_7
294 //! - \b ADC10_A_CLOCKDIVIDER_8
295 //! - \b ADC10_A_CLOCKDIVIDER_12
296 //! - \b ADC10_A_CLOCKDIVIDER_16
297 //! - \b ADC10_A_CLOCKDIVIDER_20
298 //! - \b ADC10_A_CLOCKDIVIDER_24
299 //! - \b ADC10_A_CLOCKDIVIDER_28
300 //! - \b ADC10_A_CLOCKDIVIDER_32
301 //! - \b ADC10_A_CLOCKDIVIDER_64
302 //! - \b ADC10_A_CLOCKDIVIDER_128
303 //! - \b ADC10_A_CLOCKDIVIDER_192
304 //! - \b ADC10_A_CLOCKDIVIDER_256
305 //! - \b ADC10_A_CLOCKDIVIDER_320
306 //! - \b ADC10_A_CLOCKDIVIDER_384
307 //! - \b ADC10_A_CLOCKDIVIDER_448
308 //! - \b ADC10_A_CLOCKDIVIDER_512
309 //! \n Modified bits are \b ADC10DIVx of \b ADC10CTL1 register; bits \b
310 //! ADC10PDIVx of \b ADC10CTL2 register.
311 //!
312 //! \return STATUS_SUCCESS or STATUS_FAILURE of the initialization process.
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 //
322 //! \brief Enables the ADC10_A block.
323 //!
324 //! This will enable operation of the ADC10_A block.
325 //!
326 //! \param baseAddress is the base address of the ADC10_A module.
327 //!
328 //! Modified bits are \b ADC10ON of \b ADC10CTL0 register.
329 //!
330 //! \return None
331 //
332 //*****************************************************************************
333 extern void ADC10_A_enable(uint16_t baseAddress);
334 
335 //*****************************************************************************
336 //
337 //! \brief Disables the ADC10_A block.
338 //!
339 //! This will disable operation of the ADC10_A block.
340 //!
341 //! \param baseAddress is the base address of the ADC10_A module.
342 //!
343 //! Modified bits are \b ADC10ON of \b ADC10CTL0 register.
344 //!
345 //! \return None
346 //
347 //*****************************************************************************
348 extern void ADC10_A_disable(uint16_t baseAddress);
349 
350 //*****************************************************************************
351 //
352 //! \brief Sets up and enables the Sampling Timer Pulse Mode.
353 //!
354 //! This function sets up the sampling timer pulse mode which allows the
355 //! sample/hold signal to trigger a sampling timer to sample-and-hold an input
356 //! signal for a specified number of clock cycles without having to hold the
357 //! sample/hold signal for the entire period of sampling. Note that if a
358 //! conversion has been started with the startConversion() function, then a
359 //! call to disableConversions() is required before this function may be
360 //! called.
361 //!
362 //! \param baseAddress is the base address of the ADC10_A module.
363 //! \param clockCycleHoldCount sets the amount of clock cycles to sample-and-
364 //! hold for the memory buffer.
365 //! Valid values are:
366 //! - \b ADC10_A_CYCLEHOLD_4_CYCLES [Default]
367 //! - \b ADC10_A_CYCLEHOLD_8_CYCLES
368 //! - \b ADC10_A_CYCLEHOLD_16_CYCLES
369 //! - \b ADC10_A_CYCLEHOLD_32_CYCLES
370 //! - \b ADC10_A_CYCLEHOLD_64_CYCLES
371 //! - \b ADC10_A_CYCLEHOLD_96_CYCLES
372 //! - \b ADC10_A_CYCLEHOLD_128_CYCLES
373 //! - \b ADC10_A_CYCLEHOLD_192_CYCLES
374 //! - \b ADC10_A_CYCLEHOLD_256_CYCLES
375 //! - \b ADC10_A_CYCLEHOLD_384_CYCLES
376 //! - \b ADC10_A_CYCLEHOLD_512_CYCLES
377 //! - \b ADC10_A_CYCLEHOLD_768_CYCLES
378 //! - \b ADC10_A_CYCLEHOLD_1024_CYCLES
379 //! \n Modified bits are \b ADC10SHTx of \b ADC10CTL0 register.
380 //! \param multipleSamplesEnabled allows multiple conversions to start without
381 //! a trigger signal from the sample/hold signal
382 //! Valid values are:
383 //! - \b ADC10_A_MULTIPLESAMPLESDISABLE - a timer trigger will be needed
384 //! to start every ADC conversion.
385 //! - \b ADC10_A_MULTIPLESAMPLESENABLE - during a sequenced and/or
386 //! repeated conversion mode, after the first conversion, no
387 //! sample/hold signal is necessary to start subsequent samples.
388 //! \n Modified bits are \b ADC10MSC of \b ADC10CTL0 register.
389 //!
390 //! \return None
391 //
392 //*****************************************************************************
393 extern void ADC10_A_setupSamplingTimer(uint16_t baseAddress,
394  uint16_t clockCycleHoldCount,
395  uint16_t multipleSamplesEnabled);
396 
397 //*****************************************************************************
398 //
399 //! \brief Disables Sampling Timer Pulse Mode.
400 //!
401 //! Disables the Sampling Timer Pulse Mode. Note that if a conversion has been
402 //! started with the startConversion() function, then a call to
403 //! disableConversions() is required before this function may be called.
404 //!
405 //! \param baseAddress is the base address of the ADC10_A module.
406 //!
407 //! \return None
408 //
409 //*****************************************************************************
410 extern void ADC10_A_disableSamplingTimer(uint16_t baseAddress);
411 
412 //*****************************************************************************
413 //
414 //! \brief Configures the controls of the selected memory buffer.
415 //!
416 //! Maps an input signal conversion into the memory buffer, as well as the
417 //! positive and negative reference voltages for each conversion being stored
418 //! into the memory buffer. If the internal reference is used for the positive
419 //! reference voltage, the internal REF module has to control the voltage
420 //! level. Note that if a conversion has been started with the
421 //! startConversion() function, then a call to disableConversions() is required
422 //! before this function may be called. If conversion is not disabled, this
423 //! function does nothing.
424 //!
425 //! \param baseAddress is the base address of the ADC10_A module.
426 //! \param inputSourceSelect is the input that will store the converted data
427 //! into the specified memory buffer.
428 //! Valid values are:
429 //! - \b ADC10_A_INPUT_A0 [Default]
430 //! - \b ADC10_A_INPUT_A1
431 //! - \b ADC10_A_INPUT_A2
432 //! - \b ADC10_A_INPUT_A3
433 //! - \b ADC10_A_INPUT_A4
434 //! - \b ADC10_A_INPUT_A5
435 //! - \b ADC10_A_INPUT_A6
436 //! - \b ADC10_A_INPUT_A7
437 //! - \b ADC10_A_INPUT_A8
438 //! - \b ADC10_A_INPUT_A9
439 //! - \b ADC10_A_INPUT_TEMPSENSOR
440 //! - \b ADC10_A_INPUT_BATTERYMONITOR
441 //! - \b ADC10_A_INPUT_A12
442 //! - \b ADC10_A_INPUT_A13
443 //! - \b ADC10_A_INPUT_A14
444 //! - \b ADC10_A_INPUT_A15
445 //! \n Modified bits are \b ADC10INCHx of \b ADC10MCTL0 register.
446 //! \param positiveRefVoltageSourceSelect is the reference voltage source to
447 //! set as the upper limit for the conversion that is to be stored in
448 //! the specified memory buffer.
449 //! Valid values are:
450 //! - \b ADC10_A_VREFPOS_AVCC [Default]
451 //! - \b ADC10_A_VREFPOS_EXT
452 //! - \b ADC10_A_VREFPOS_INT
453 //! \n Modified bits are \b ADC10SREF of \b ADC10MCTL0 register.
454 //! \param negativeRefVoltageSourceSelect is the reference voltage source to
455 //! set as the lower limit for the conversion that is to be stored in
456 //! the specified memory buffer.
457 //! Valid values are:
458 //! - \b ADC10_A_VREFNEG_AVSS
459 //! - \b ADC10_A_VREFNEG_EXT
460 //! \n Modified bits are \b ADC10SREF of \b ADC10CTL0 register.
461 //!
462 //! \return None
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 //
472 //! \brief Enables selected ADC10_A interrupt sources.
473 //!
474 //! Enables the indicated ADC10_A interrupt sources. Only the sources that are
475 //! enabled can be reflected to the processor interrupt; disabled sources have
476 //! no effect on the processor. Does not clear interrupt flags.
477 //!
478 //! \param baseAddress is the base address of the ADC10_A module.
479 //! \param interruptMask is the bit mask of the memory buffer interrupt sources
480 //! to be enabled.
481 //! Mask value is the logical OR of any of the following:
482 //! - \b ADC10_A_TIMEOVERFLOW_INT - Interrupts when a new conversion is
483 //! starting before the previous one has finished
484 //! - \b ADC10_A_OVERFLOW_INT - Interrupts when a new conversion is
485 //! about to overwrite the previous one
486 //! - \b ADC10_A_ABOVETHRESHOLD_INT - Interrupts when the input signal
487 //! has gone above the high threshold of the window comparator
488 //! - \b ADC10_A_BELOWTHRESHOLD_INT - Interrupts when the input signal
489 //! has gone below the low threshold of the low window comparator
490 //! - \b ADC10_A_INSIDEWINDOW_INT - Interrupts when the input signal is
491 //! in between the high and low thresholds of the window comparator
492 //! - \b ADC10_A_COMPLETED_INT - Interrupt for new conversion data in
493 //! the memory buffer
494 //!
495 //! Modified bits of \b ADC10IE register.
496 //!
497 //! \return None
498 //
499 //*****************************************************************************
500 extern void ADC10_A_enableInterrupt(uint16_t baseAddress,
501  uint8_t interruptMask);
502 
503 //*****************************************************************************
504 //
505 //! \brief Disables selected ADC10_A interrupt sources.
506 //!
507 //! Disables the indicated ADC10_A interrupt sources. Only the sources that are
508 //! enabled can be reflected to the processor interrupt; disabled sources have
509 //! no effect on the processor.
510 //!
511 //! \param baseAddress is the base address of the ADC10_A module.
512 //! \param interruptMask is the bit mask of the memory buffer interrupt sources
513 //! to be disabled.
514 //! Mask value is the logical OR of any of the following:
515 //! - \b ADC10_A_TIMEOVERFLOW_INT - Interrupts when a new conversion is
516 //! starting before the previous one has finished
517 //! - \b ADC10_A_OVERFLOW_INT - Interrupts when a new conversion is
518 //! about to overwrite the previous one
519 //! - \b ADC10_A_ABOVETHRESHOLD_INT - Interrupts when the input signal
520 //! has gone above the high threshold of the window comparator
521 //! - \b ADC10_A_BELOWTHRESHOLD_INT - Interrupts when the input signal
522 //! has gone below the low threshold of the low window comparator
523 //! - \b ADC10_A_INSIDEWINDOW_INT - Interrupts when the input signal is
524 //! in between the high and low thresholds of the window comparator
525 //! - \b ADC10_A_COMPLETED_INT - Interrupt for new conversion data in
526 //! the memory buffer
527 //!
528 //! Modified bits of \b ADC10IE register.
529 //!
530 //! \return None
531 //
532 //*****************************************************************************
533 extern void ADC10_A_disableInterrupt(uint16_t baseAddress,
534  uint8_t interruptMask);
535 
536 //*****************************************************************************
537 //
538 //! \brief Clears ADC10_A selected interrupt flags.
539 //!
540 //! The selected ADC10_A interrupt flags are cleared, so that it no longer
541 //! asserts. The memory buffer interrupt flags are only cleared when the memory
542 //! buffer is accessed.
543 //!
544 //! \param baseAddress is the base address of the ADC10_A module.
545 //! \param interruptFlagMask is a bit mask of the interrupt flags to be
546 //! cleared.
547 //! Mask value is the logical OR of any of the following:
548 //! - \b ADC10_A_TIMEOVERFLOW_INTFLAG - Interrupts flag when a new
549 //! conversion is starting before the previous one has finished
550 //! - \b ADC10_A_OVERFLOW_INTFLAG - Interrupts flag when a new
551 //! conversion is about to overwrite the previous one
552 //! - \b ADC10_A_ABOVETHRESHOLD_INTFLAG - Interrupts flag when the input
553 //! signal has gone above the high threshold of the window comparator
554 //! - \b ADC10_A_BELOWTHRESHOLD_INTFLAG - Interrupts flag when the input
555 //! signal has gone below the low threshold of the low window
556 //! comparator
557 //! - \b ADC10_A_INSIDEWINDOW_INTFLAG - Interrupts flag when the input
558 //! signal is in between the high and low thresholds of the window
559 //! comparator
560 //! - \b ADC10_A_COMPLETED_INTFLAG - Interrupt flag for new conversion
561 //! data in the memory buffer
562 //!
563 //! Modified bits of \b ADC10IFG register.
564 //!
565 //! \return None
566 //
567 //*****************************************************************************
568 extern void ADC10_A_clearInterrupt(uint16_t baseAddress,
569  uint8_t interruptFlagMask);
570 
571 //*****************************************************************************
572 //
573 //! \brief Returns the status of the selected memory interrupt flags.
574 //!
575 //! Returns the status of the selected interrupt flags.
576 //!
577 //! \param baseAddress is the base address of the ADC10_A module.
578 //! \param interruptFlagMask is a bit mask of the interrupt flags status to be
579 //! returned.
580 //! Mask value is the logical OR of any of the following:
581 //! - \b ADC10_A_TIMEOVERFLOW_INTFLAG - Interrupts flag when a new
582 //! conversion is starting before the previous one has finished
583 //! - \b ADC10_A_OVERFLOW_INTFLAG - Interrupts flag when a new
584 //! conversion is about to overwrite the previous one
585 //! - \b ADC10_A_ABOVETHRESHOLD_INTFLAG - Interrupts flag when the input
586 //! signal has gone above the high threshold of the window comparator
587 //! - \b ADC10_A_BELOWTHRESHOLD_INTFLAG - Interrupts flag when the input
588 //! signal has gone below the low threshold of the low window
589 //! comparator
590 //! - \b ADC10_A_INSIDEWINDOW_INTFLAG - Interrupts flag when the input
591 //! signal is in between the high and low thresholds of the window
592 //! comparator
593 //! - \b ADC10_A_COMPLETED_INTFLAG - Interrupt flag for new conversion
594 //! data in the memory buffer
595 //!
596 //! \return The current interrupt flag status for the corresponding mask.
597 //
598 //*****************************************************************************
599 extern uint16_t ADC10_A_getInterruptStatus(uint16_t baseAddress,
600  uint8_t interruptFlagMask);
601 
602 //*****************************************************************************
603 //
604 //! \brief Enables/Starts an Analog-to-Digital Conversion.
605 //!
606 //! This function enables/starts the conversion process of the ADC. If the
607 //! sample/hold signal source chosen during initialization was ADC10OSC, then
608 //! the conversion is started immediately, otherwise the chosen sample/hold
609 //! signal source starts the conversion by a rising edge of the signal. Keep in
610 //! mind when selecting conversion modes, that for sequenced and/or repeated
611 //! modes, to keep the sample/hold-and-convert process continuing without a
612 //! trigger from the sample/hold signal source, the multiple samples must be
613 //! enabled using the ADC10_A_setupSamplingTimer() function. Also note that
614 //! when a sequence conversion mode is selected, the first input channel is the
615 //! one mapped to the memory buffer, the next input channel selected for
616 //! conversion is one less than the input channel just converted (i.e. A1 comes
617 //! after A2), until A0 is reached, and if in repeating mode, then the next
618 //! input channel will again be the one mapped to the memory buffer. Note that
619 //! after this function is called, the ADC10_A_stopConversions() has to be
620 //! called to re-initialize the ADC, reconfigure a memory buffer control,
621 //! enable/disable the sampling timer, or to change the internal reference
622 //! voltage.
623 //!
624 //! \param baseAddress is the base address of the ADC10_A module.
625 //! \param conversionSequenceModeSelect determines the ADC operating mode.
626 //! Valid values are:
627 //! - \b ADC10_A_SINGLECHANNEL [Default] - one-time conversion of a
628 //! single channel into a single memory buffer
629 //! - \b ADC10_A_SEQOFCHANNELS - one time conversion of multiple
630 //! channels into the specified starting memory buffer and each
631 //! subsequent memory buffer up until the conversion is stored in a
632 //! memory buffer dedicated as the end-of-sequence by the memory's
633 //! control register
634 //! - \b ADC10_A_REPEATED_SINGLECHANNEL - repeated conversions of one
635 //! channel into a single memory buffer
636 //! - \b ADC10_A_REPEATED_SEQOFCHANNELS - repeated conversions of
637 //! multiple channels into the specified starting memory buffer and
638 //! each subsequent memory buffer up until the conversion is stored
639 //! in a memory buffer dedicated as the end-of-sequence by the
640 //! memory's control register
641 //! \n Modified bits are \b ADC10CONSEQx of \b ADC10CTL1 register.
642 //!
643 //! \return None
644 //
645 //*****************************************************************************
646 extern void ADC10_A_startConversion(uint16_t baseAddress,
647  uint8_t conversionSequenceModeSelect);
648 
649 //*****************************************************************************
650 //
651 //! \brief Disables the ADC from converting any more signals.
652 //!
653 //! Disables the ADC from converting any more signals. If there is a conversion
654 //! in progress, this function can stop it immediately if the preempt parameter
655 //! is set as ADC10_A_PREEMPTCONVERSION, by changing the conversion mode to
656 //! single-channel, single-conversion and disabling conversions. If the
657 //! conversion mode is set as single-channel, single-conversion and this
658 //! function is called without preemption, then the ADC core conversion status
659 //! is polled until the conversion is complete before disabling conversions to
660 //! prevent unpredictable data. If the ADC10_A_startConversion() has been
661 //! called, then this function has to be called to re-initialize the ADC,
662 //! reconfigure a memory buffer control, enable/disable the sampling pulse
663 //! mode, or change the internal reference voltage.
664 //!
665 //! \param baseAddress is the base address of the ADC10_A module.
666 //! \param preempt specifies if the current conversion should be pre-empted
667 //! before the end of the conversion
668 //! Valid values are:
669 //! - \b ADC10_A_COMPLETECONVERSION - Allows the ADC10_A to end the
670 //! current conversion before disabling conversions.
671 //! - \b ADC10_A_PREEMPTCONVERSION - Stops the ADC10_A immediately, with
672 //! unpredictable results of the current conversion. Cannot be used
673 //! with repeated conversion.
674 //!
675 //! Modified bits of \b ADC10CTL1 register and bits of \b ADC10CTL0 register.
676 //!
677 //! \return None
678 //
679 //*****************************************************************************
680 extern void ADC10_A_disableConversions(uint16_t baseAddress,
681  bool preempt);
682 
683 //*****************************************************************************
684 //
685 //! \brief Returns the raw contents of the specified memory buffer.
686 //!
687 //! Returns the raw contents of the specified memory buffer. The format of the
688 //! content depends on the read-back format of the data: if the data is in
689 //! signed 2's complement format then the contents in the memory buffer will be
690 //! left-justified with the least-significant bits as 0's, whereas if the data
691 //! is in unsigned format then the contents in the memory buffer will be right-
692 //! justified with the most-significant bits as 0's.
693 //!
694 //! \param baseAddress is the base address of the ADC10_A module.
695 //!
696 //! \return A Signed Integer of the contents of the specified memory buffer.
697 //
698 //*****************************************************************************
699 extern int16_t ADC10_A_getResults(uint16_t baseAddress);
700 
701 //*****************************************************************************
702 //
703 //! \brief Use to change the resolution of the converted data.
704 //!
705 //! This function can be used to change the resolution of the converted data
706 //! from the default of 12-bits.
707 //!
708 //! \param baseAddress is the base address of the ADC10_A module.
709 //! \param resolutionSelect determines the resolution of the converted data.
710 //! Valid values are:
711 //! - \b ADC10_A_RESOLUTION_8BIT
712 //! - \b ADC10_A_RESOLUTION_10BIT [Default]
713 //! \n Modified bits are \b ADC10RES of \b ADC10CTL2 register.
714 //!
715 //! \return None
716 //
717 //*****************************************************************************
718 extern void ADC10_A_setResolution(uint16_t baseAddress,
719  uint8_t resolutionSelect);
720 
721 //*****************************************************************************
722 //
723 //! \brief Use to invert or un-invert the sample/hold signal
724 //!
725 //! This function can be used to invert or un-invert the sample/hold signal.
726 //! Note that if a conversion has been started with the startConversion()
727 //! function, then a call to disableConversions() is required before this
728 //! function may be called.
729 //!
730 //! \param baseAddress is the base address of the ADC10_A module.
731 //! \param invertedSignal set if the sample/hold signal should be inverted
732 //! Valid values are:
733 //! - \b ADC10_A_NONINVERTEDSIGNAL [Default] - a sample-and-hold of an
734 //! input signal for conversion will be started on a rising edge of
735 //! the sample/hold signal.
736 //! - \b ADC10_A_INVERTEDSIGNAL - a sample-and-hold of an input signal
737 //! for conversion will be started on a falling edge of the
738 //! sample/hold signal.
739 //! \n Modified bits are \b ADC10ISSH of \b ADC10CTL1 register.
740 //!
741 //! \return None
742 //
743 //*****************************************************************************
744 extern void ADC10_A_setSampleHoldSignalInversion(uint16_t baseAddress,
745  uint16_t invertedSignal);
746 
747 //*****************************************************************************
748 //
749 //! \brief Use to set the read-back format of the converted data
750 //!
751 //! Sets the format of the converted data: how it will be stored into the
752 //! memory buffer, and how it should be read back. The format can be set as
753 //! right-justified (default), which indicates that the number will be
754 //! unsigned, or left-justified, which indicates that the number will be signed
755 //! in 2's complement format. This change affects all memory buffers for
756 //! subsequent conversions.
757 //!
758 //! \param baseAddress is the base address of the ADC10_A module.
759 //! \param readBackFormat is the specified format to store the conversions in
760 //! the memory buffer.
761 //! Valid values are:
762 //! - \b ADC10_A_UNSIGNED_BINARY [Default]
763 //! - \b ADC10_A_SIGNED_2SCOMPLEMENT
764 //! \n Modified bits are \b ADC10DF of \b ADC10CTL2 register.
765 //!
766 //! \return None
767 //
768 //*****************************************************************************
769 extern void ADC10_A_setDataReadBackFormat(uint16_t baseAddress,
770  uint16_t readBackFormat);
771 
772 //*****************************************************************************
773 //
774 //! \brief Enables the reference buffer's burst ability.
775 //!
776 //! Enables the reference buffer's burst ability, allowing the reference buffer
777 //! to turn off while the ADC is not converting, and automatically turning on
778 //! when the ADC needs the generated reference voltage for a conversion.
779 //!
780 //! \param baseAddress is the base address of the ADC10_A module.
781 //!
782 //! \return None
783 //
784 //*****************************************************************************
785 extern void ADC10_A_enableReferenceBurst(uint16_t baseAddress);
786 
787 //*****************************************************************************
788 //
789 //! \brief Disables the reference buffer's burst ability.
790 //!
791 //! Disables the reference buffer's burst ability, forcing the reference buffer
792 //! to remain on continuously.
793 //!
794 //! \param baseAddress is the base address of the ADC10_A module.
795 //!
796 //! \return None
797 //
798 //*****************************************************************************
799 extern void ADC10_A_disableReferenceBurst(uint16_t baseAddress);
800 
801 //*****************************************************************************
802 //
803 //! \brief Use to set the reference buffer's sampling rate.
804 //!
805 //! Sets the reference buffer's sampling rate to the selected sampling rate.
806 //! The default sampling rate is maximum of 200-ksps, and can be reduced to a
807 //! maximum of 50-ksps to conserve power.
808 //!
809 //! \param baseAddress is the base address of the ADC10_A module.
810 //! \param samplingRateSelect is the specified maximum sampling rate.
811 //! Valid values are:
812 //! - \b ADC10_A_MAXSAMPLINGRATE_200KSPS [Default]
813 //! - \b ADC10_A_MAXSAMPLINGRATE_50KSPS
814 //! \n Modified bits are \b ADC10SR of \b ADC10CTL2 register.
815 //!
816 //! \return None
817 //
818 //*****************************************************************************
819 extern void ADC10_A_setReferenceBufferSamplingRate(uint16_t baseAddress,
820  uint16_t samplingRateSelect);
821 
822 //*****************************************************************************
823 //
824 //! \brief Sets the high and low threshold for the window comparator feature.
825 //!
826 //! Sets the high and low threshold for the window comparator feature. Use the
827 //! ADC10HIIE, ADC10INIE, ADC10LOIE interrupts to utilize this feature.
828 //!
829 //! \param baseAddress is the base address of the ADC10_A module.
830 //! \param highThreshold is the upper bound that could trip an interrupt for
831 //! the window comparator.
832 //! \param lowThreshold is the lower bound that could trip on interrupt for the
833 //! window comparator.
834 //!
835 //! \return None
836 //
837 //*****************************************************************************
838 extern void ADC10_A_setWindowComp(uint16_t baseAddress,
839  uint16_t highThreshold,
840  uint16_t lowThreshold);
841 
842 //*****************************************************************************
843 //
844 //! \brief Returns the address of the memory buffer for the DMA module.
845 //!
846 //! Returns the address of the memory buffer. This can be used in conjunction
847 //! with the DMA to store the converted data directly to memory.
848 //!
849 //! \param baseAddress is the base address of the ADC10_A module.
850 //!
851 //! \return The memory address of the memory buffer
852 //
853 //*****************************************************************************
854 extern uint32_t ADC10_A_getMemoryAddressForDMA(uint16_t baseAddress);
855 
856 //*****************************************************************************
857 //
858 //! \brief Returns the busy status of the ADC10_A core.
859 //!
860 //! Returns the status of the ADC core if there is a conversion currently
861 //! taking place.
862 //!
863 //! \param baseAddress is the base address of the ADC10_A module.
864 //!
865 //! \return One of the following:
866 //! - \b ADC10_A_BUSY
867 //! - \b ADC10_A_NOTBUSY
868 //! \n indicating if there is a conversion currently taking place
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__
void ADC10_A_disableInterrupt(uint16_t baseAddress, uint8_t interruptMask)
Disables selected ADC10_A interrupt sources.
Definition: adc10_a.c:101
void ADC10_A_disable(uint16_t baseAddress)
Disables the ADC10_A block.
Definition: adc10_a.c:51
void ADC10_A_setupSamplingTimer(uint16_t baseAddress, uint16_t clockCycleHoldCount, uint16_t multipleSamplesEnabled)
Sets up and enables the Sampling Timer Pulse Mode.
Definition: adc10_a.c:57
void ADC10_A_enable(uint16_t baseAddress)
Enables the ADC10_A block.
Definition: adc10_a.c:45
void ADC10_A_clearInterrupt(uint16_t baseAddress, uint8_t interruptFlagMask)
Clears ADC10_A selected interrupt flags.
Definition: adc10_a.c:107
void ADC10_A_disableConversions(uint16_t baseAddress, bool preempt)
Disables the ADC from converting any more signals.
Definition: adc10_a.c:129
void ADC10_A_enableInterrupt(uint16_t baseAddress, uint8_t interruptMask)
Enables selected ADC10_A interrupt sources.
Definition: adc10_a.c:95
void ADC10_A_setWindowComp(uint16_t baseAddress, uint16_t highThreshold, uint16_t lowThreshold)
Sets the high and low threshold for the window comparator feature.
Definition: adc10_a.c:186
void ADC10_A_enableReferenceBurst(uint16_t baseAddress)
Enables the reference buffer's burst ability.
Definition: adc10_a.c:169
void ADC10_A_disableReferenceBurst(uint16_t baseAddress)
Disables the reference buffer's burst ability.
Definition: adc10_a.c:174
void ADC10_A_setSampleHoldSignalInversion(uint16_t baseAddress, uint16_t invertedSignal)
Use to invert or un-invert the sample/hold signal.
Definition: adc10_a.c:155
uint16_t ADC10_A_getInterruptStatus(uint16_t baseAddress, uint8_t interruptFlagMask)
Returns the status of the selected memory interrupt flags.
Definition: adc10_a.c:113
uint16_t ADC10_A_isBusy(uint16_t baseAddress)
Returns the busy status of the ADC10_A core.
Definition: adc10_a.c:199
void ADC10_A_configureMemory(uint16_t baseAddress, uint8_t inputSourceSelect, uint8_t positiveRefVoltageSourceSelect, uint8_t negativeRefVoltageSourceSelect)
Configures the controls of the selected memory buffer.
Definition: adc10_a.c:74
void ADC10_A_setReferenceBufferSamplingRate(uint16_t baseAddress, uint16_t samplingRateSelect)
Use to set the reference buffer's sampling rate.
Definition: adc10_a.c:179
void ADC10_A_setDataReadBackFormat(uint16_t baseAddress, uint16_t readBackFormat)
Use to set the read-back format of the converted data.
Definition: adc10_a.c:162
void ADC10_A_startConversion(uint16_t baseAddress, uint8_t conversionSequenceModeSelect)
Enables/Starts an Analog-to-Digital Conversion.
Definition: adc10_a.c:119
void ADC10_A_setResolution(uint16_t baseAddress, uint8_t resolutionSelect)
Use to change the resolution of the converted data.
Definition: adc10_a.c:148
int16_t ADC10_A_getResults(uint16_t baseAddress)
Returns the raw contents of the specified memory buffer.
Definition: adc10_a.c:143
bool ADC10_A_init(uint16_t baseAddress, uint16_t sampleHoldSignalSourceSelect, uint8_t clockSourceSelect, uint16_t clockSourceDivider)
Initializes the ADC10_A Module.
Definition: adc10_a.c:21
uint32_t ADC10_A_getMemoryAddressForDMA(uint16_t baseAddress)
Returns the address of the memory buffer for the DMA module.
Definition: adc10_a.c:194
void ADC10_A_disableSamplingTimer(uint16_t baseAddress)
Disables Sampling Timer Pulse Mode.
Definition: adc10_a.c:69

Copyright 2020, Texas Instruments Incorporated