MSP430 DriverLib for MSP430FR57xx Devices  2.91.13.01
adc10_b.h
1 //*****************************************************************************
2 //
3 // adc10_b.h - Driver for the ADC10_B Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_ADC10_B_H__
8 #define __MSP430WARE_ADC10_B_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_ADC10_B__
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_B_init().
29 //
30 //*****************************************************************************
31 #define ADC10_B_CLOCKSOURCE_ADC10OSC (ADC10SSEL_0)
32 #define ADC10_B_CLOCKSOURCE_ACLK (ADC10SSEL_1)
33 #define ADC10_B_CLOCKSOURCE_MCLK (ADC10SSEL_2)
34 #define ADC10_B_CLOCKSOURCE_SMCLK (ADC10SSEL_3)
35 
36 //*****************************************************************************
37 //
38 // The following are values that can be passed to the clockSourceDivider
39 // parameter for functions: ADC10_B_init().
40 //
41 //*****************************************************************************
42 #define ADC10_B_CLOCKDIVIDER_1 (ADC10DIV_0 + ADC10PDIV_0)
43 #define ADC10_B_CLOCKDIVIDER_2 (ADC10DIV_1 + ADC10PDIV_0)
44 #define ADC10_B_CLOCKDIVIDER_3 (ADC10DIV_2 + ADC10PDIV_0)
45 #define ADC10_B_CLOCKDIVIDER_4 (ADC10DIV_3 + ADC10PDIV_0)
46 #define ADC10_B_CLOCKDIVIDER_5 (ADC10DIV_4 + ADC10PDIV_0)
47 #define ADC10_B_CLOCKDIVIDER_6 (ADC10DIV_5 + ADC10PDIV_0)
48 #define ADC10_B_CLOCKDIVIDER_7 (ADC10DIV_6 + ADC10PDIV_0)
49 #define ADC10_B_CLOCKDIVIDER_8 (ADC10DIV_7 + ADC10PDIV_0)
50 #define ADC10_B_CLOCKDIVIDER_12 (ADC10DIV_2 + ADC10PDIV_1)
51 #define ADC10_B_CLOCKDIVIDER_16 (ADC10DIV_3 + ADC10PDIV_1)
52 #define ADC10_B_CLOCKDIVIDER_20 (ADC10DIV_4 + ADC10PDIV_1)
53 #define ADC10_B_CLOCKDIVIDER_24 (ADC10DIV_5 + ADC10PDIV_1)
54 #define ADC10_B_CLOCKDIVIDER_28 (ADC10DIV_6 + ADC10PDIV_1)
55 #define ADC10_B_CLOCKDIVIDER_32 (ADC10DIV_7 + ADC10PDIV_1)
56 #define ADC10_B_CLOCKDIVIDER_64 (ADC10DIV_0 + ADC10PDIV_2)
57 #define ADC10_B_CLOCKDIVIDER_128 (ADC10DIV_1 + ADC10PDIV_2)
58 #define ADC10_B_CLOCKDIVIDER_192 (ADC10DIV_2 + ADC10PDIV_2)
59 #define ADC10_B_CLOCKDIVIDER_256 (ADC10DIV_3 + ADC10PDIV_2)
60 #define ADC10_B_CLOCKDIVIDER_320 (ADC10DIV_4 + ADC10PDIV_2)
61 #define ADC10_B_CLOCKDIVIDER_384 (ADC10DIV_5 + ADC10PDIV_2)
62 #define ADC10_B_CLOCKDIVIDER_448 (ADC10DIV_6 + ADC10PDIV_2)
63 #define ADC10_B_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_B_init().
69 //
70 //*****************************************************************************
71 #define ADC10_B_SAMPLEHOLDSOURCE_SC (ADC10SHS_0)
72 #define ADC10_B_SAMPLEHOLDSOURCE_1 (ADC10SHS_1)
73 #define ADC10_B_SAMPLEHOLDSOURCE_2 (ADC10SHS_2)
74 #define ADC10_B_SAMPLEHOLDSOURCE_3 (ADC10SHS_3)
75 
76 //*****************************************************************************
77 //
78 // The following are values that can be passed to the multipleSamplesEnabled
79 // parameter for functions: ADC10_B_setupSamplingTimer().
80 //
81 //*****************************************************************************
82 #define ADC10_B_MULTIPLESAMPLESDISABLE (!(ADC10MSC))
83 #define ADC10_B_MULTIPLESAMPLESENABLE (ADC10MSC)
84 
85 //*****************************************************************************
86 //
87 // The following are values that can be passed to the clockCycleHoldCount
88 // parameter for functions: ADC10_B_setupSamplingTimer().
89 //
90 //*****************************************************************************
91 #define ADC10_B_CYCLEHOLD_4_CYCLES (ADC10SHT_0)
92 #define ADC10_B_CYCLEHOLD_8_CYCLES (ADC10SHT_1)
93 #define ADC10_B_CYCLEHOLD_16_CYCLES (ADC10SHT_2)
94 #define ADC10_B_CYCLEHOLD_32_CYCLES (ADC10SHT_3)
95 #define ADC10_B_CYCLEHOLD_64_CYCLES (ADC10SHT_4)
96 #define ADC10_B_CYCLEHOLD_96_CYCLES (ADC10SHT_5)
97 #define ADC10_B_CYCLEHOLD_128_CYCLES (ADC10SHT_6)
98 #define ADC10_B_CYCLEHOLD_192_CYCLES (ADC10SHT_7)
99 #define ADC10_B_CYCLEHOLD_256_CYCLES (ADC10SHT_8)
100 #define ADC10_B_CYCLEHOLD_384_CYCLES (ADC10SHT_9)
101 #define ADC10_B_CYCLEHOLD_512_CYCLES (ADC10SHT_10)
102 #define ADC10_B_CYCLEHOLD_768_CYCLES (ADC10SHT_11)
103 #define ADC10_B_CYCLEHOLD_1024_CYCLES (ADC10SHT_12)
104 
105 //*****************************************************************************
106 //
107 // The following are values that can be passed to the inputSourceSelect
108 // parameter for functions: ADC10_B_configureMemory().
109 //
110 //*****************************************************************************
111 #define ADC10_B_INPUT_A0 (ADC10INCH_0)
112 #define ADC10_B_INPUT_A1 (ADC10INCH_1)
113 #define ADC10_B_INPUT_A2 (ADC10INCH_2)
114 #define ADC10_B_INPUT_A3 (ADC10INCH_3)
115 #define ADC10_B_INPUT_A4 (ADC10INCH_4)
116 #define ADC10_B_INPUT_A5 (ADC10INCH_5)
117 #define ADC10_B_INPUT_A6 (ADC10INCH_6)
118 #define ADC10_B_INPUT_A7 (ADC10INCH_7)
119 #define ADC10_B_INPUT_VEREF_P (ADC10INCH_8)
120 #define ADC10_B_INPUT_VEREF_N (ADC10INCH_9)
121 #define ADC10_B_INPUT_TEMPSENSOR (ADC10INCH_10)
122 #define ADC10_B_INPUT_BATTERYMONITOR (ADC10INCH_11)
123 #define ADC10_B_INPUT_A12 (ADC10INCH_12)
124 #define ADC10_B_INPUT_A13 (ADC10INCH_13)
125 #define ADC10_B_INPUT_A14 (ADC10INCH_14)
126 #define ADC10_B_INPUT_A15 (ADC10INCH_15)
127 
128 //*****************************************************************************
129 //
130 // The following are values that can be passed to the
131 // positiveRefVoltageSourceSelect parameter for functions:
132 // ADC10_B_configureMemory().
133 //
134 //*****************************************************************************
135 #define ADC10_B_VREFPOS_AVCC (!(ADC10SREF0 + ADC10SREF1))
136 #define ADC10_B_VREFPOS_EXT (ADC10SREF1)
137 #define ADC10_B_VREFPOS_INT (ADC10SREF0)
138 
139 //*****************************************************************************
140 //
141 // The following are values that can be passed to the
142 // negativeRefVoltageSourceSelect parameter for functions:
143 // ADC10_B_configureMemory().
144 //
145 //*****************************************************************************
146 #define ADC10_B_VREFNEG_AVSS (!(ADC10SREF2))
147 #define ADC10_B_VREFNEG_EXT (ADC10SREF2)
148 
149 //*****************************************************************************
150 //
151 // The following are values that can be passed to the interruptMask parameter
152 // for functions: ADC10_B_enableInterrupt(), and ADC10_B_disableInterrupt().
153 //
154 //*****************************************************************************
155 #define ADC10_B_OVIE (ADC10OVIE)
156 #define ADC10_B_TOVIE (ADC10TOVIE)
157 #define ADC10_B_HIIE (ADC10HIIE)
158 #define ADC10_B_LOIE (ADC10LOIE)
159 #define ADC10_B_INIE (ADC10INIE)
160 #define ADC10_B_IE0 (ADC10IE0)
161 
162 //*****************************************************************************
163 //
164 // The following are values that can be passed to the interruptFlagMask
165 // parameter for functions: ADC10_B_clearInterrupt(), and
166 // ADC10_B_getInterruptStatus().
167 //
168 //*****************************************************************************
169 #define ADC10_B_OVIFG (ADC10OVIFG)
170 #define ADC10_B_TOVIFG (ADC10TOVIFG)
171 #define ADC10_B_HIIFG (ADC10HIIFG)
172 #define ADC10_B_LOIFG (ADC10LOIFG)
173 #define ADC10_B_INIFG (ADC10INIFG)
174 #define ADC10_B_IFG0 (ADC10IFG0)
175 
176 //*****************************************************************************
177 //
178 // The following are values that can be passed to the
179 // conversionSequenceModeSelect parameter for functions:
180 // ADC10_B_startConversion().
181 //
182 //*****************************************************************************
183 #define ADC10_B_SINGLECHANNEL (ADC10CONSEQ_0)
184 #define ADC10_B_SEQOFCHANNELS (ADC10CONSEQ_1)
185 #define ADC10_B_REPEATED_SINGLECHANNEL (ADC10CONSEQ_2)
186 #define ADC10_B_REPEATED_SEQOFCHANNELS (ADC10CONSEQ_3)
187 
188 //*****************************************************************************
189 //
190 // The following are values that can be passed to the preempt parameter for
191 // functions: ADC10_B_disableConversions().
192 //
193 //*****************************************************************************
194 #define ADC10_B_COMPLETECONVERSION false
195 #define ADC10_B_PREEMPTCONVERSION true
196 
197 //*****************************************************************************
198 //
199 // The following are values that can be passed to the resolutionSelect
200 // parameter for functions: ADC10_B_setResolution().
201 //
202 //*****************************************************************************
203 #define ADC10_B_RESOLUTION_8BIT (!(ADC10RES))
204 #define ADC10_B_RESOLUTION_10BIT (ADC10RES)
205 
206 //*****************************************************************************
207 //
208 // The following are values that can be passed to the invertedSignal parameter
209 // for functions: ADC10_B_setSampleHoldSignalInversion().
210 //
211 //*****************************************************************************
212 #define ADC10_B_NONINVERTEDSIGNAL (!(ADC10ISSH))
213 #define ADC10_B_INVERTEDSIGNAL (ADC10ISSH)
214 
215 //*****************************************************************************
216 //
217 // The following are values that can be passed to the readBackFormat parameter
218 // for functions: ADC10_B_setDataReadBackFormat().
219 //
220 //*****************************************************************************
221 #define ADC10_B_UNSIGNED_BINARY (!(ADC10DF))
222 #define ADC10_B_SIGNED_2SCOMPLEMENT (ADC10DF)
223 
224 //*****************************************************************************
225 //
226 // The following are values that can be passed to the samplingRateSelect
227 // parameter for functions: ADC10_B_setReferenceBufferSamplingRate().
228 //
229 //*****************************************************************************
230 #define ADC10_B_MAXSAMPLINGRATE_200KSPS (!(ADC10SR))
231 #define ADC10_B_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_B_isBusy() function.
237 //
238 //*****************************************************************************
239 #define ADC10_B_NOTBUSY 0x00
240 #define ADC10_B_BUSY (ADC10BUSY)
241 
242 //*****************************************************************************
243 //
244 // Prototypes for the APIs.
245 //
246 //*****************************************************************************
247 
248 //*****************************************************************************
249 //
250 //! \brief Initializes the ADC10B 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 ADC10B 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_B_SAMPLEHOLDSOURCE_SC [Default]
271 //! - \b ADC10_B_SAMPLEHOLDSOURCE_1
272 //! - \b ADC10_B_SAMPLEHOLDSOURCE_2
273 //! - \b ADC10_B_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 ADC10B
276 //! core and the sampling timer if a sampling pulse mode is enabled.
277 //! Valid values are:
278 //! - \b ADC10_B_CLOCKSOURCE_ADC10OSC [Default] - MODOSC 5 MHz
279 //! oscillator from the clock system
280 //! - \b ADC10_B_CLOCKSOURCE_ACLK - The Auxiliary Clock
281 //! - \b ADC10_B_CLOCKSOURCE_MCLK - The Master Clock
282 //! - \b ADC10_B_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_B_CLOCKDIVIDER_1 [Default]
288 //! - \b ADC10_B_CLOCKDIVIDER_2
289 //! - \b ADC10_B_CLOCKDIVIDER_3
290 //! - \b ADC10_B_CLOCKDIVIDER_4
291 //! - \b ADC10_B_CLOCKDIVIDER_5
292 //! - \b ADC10_B_CLOCKDIVIDER_6
293 //! - \b ADC10_B_CLOCKDIVIDER_7
294 //! - \b ADC10_B_CLOCKDIVIDER_8
295 //! - \b ADC10_B_CLOCKDIVIDER_12
296 //! - \b ADC10_B_CLOCKDIVIDER_16
297 //! - \b ADC10_B_CLOCKDIVIDER_20
298 //! - \b ADC10_B_CLOCKDIVIDER_24
299 //! - \b ADC10_B_CLOCKDIVIDER_28
300 //! - \b ADC10_B_CLOCKDIVIDER_32
301 //! - \b ADC10_B_CLOCKDIVIDER_64
302 //! - \b ADC10_B_CLOCKDIVIDER_128
303 //! - \b ADC10_B_CLOCKDIVIDER_192
304 //! - \b ADC10_B_CLOCKDIVIDER_256
305 //! - \b ADC10_B_CLOCKDIVIDER_320
306 //! - \b ADC10_B_CLOCKDIVIDER_384
307 //! - \b ADC10_B_CLOCKDIVIDER_448
308 //! - \b ADC10_B_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_B_init(uint16_t baseAddress,
316  uint16_t sampleHoldSignalSourceSelect,
317  uint8_t clockSourceSelect,
318  uint16_t clockSourceDivider);
319 
320 //*****************************************************************************
321 //
322 //! \brief Enables the ADC10B block.
323 //!
324 //! This will enable operation of the ADC10B block.
325 //!
326 //! \param baseAddress is the base address of the ADC10B module.
327 //!
328 //! Modified bits are \b ADC10ON of \b ADC10CTL0 register.
329 //!
330 //! \return None
331 //
332 //*****************************************************************************
333 extern void ADC10_B_enable(uint16_t baseAddress);
334 
335 //*****************************************************************************
336 //
337 //! \brief Disables the ADC10B block.
338 //!
339 //! This will disable operation of the ADC10B block.
340 //!
341 //! \param baseAddress is the base address of the ADC10B module.
342 //!
343 //! Modified bits are \b ADC10ON of \b ADC10CTL0 register.
344 //!
345 //! \return None
346 //
347 //*****************************************************************************
348 extern void ADC10_B_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 ADC10B 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_B_CYCLEHOLD_4_CYCLES [Default]
367 //! - \b ADC10_B_CYCLEHOLD_8_CYCLES
368 //! - \b ADC10_B_CYCLEHOLD_16_CYCLES
369 //! - \b ADC10_B_CYCLEHOLD_32_CYCLES
370 //! - \b ADC10_B_CYCLEHOLD_64_CYCLES
371 //! - \b ADC10_B_CYCLEHOLD_96_CYCLES
372 //! - \b ADC10_B_CYCLEHOLD_128_CYCLES
373 //! - \b ADC10_B_CYCLEHOLD_192_CYCLES
374 //! - \b ADC10_B_CYCLEHOLD_256_CYCLES
375 //! - \b ADC10_B_CYCLEHOLD_384_CYCLES
376 //! - \b ADC10_B_CYCLEHOLD_512_CYCLES
377 //! - \b ADC10_B_CYCLEHOLD_768_CYCLES
378 //! - \b ADC10_B_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_B_MULTIPLESAMPLESDISABLE - a timer trigger will be needed
384 //! to start every ADC conversion.
385 //! - \b ADC10_B_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_B_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 ADC10B module.
406 //!
407 //! Modified bits are \b ADC10SHP of \b ADC10CTL1 register.
408 //!
409 //! \return None
410 //
411 //*****************************************************************************
412 extern void ADC10_B_disableSamplingTimer(uint16_t baseAddress);
413 
414 //*****************************************************************************
415 //
416 //! \brief Configures the controls of the selected memory buffer.
417 //!
418 //! Maps an input signal conversion into the memory buffer, as well as the
419 //! positive and negative reference voltages for each conversion being stored
420 //! into the memory buffer. If the internal reference is used for the positive
421 //! reference voltage, the internal REF module has to control the voltage
422 //! level. Note that if a conversion has been started with the
423 //! startConversion() function, then a call to disableConversions() is required
424 //! before this function may be called. If conversion is not disabled, this
425 //! function does nothing.
426 //!
427 //! \param baseAddress is the base address of the ADC10B module.
428 //! \param inputSourceSelect is the input that will store the converted data
429 //! into the specified memory buffer.
430 //! Valid values are:
431 //! - \b ADC10_B_INPUT_A0 [Default]
432 //! - \b ADC10_B_INPUT_A1
433 //! - \b ADC10_B_INPUT_A2
434 //! - \b ADC10_B_INPUT_A3
435 //! - \b ADC10_B_INPUT_A4
436 //! - \b ADC10_B_INPUT_A5
437 //! - \b ADC10_B_INPUT_A6
438 //! - \b ADC10_B_INPUT_A7
439 //! - \b ADC10_B_INPUT_VEREF_P
440 //! - \b ADC10_B_INPUT_VEREF_N
441 //! - \b ADC10_B_INPUT_TEMPSENSOR
442 //! - \b ADC10_B_INPUT_BATTERYMONITOR
443 //! - \b ADC10_B_INPUT_A12
444 //! - \b ADC10_B_INPUT_A13
445 //! - \b ADC10_B_INPUT_A14
446 //! - \b ADC10_B_INPUT_A15
447 //! \n Modified bits are \b ADC10INCHx of \b ADC10MCTL0 register.
448 //! \param positiveRefVoltageSourceSelect is the reference voltage source to
449 //! set as the upper limit for the conversion that is to be stored in
450 //! the specified memory buffer.
451 //! Valid values are:
452 //! - \b ADC10_B_VREFPOS_AVCC [Default]
453 //! - \b ADC10_B_VREFPOS_EXT
454 //! - \b ADC10_B_VREFPOS_INT
455 //! \n Modified bits are \b ADC10SREF of \b ADC10MCTL0 register.
456 //! \param negativeRefVoltageSourceSelect is the reference voltage source to
457 //! set as the lower limit for the conversion that is to be stored in
458 //! the specified memory buffer.
459 //! Valid values are:
460 //! - \b ADC10_B_VREFNEG_AVSS [Default]
461 //! - \b ADC10_B_VREFNEG_EXT
462 //! \n Modified bits are \b ADC10SREF of \b ADC10MCTL0 register.
463 //!
464 //! \return None
465 //
466 //*****************************************************************************
467 extern void ADC10_B_configureMemory(uint16_t baseAddress,
468  uint8_t inputSourceSelect,
469  uint8_t positiveRefVoltageSourceSelect,
470  uint8_t negativeRefVoltageSourceSelect);
471 
472 //*****************************************************************************
473 //
474 //! \brief Enables selected ADC10B interrupt sources.
475 //!
476 //! Enables the indicated ADC10B interrupt sources. Only the sources that are
477 //! enabled can be reflected to the processor interrupt; disabled sources have
478 //! no effect on the processor. Does not clear interrupt flags.
479 //!
480 //! \param baseAddress is the base address of the ADC10B module.
481 //! \param interruptMask is the bit mask of the memory buffer interrupt sources
482 //! to be enabled.
483 //! Mask value is the logical OR of any of the following:
484 //! - \b ADC10_B_OVIE - Interrupts when a new conversion is about to
485 //! overwrite the previous one
486 //! - \b ADC10_B_TOVIE - Interrupts when a new conversion is starting
487 //! before the previous one has finished
488 //! - \b ADC10_B_HIIE - Interrupts when the input signal has gone above
489 //! the high threshold of the window comparator
490 //! - \b ADC10_B_LOIE - Interrupts when the input signal has gone below
491 //! the low threshold of the low window comparator
492 //! - \b ADC10_B_INIE - Interrupts when the input signal is in between
493 //! the high and low thresholds of the window comparator
494 //! - \b ADC10_B_IE0 - Interrupt for new conversion data in the memory
495 //! buffer
496 //!
497 //! Modified bits of \b ADC10IE register.
498 //!
499 //! \return None
500 //
501 //*****************************************************************************
502 extern void ADC10_B_enableInterrupt(uint16_t baseAddress,
503  uint8_t interruptMask);
504 
505 //*****************************************************************************
506 //
507 //! \brief Disables selected ADC10B interrupt sources.
508 //!
509 //! Disables the indicated ADC10B interrupt sources. Only the sources that are
510 //! enabled can be reflected to the processor interrupt; disabled sources have
511 //! no effect on the processor.
512 //!
513 //! \param baseAddress is the base address of the ADC10B module.
514 //! \param interruptMask is the bit mask of the memory buffer interrupt sources
515 //! to be disabled.
516 //! Mask value is the logical OR of any of the following:
517 //! - \b ADC10_B_OVIE - Interrupts when a new conversion is about to
518 //! overwrite the previous one
519 //! - \b ADC10_B_TOVIE - Interrupts when a new conversion is starting
520 //! before the previous one has finished
521 //! - \b ADC10_B_HIIE - Interrupts when the input signal has gone above
522 //! the high threshold of the window comparator
523 //! - \b ADC10_B_LOIE - Interrupts when the input signal has gone below
524 //! the low threshold of the low window comparator
525 //! - \b ADC10_B_INIE - Interrupts when the input signal is in between
526 //! the high and low thresholds of the window comparator
527 //! - \b ADC10_B_IE0 - Interrupt for new conversion data in the memory
528 //! buffer
529 //!
530 //! Modified bits of \b ADC10IE register.
531 //!
532 //! \return None
533 //
534 //*****************************************************************************
535 extern void ADC10_B_disableInterrupt(uint16_t baseAddress,
536  uint8_t interruptMask);
537 
538 //*****************************************************************************
539 //
540 //! \brief Clears ADC10B selected interrupt flags.
541 //!
542 //! The selected ADC10B interrupt flags are cleared, so that it no longer
543 //! asserts. The memory buffer interrupt flags are only cleared when the memory
544 //! buffer is accessed.
545 //!
546 //! \param baseAddress is the base address of the ADC10B module.
547 //! \param interruptFlagMask is a bit mask of the interrupt flags to be
548 //! cleared.
549 //! Mask value is the logical OR of any of the following:
550 //! - \b ADC10_B_OVIFG - Interrupt flag for when a new conversion is
551 //! about to overwrite the previous one
552 //! - \b ADC10_B_TOVIFG - Interrupt flag for when a new conversion is
553 //! starting before the previous one has finished
554 //! - \b ADC10_B_HIIFG - Interrupt flag for when the input signal has
555 //! gone above the high threshold of the window comparator
556 //! - \b ADC10_B_LOIFG - Interrupt flag for when the input signal has
557 //! gone below the low threshold of the window comparator
558 //! - \b ADC10_B_INIFG - Interrupt flag for when the input signal is in
559 //! between the high and low thresholds of the window comparator
560 //! - \b ADC10_B_IFG0 - Interrupt flag for new conversion data in the
561 //! memory buffer
562 //!
563 //! Modified bits of \b ADC10IFG register.
564 //!
565 //! \return None
566 //
567 //*****************************************************************************
568 extern void ADC10_B_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 ADC10B 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_B_OVIFG - Interrupt flag for when a new conversion is
582 //! about to overwrite the previous one
583 //! - \b ADC10_B_TOVIFG - Interrupt flag for when a new conversion is
584 //! starting before the previous one has finished
585 //! - \b ADC10_B_HIIFG - Interrupt flag for when the input signal has
586 //! gone above the high threshold of the window comparator
587 //! - \b ADC10_B_LOIFG - Interrupt flag for when the input signal has
588 //! gone below the low threshold of the window comparator
589 //! - \b ADC10_B_INIFG - Interrupt flag for when the input signal is in
590 //! between the high and low thresholds of the window comparator
591 //! - \b ADC10_B_IFG0 - Interrupt flag for new conversion data in the
592 //! memory buffer
593 //!
594 //! Modified bits of \b ADC10IFG register.
595 //!
596 //! \return The current interrupt flag status for the corresponding mask.
597 //
598 //*****************************************************************************
599 extern uint8_t ADC10_B_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
611 //! and/or repeated modes, to keep the sample/hold-and-convert process
612 //! continuing without a trigger from the sample/hold signal source, the
613 //! multiple samples must be enabled using the ADC10_B_setupSamplingTimer()
614 //! function. Also note that when a sequence conversion mode is selected, the
615 //! first input channel is the one mapped to the memory buffer, the next input
616 //! channel selected for conversion is one less than the input channel just
617 //! converted (i.e. A1 comes after A2), until A0 is reached, and if in
618 //! repeating mode, then the next input channel will again be the one mapped to
619 //! the memory buffer. Note that after this function is called, the
620 //! ADC10_B_stopConversions() has to be called to re-initialize the ADC,
621 //! reconfigure a memory buffer control, enable/disable the sampling timer, or
622 //! to change the internal reference voltage.
623 //!
624 //! \param baseAddress is the base address of the ADC10B module.
625 //! \param conversionSequenceModeSelect determines the ADC operating mode.
626 //! Valid values are:
627 //! - \b ADC10_B_SINGLECHANNEL [Default] - one-time conversion of a
628 //! single channel into a single memory buffer
629 //! - \b ADC10_B_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_B_REPEATED_SINGLECHANNEL - repeated conversions of one
635 //! channel into a single memory buffer
636 //! - \b ADC10_B_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_B_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_B_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 ADC10CTL1 and ADC10CTL0
661 //!
662 //! \param baseAddress is the base address of the ADC10B module.
663 //! \param preempt specifies if the current conversion should be pre-empted
664 //! stopped before the end of the conversion
665 //! Valid values are:
666 //! - \b ADC10_B_COMPLETECONVERSION - Allows the ADC10B to end the
667 //! current conversion before disabling conversions.
668 //! - \b ADC10_B_PREEMPTCONVERSION - Stops the ADC10B immediately, with
669 //! unpredicatble results of the current conversion. Cannot be used
670 //! with repeated conversion.
671 //!
672 //! Modified bits of \b ADC10CTL1 register and bits of \b ADC10CTL0 register.
673 //!
674 //! \return None
675 //
676 //*****************************************************************************
677 extern void ADC10_B_disableConversions(uint16_t baseAddress,
678  bool preempt);
679 
680 //*****************************************************************************
681 //
682 //! \brief Returns the raw contents of the specified memory buffer.
683 //!
684 //! Returns the raw contents of the specified memory buffer. The format of the
685 //! content depends on the read-back format of the data: if the data is in
686 //! signed 2's complement format then the contents in the memory buffer will be
687 //! left-justified with the least-significant bits as 0's, whereas if the data
688 //! is in unsigned format then the contents in the memory buffer will be right-
689 //! justified with the most-significant bits as 0's.
690 //!
691 //! \param baseAddress is the base address of the ADC10B module.
692 //!
693 //! \return A Signed Integer of the contents of the specified memory buffer.
694 //
695 //*****************************************************************************
696 extern uint16_t ADC10_B_getResults(uint16_t baseAddress);
697 
698 //*****************************************************************************
699 //
700 //! \brief Use to change the resolution of the converted data.
701 //!
702 //! This function can be used to change the resolution of the converted data
703 //! from the default of 12-bits.
704 //!
705 //! \param baseAddress is the base address of the ADC10B module.
706 //! \param resolutionSelect determines the resolution of the converted data.
707 //! Valid values are:
708 //! - \b ADC10_B_RESOLUTION_8BIT
709 //! - \b ADC10_B_RESOLUTION_10BIT [Default]
710 //! \n Modified bits are \b ADC10RES of \b ADC10CTL2 register.
711 //!
712 //! \return None
713 //
714 //*****************************************************************************
715 extern void ADC10_B_setResolution(uint16_t baseAddress,
716  uint8_t resolutionSelect);
717 
718 //*****************************************************************************
719 //
720 //! \brief Use to invert or un-invert the sample/hold signal
721 //!
722 //! This function can be used to invert or un-invert the sample/hold signal.
723 //! Note that if a conversion has been started with the startConversion()
724 //! function, then a call to disableConversions() is required before this
725 //! function may be called.
726 //!
727 //! \param baseAddress is the base address of the ADC10B module.
728 //! \param invertedSignal set if the sample/hold signal should be inverted
729 //! Valid values are:
730 //! - \b ADC10_B_NONINVERTEDSIGNAL [Default] - a sample-and-hold of an
731 //! input signal for conversion will be started on a rising edge of
732 //! the sample/hold signal.
733 //! - \b ADC10_B_INVERTEDSIGNAL - a sample-and-hold of an input signal
734 //! for conversion will be started on a falling edge of the
735 //! sample/hold signal.
736 //! \n Modified bits are \b ADC10ISSH of \b ADC10CTL1 register.
737 //!
738 //! \return None
739 //
740 //*****************************************************************************
741 extern void ADC10_B_setSampleHoldSignalInversion(uint16_t baseAddress,
742  uint16_t invertedSignal);
743 
744 //*****************************************************************************
745 //
746 //! \brief Use to set the read-back format of the converted data
747 //!
748 //! Sets the format of the converted data: how it will be stored into the
749 //! memory buffer, and how it should be read back. The format can be set as
750 //! right-justified (default), which indicates that the number will be
751 //! unsigned, or left-justified, which indicates that the number will be signed
752 //! in 2's complement format. This change affects all memory buffers for
753 //! subsequent conversions.
754 //!
755 //! \param baseAddress is the base address of the ADC10B module.
756 //! \param readBackFormat is the specified format to store the conversions in
757 //! the memory buffer.
758 //! Valid values are:
759 //! - \b ADC10_B_UNSIGNED_BINARY [Default]
760 //! - \b ADC10_B_SIGNED_2SCOMPLEMENT
761 //! \n Modified bits are \b ADC10DF of \b ADC10CTL2 register.
762 //!
763 //! \return None
764 //
765 //*****************************************************************************
766 extern void ADC10_B_setDataReadBackFormat(uint16_t baseAddress,
767  uint16_t readBackFormat);
768 
769 //*****************************************************************************
770 //
771 //! \brief Enables the reference buffer's burst ability.
772 //!
773 //! Enables the reference buffer's burst ability, allowing the reference buffer
774 //! to turn off while the ADC is not converting, and automatically turning on
775 //! when the ADC needs the generated reference voltage for a conversion.
776 //!
777 //! \param baseAddress is the base address of the ADC10B module.
778 //!
779 //! Modified bits are \b ADC10REFBURST of \b ADC10CTL2 register.
780 //!
781 //! \return None
782 //
783 //*****************************************************************************
784 extern void ADC10_B_enableReferenceBurst(uint16_t baseAddress);
785 
786 //*****************************************************************************
787 //
788 //! \brief Disables the reference buffer's burst ability.
789 //!
790 //! Disables the reference buffer's burst ability, forcing the reference buffer
791 //! to remain on continuously.
792 //!
793 //! \param baseAddress is the base address of the ADC10B module.
794 //!
795 //! Modified bits are \b ADC10REFBURST of \b ADC10CTL2 register.
796 //!
797 //! \return None
798 //
799 //*****************************************************************************
800 extern void ADC10_B_disableReferenceBurst(uint16_t baseAddress);
801 
802 //*****************************************************************************
803 //
804 //! \brief Use to set the reference buffer's sampling rate.
805 //!
806 //! Sets the reference buffer's sampling rate to the selected sampling rate.
807 //! The default sampling rate is maximum of 200-ksps, and can be reduced to a
808 //! maximum of 50-ksps to conserve power.
809 //!
810 //! \param baseAddress is the base address of the ADC10B module.
811 //! \param samplingRateSelect is the specified maximum sampling rate.
812 //! Valid values are:
813 //! - \b ADC10_B_MAXSAMPLINGRATE_200KSPS [Default]
814 //! - \b ADC10_B_MAXSAMPLINGRATE_50KSPS
815 //! \n Modified bits are \b ADC10SR of \b ADC10CTL2 register.
816 //!
817 //! Modified bits of \b ADC10CTL2 register.
818 //!
819 //! \return None
820 //
821 //*****************************************************************************
822 extern void ADC10_B_setReferenceBufferSamplingRate(uint16_t baseAddress,
823  uint16_t samplingRateSelect);
824 
825 //*****************************************************************************
826 //
827 //! \brief Sets the high and low threshold for the window comparator feature.
828 //!
829 //! Sets the high and low threshold for the window comparator feature. Use the
830 //! ADC10HIIE, ADC10INIE, ADC10LOIE interrupts to utilize this feature.
831 //!
832 //! \param baseAddress is the base address of the ADC10B module.
833 //! \param highThreshold is the upper bound that could trip an interrupt for
834 //! the window comparator.
835 //! \param lowThreshold is the lower bound that could trip on interrupt for the
836 //! window comparator.
837 //!
838 //! Modified bits of \b ADC10LO register and bits of \b ADC10HI register.
839 //!
840 //! \return None
841 //
842 //*****************************************************************************
843 extern void ADC10_B_setWindowComp(uint16_t baseAddress,
844  uint16_t highThreshold,
845  uint16_t lowThreshold);
846 
847 //*****************************************************************************
848 //
849 //! \brief Returns the address of the memory buffer for the DMA module.
850 //!
851 //! \param baseAddress is the base address of the ADC10B module.
852 //!
853 //! \return Returns the address of the memory buffer. This can be used in
854 //! conjunction with the DMA to store the converted data directly to
855 //! memory.
856 //
857 //*****************************************************************************
858 extern uint32_t ADC10_B_getMemoryAddressForDMA(uint16_t baseAddress);
859 
860 //*****************************************************************************
861 //
862 //! \brief Returns the busy status of the ADC10B core.
863 //!
864 //! Returns the status of the ADC core if there is a conversion currently
865 //! taking place.
866 //!
867 //! \param baseAddress is the base address of the ADC10B module.
868 //!
869 //! \return ADC10_B_BUSY or ADC10_B_NOTBUSY dependent if there is a conversion
870 //! currently taking place.
871 //! Return one of the following:
872 //! - \b ADC10_B_NOTBUSY
873 //! - \b ADC10_B_BUSY
874 //
875 //*****************************************************************************
876 extern uint8_t ADC10_B_isBusy(uint16_t baseAddress);
877 
878 //*****************************************************************************
879 //
880 // Mark the end of the C bindings section for C++ compilers.
881 //
882 //*****************************************************************************
883 #ifdef __cplusplus
884 }
885 #endif
886 
887 #endif
888 #endif // __MSP430WARE_ADC10_B_H__
uint8_t ADC10_B_isBusy(uint16_t baseAddress)
Returns the busy status of the ADC10B core.
Definition: adc10_b.c:224
void ADC10_B_clearInterrupt(uint16_t baseAddress, uint8_t interruptFlagMask)
Clears ADC10B selected interrupt flags.
Definition: adc10_b.c:121
void ADC10_B_enable(uint16_t baseAddress)
Enables the ADC10B block.
Definition: adc10_b.c:51
void ADC10_B_disableReferenceBurst(uint16_t baseAddress)
Disables the reference buffer's burst ability.
Definition: adc10_b.c:197
void ADC10_B_disableConversions(uint16_t baseAddress, bool preempt)
Disables the ADC from converting any more signals.
Definition: adc10_b.c:145
bool ADC10_B_init(uint16_t baseAddress, uint16_t sampleHoldSignalSourceSelect, uint8_t clockSourceSelect, uint16_t clockSourceDivider)
Initializes the ADC10B Module.
Definition: adc10_b.c:21
void ADC10_B_enableInterrupt(uint16_t baseAddress, uint8_t interruptMask)
Enables selected ADC10B interrupt sources.
Definition: adc10_b.c:109
void ADC10_B_setReferenceBufferSamplingRate(uint16_t baseAddress, uint16_t samplingRateSelect)
Use to set the reference buffer's sampling rate.
Definition: adc10_b.c:202
void ADC10_B_setWindowComp(uint16_t baseAddress, uint16_t highThreshold, uint16_t lowThreshold)
Sets the high and low threshold for the window comparator feature.
Definition: adc10_b.c:211
void ADC10_B_disable(uint16_t baseAddress)
Disables the ADC10B block.
Definition: adc10_b.c:57
void ADC10_B_enableReferenceBurst(uint16_t baseAddress)
Enables the reference buffer's burst ability.
Definition: adc10_b.c:192
void ADC10_B_configureMemory(uint16_t baseAddress, uint8_t inputSourceSelect, uint8_t positiveRefVoltageSourceSelect, uint8_t negativeRefVoltageSourceSelect)
Configures the controls of the selected memory buffer.
Definition: adc10_b.c:88
void ADC10_B_disableInterrupt(uint16_t baseAddress, uint8_t interruptMask)
Disables selected ADC10B interrupt sources.
Definition: adc10_b.c:115
void ADC10_B_setupSamplingTimer(uint16_t baseAddress, uint16_t clockCycleHoldCount, uint16_t multipleSamplesEnabled)
Sets up and enables the Sampling Timer Pulse Mode.
Definition: adc10_b.c:63
void ADC10_B_startConversion(uint16_t baseAddress, uint8_t conversionSequenceModeSelect)
Enables/Starts an Analog-to-Digital Conversion.
Definition: adc10_b.c:133
void ADC10_B_setSampleHoldSignalInversion(uint16_t baseAddress, uint16_t invertedSignal)
Use to invert or un-invert the sample/hold signal.
Definition: adc10_b.c:173
void ADC10_B_setResolution(uint16_t baseAddress, uint8_t resolutionSelect)
Use to change the resolution of the converted data.
Definition: adc10_b.c:164
uint8_t ADC10_B_getInterruptStatus(uint16_t baseAddress, uint8_t interruptFlagMask)
Returns the status of the selected memory interrupt flags.
Definition: adc10_b.c:127
uint16_t ADC10_B_getResults(uint16_t baseAddress)
Returns the raw contents of the specified memory buffer.
Definition: adc10_b.c:159
uint32_t ADC10_B_getMemoryAddressForDMA(uint16_t baseAddress)
Returns the address of the memory buffer for the DMA module.
Definition: adc10_b.c:219
void ADC10_B_setDataReadBackFormat(uint16_t baseAddress, uint16_t readBackFormat)
Use to set the read-back format of the converted data.
Definition: adc10_b.c:183
void ADC10_B_disableSamplingTimer(uint16_t baseAddress)
Disables Sampling Timer Pulse Mode.
Definition: adc10_b.c:80

Copyright 2020, Texas Instruments Incorporated