2 * -------------------------------------------
3 * MSP432 DriverLib - v01_04_00_18
4 * -------------------------------------------
6 * --COPYRIGHT--,BSD,BSD
7 * Copyright (c) 2015, Texas Instruments Incorporated
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * * Neither the name of Texas Instruments Incorporated nor the names of
22 * its contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 //*****************************************************************************
43 //! \addtogroup adc14_api
46 //*****************************************************************************
48 //*****************************************************************************
50 // If building with a C++ compiler, make all of the definitions in this header
53 //*****************************************************************************
63 //*****************************************************************************
65 // Control specific variables
67 //*****************************************************************************
69 //*****************************************************************************
71 //The following are values that can be passed to ADC14_initModule
73 //*****************************************************************************
74 #define ADC_CLOCKSOURCE_ADCOSC (ADC14SSEL_0)
75 #define ADC_CLOCKSOURCE_SYSOSC (ADC14SSEL_1)
76 #define ADC_CLOCKSOURCE_ACLK (ADC14SSEL_2)
77 #define ADC_CLOCKSOURCE_MCLK (ADC14SSEL_3)
78 #define ADC_CLOCKSOURCE_SMCLK (ADC14SSEL_4)
79 #define ADC_CLOCKSOURCE_HSMCLK (ADC14SSEL_5)
81 #define ADC_PREDIVIDER_1 (ADC14PDIV_0)
82 #define ADC_PREDIVIDER_4 (ADC14PDIV_1)
83 #define ADC_PREDIVIDER_32 (ADC14PDIV_2)
84 #define ADC_PREDIVIDER_64 (ADC14PDIV_3)
86 #define ADC_DIVIDER_1 (ADC14DIV_0)
87 #define ADC_DIVIDER_2 (ADC14DIV_1)
88 #define ADC_DIVIDER_3 (ADC14DIV_2)
89 #define ADC_DIVIDER_4 (ADC14DIV_3)
90 #define ADC_DIVIDER_5 (ADC14DIV_4)
91 #define ADC_DIVIDER_6 (ADC14DIV_5)
92 #define ADC_DIVIDER_7 (ADC14DIV_6)
93 #define ADC_DIVIDER_8 (ADC14DIV_7)
95 #define ADC_MAPINTCH3 (ADC14CH3MAP)
96 #define ADC_MAPINTCH2 (ADC14CH2MAP)
97 #define ADC_MAPINTCH1 (ADC14CH1MAP)
98 #define ADC_MAPINTCH0 (ADC14CH0MAP)
99 #define ADC_TEMPSENSEMAP (ADC14TCMAP)
100 #define ADC_BATTMAP (ADC14BATMAP)
101 #define ADC_NOROUTE 0
103 #define ADC_8BIT ADC14RES_0
104 #define ADC_10BIT ADC14RES_1
105 #define ADC_12BIT ADC14RES_2
106 #define ADC_14BIT ADC14RES_3
108 #define ADC_TRIGGER_ADCSC ADC14SHS_0
109 #define ADC_TRIGGER_SOURCE1 ADC14SHS_1
110 #define ADC_TRIGGER_SOURCE2 ADC14SHS_2
111 #define ADC_TRIGGER_SOURCE3 ADC14SHS_3
112 #define ADC_TRIGGER_SOURCE4 ADC14SHS_4
113 #define ADC_TRIGGER_SOURCE5 ADC14SHS_5
114 #define ADC_TRIGGER_SOURCE6 ADC14SHS_6
115 #define ADC_TRIGGER_SOURCE7 ADC14SHS_7
117 #define ADC_PULSE_WIDTH_4 ADC14SHT1_0
118 #define ADC_PULSE_WIDTH_8 ADC14SHT1_1
119 #define ADC_PULSE_WIDTH_16 ADC14SHT1_2
120 #define ADC_PULSE_WIDTH_32 ADC14SHT1_3
121 #define ADC_PULSE_WIDTH_64 ADC14SHT1_4
122 #define ADC_PULSE_WIDTH_96 ADC14SHT1_5
123 #define ADC_PULSE_WIDTH_128 ADC14SHT1_6
124 #define ADC_PULSE_WIDTH_192 ADC14SHT1_7
126 #define ADC_NONDIFFERENTIAL_INPUTS false
127 #define ADC_DIFFERENTIAL_INPUTS true
129 #define ADC_MEM0 0x00000001
130 #define ADC_MEM1 0x00000002
131 #define ADC_MEM2 0x00000004
132 #define ADC_MEM3 0x00000008
133 #define ADC_MEM4 0x00000010
134 #define ADC_MEM5 0x00000020
135 #define ADC_MEM6 0x00000040
136 #define ADC_MEM7 0x00000080
137 #define ADC_MEM8 0x00000100
138 #define ADC_MEM9 0x00000200
139 #define ADC_MEM10 0x00000400
140 #define ADC_MEM11 0x00000800
141 #define ADC_MEM12 0x00001000
142 #define ADC_MEM13 0x00002000
143 #define ADC_MEM14 0x00004000
144 #define ADC_MEM15 0x00008000
145 #define ADC_MEM16 0x00010000
146 #define ADC_MEM17 0x00020000
147 #define ADC_MEM18 0x00040000
148 #define ADC_MEM19 0x00080000
149 #define ADC_MEM20 0x00100000
150 #define ADC_MEM21 0x00200000
151 #define ADC_MEM22 0x00400000
152 #define ADC_MEM23 0x00800000
153 #define ADC_MEM24 0x01000000
154 #define ADC_MEM25 0x02000000
155 #define ADC_MEM26 0x04000000
156 #define ADC_MEM27 0x08000000
157 #define ADC_MEM28 0x10000000
158 #define ADC_MEM29 0x20000000
159 #define ADC_MEM30 0x40000000
160 #define ADC_MEM31 0x80000000
162 #define ADC_VREFPOS_AVCC_VREFNEG_VSS (ADC14VRSEL_0)
163 #define ADC_VREFPOS_INTBUF_VREFNEG_VSS (ADC14VRSEL_1)
164 #define ADC_VREFPOS_EXTPOS_VREFNEG_EXTNEG (ADC14VRSEL_14)
165 #define ADC_VREFPOS_EXTBUF_VREFNEG_EXTNEG (ADC14VRSEL_15)
167 #define ADC_INPUT_A0 (ADC14INCH_0)
168 #define ADC_INPUT_A1 (ADC14INCH_1)
169 #define ADC_INPUT_A2 (ADC14INCH_2)
170 #define ADC_INPUT_A3 (ADC14INCH_3)
171 #define ADC_INPUT_A4 (ADC14INCH_4)
172 #define ADC_INPUT_A5 (ADC14INCH_5)
173 #define ADC_INPUT_A6 (ADC14INCH_6)
174 #define ADC_INPUT_A7 (ADC14INCH_7)
175 #define ADC_INPUT_A8 (ADC14INCH_8)
176 #define ADC_INPUT_A9 (ADC14INCH_9)
177 #define ADC_INPUT_A10 (ADC14INCH_10)
178 #define ADC_INPUT_A11 (ADC14INCH_11)
179 #define ADC_INPUT_A12 (ADC14INCH_12)
180 #define ADC_INPUT_A13 (ADC14INCH_13)
181 #define ADC_INPUT_A14 (ADC14INCH_14)
182 #define ADC_INPUT_A15 (ADC14INCH_15)
183 #define ADC_INPUT_A16 (ADC14INCH_16)
184 #define ADC_INPUT_A17 (ADC14INCH_17)
185 #define ADC_INPUT_A18 (ADC14INCH_18)
186 #define ADC_INPUT_A19 (ADC14INCH_19)
187 #define ADC_INPUT_A20 (ADC14INCH_20)
188 #define ADC_INPUT_A21 (ADC14INCH_21)
189 #define ADC_INPUT_A22 (ADC14INCH_22)
190 #define ADC_INPUT_A23 (ADC14INCH_23)
191 #define ADC_INPUT_A24 (ADC14INCH_24)
192 #define ADC_INPUT_A25 (ADC14INCH_25)
193 #define ADC_INPUT_A26 (ADC14INCH_26)
194 #define ADC_INPUT_A27 (ADC14INCH_27)
195 #define ADC_INPUT_A28 (ADC14INCH_28)
196 #define ADC_INPUT_A29 (ADC14INCH_29)
197 #define ADC_INPUT_A30 (ADC14INCH_30)
198 #define ADC_INPUT_A31 (ADC14INCH_31)
200 #define ADC_COMP_WINDOW0 0x00
201 #define ADC_COMP_WINDOW1 0x01
203 #define ADC_SIGNED_BINARY 0x00
204 #define ADC_UNSIGNED_BINARY 0x01
206 #define ADC_MANUAL_ITERATION 0x00
207 #define ADC_AUTOMATIC_ITERATION ADC14MSC
209 #define ADC_UNRESTRICTED_POWER_MODE ADC14PWRMD_0
210 #define ADC_ULTRA_LOW_POWER_MODE ADC14PWRMD_2
213 #define ADC_INT0 ADC14IE0
214 #define ADC_INT1 ADC14IE1
215 #define ADC_INT2 ADC14IE2
216 #define ADC_INT3 ADC14IE3
217 #define ADC_INT4 ADC14IE4
218 #define ADC_INT5 ADC14IE5
219 #define ADC_INT6 ADC14IE6
220 #define ADC_INT7 ADC14IE7
221 #define ADC_INT8 ADC14IE8
222 #define ADC_INT9 ADC14IE9
223 #define ADC_INT10 ADC14IE10
224 #define ADC_INT11 ADC14IE11
225 #define ADC_INT12 ADC14IE12
226 #define ADC_INT13 ADC14IE13
227 #define ADC_INT14 ADC14IE14
228 #define ADC_INT15 ADC14IE15
229 #define ADC_INT16 ADC14IE16
230 #define ADC_INT17 ADC14IE17
231 #define ADC_INT18 ADC14IE18
232 #define ADC_INT19 ADC14IE19
233 #define ADC_INT20 ADC14IE20
234 #define ADC_INT21 ADC14IE21
235 #define ADC_INT22 ADC14IE22
236 #define ADC_INT23 ADC14IE23
237 #define ADC_INT24 ADC14IE24
238 #define ADC_INT25 ADC14IE25
239 #define ADC_INT26 ADC14IE26
240 #define ADC_INT27 ADC14IE27
241 #define ADC_INT28 ADC14IE28
242 #define ADC_INT29 ADC14IE29
243 #define ADC_INT30 ADC14IE30
244 #define ADC_INT31 ADC14IE31
245 #define ADC_IN_INT 0x0000000200000000
246 #define ADC_LO_INT 0x0000000400000000
247 #define ADC_HI_INT 0x0000000800000000
248 #define ADC_OV_INT 0x0000001000000000
249 #define ADC_TOV_INT 0x0000002000000000
250 #define ADC_RDY_INT 0x0000004000000000
252 #define ADC_INVALID_MEM 32
254 //*****************************************************************************
256 //Prototypes for the APIs.
258 //*****************************************************************************
260 //*****************************************************************************
263 //! Enables the ADC block.
265 //! This will enable operation of the ADC block.
269 //*****************************************************************************
270 extern void ADC14_enableModule(void);
272 //*****************************************************************************
275 //! Disables the ADC block.
277 //! This will disable operation of the ADC block.
279 //! \return false if user is trying to disable during active conversion
281 //*****************************************************************************
282 extern bool ADC14_disableModule(void);
284 //*****************************************************************************
287 //! Initializes the ADC module and sets up the clock system divider/pre-divider.
288 //! This initialization function will also configure the internal/external
291 //! \note A call to this function while active ADC conversion is happening
292 //! is an invalid case and will result in a false value being returned.
294 //! \param clockSource The clock source to use for the ADC module.
295 //! - \b ADC_CLOCKSOURCE_ADCOSC [DEFAULT]
296 //! - \b ADC_CLOCKSOURCE_SYSOSC
297 //! - \b ADC_CLOCKSOURCE_ACLK
298 //! - \b ADC_CLOCKSOURCE_MCLK
299 //! - \b ADC_CLOCKSOURCE_SMCLK
300 //! - \b ADC_CLOCKSOURCE_HSMCLK
302 //! \param clockPredivider Divides the given clock source before feeding it
303 //! into the main clock divider.
304 //! Valid values are:
305 //! - \b ADC_PREDIVIDER_1 [DEFAULT]
306 //! - \b ADC_PREDIVIDER_4
307 //! - \b ADC_PREDIVIDER_32
308 //! - \b ADC_PREDIVIDER_64
310 //! \param clockDivider Divides the pre-divided clock source
312 //! - \b ADC_DIVIDER_1 [Default value]
313 //! - \b ADC_DIVIDER_2
314 //! - \b ADC_DIVIDER_3
315 //! - \b ADC_DIVIDER_4
316 //! - \b ADC_DIVIDER_5
317 //! - \b ADC_DIVIDER_6
318 //! - \b ADC_DIVIDER_7
319 //! - \b ADC_DIVIDER_8
321 //! \param internalChannelMask
322 //! Configures the internal/external pin mappings
323 //! for the ADC modules. This setting determines if the given ADC channel or
324 //! component is mapped to an external pin (default), or routed to an internal
325 //! component. This parameter is a bit mask where a logical high value will
326 //! switch the component to the internal routing. For a list of internal
327 //! routings, please refer to the device specific data sheet.
328 //! Valid values are a logical OR of the following values:
329 //! - \b ADC_MAPINTCH3
330 //! - \b ADC_MAPINTCH2
331 //! - \b ADC_MAPINTCH1
332 //! - \b ADC_MAPINTCH0
333 //! - \b ADC_TEMPSENSEMAP
336 //! If internalChannelMask is not desired, pass ADC_NOROUTE in lieu of this
339 //! \return false if the initialization fails due to an in progress conversion
343 //*****************************************************************************
344 extern bool ADC14_initModule(uint32_t clockSource, uint32_t clockPredivider,
345 uint32_t clockDivider, uint32_t internalChannelMask);
347 //*****************************************************************************
350 //! Sets the resolution of the ADC module. The default resolution is 12-bit,
351 //! however for power consumption concerns this can be limited to a lower
354 //! \param resolution Resolution of the ADC module
355 //! - \b ADC_8BIT (10 clock cycle conversion time)
356 //! - \b ADC_10BIT (12 clock cycle conversion time)
357 //! - \b ADC_12BIT (14 clock cycle conversion time)
358 //! - \b ADC_14BIT (16 clock cycle conversion time)[DEFAULT]
362 //*****************************************************************************
363 extern void ADC14_setResolution(uint32_t resolution);
365 //*****************************************************************************
368 //! Gets the resolution of the ADC module.
370 //! \return Resolution of the ADC module
371 //! - \b ADC_8BIT (10 clock cycle conversion time)
372 //! - \b ADC_10BIT (12 clock cycle conversion time)
373 //! - \b ADC_12BIT (14 clock cycle conversion time)
374 //! - \b ADC_14BIT (16 clock cycle conversion time)
376 //*****************************************************************************
377 extern uint_fast32_t ADC14_getResolution(void);
379 //*****************************************************************************
382 //! Sets the source for the trigger of the ADC module. By default, this value
383 //! is configured to a software source (the ADCSC bit), however depending on
384 //! the specific device the trigger can be set to different sources (for
385 //! example, a timer output). These sources vary from part to part and the
386 //! user should refer to the device specific datasheet.
388 //! \param source Trigger source for sampling. Possible values include:
389 //! - \b ADC_TRIGGER_ADCSC [DEFAULT]
390 //! - \b ADC_TRIGGER_SOURCE1
391 //! - \b ADC_TRIGGER_SOURCE2
392 //! - \b ADC_TRIGGER_SOURCE3
393 //! - \b ADC_TRIGGER_SOURCE4
394 //! - \b ADC_TRIGGER_SOURCE5
395 //! - \b ADC_TRIGGER_SOURCE6
396 //! - \b ADC_TRIGGER_SOURCE7
397 //! \param invertSignal When set to true, will invert the trigger signal to a
398 //! falling edge. When false, will use a rising edge.
400 //! \return false if setting fails due to an in progress conversion
402 //*****************************************************************************
403 extern bool ADC14_setSampleHoldTrigger(uint32_t source, bool invertSignal);
405 //*****************************************************************************
408 //! Sets the sample/hold time for the specified memory register range. The
409 //! duration of time required for a sample differs depending on the user's
410 //! hardware configuration.
412 //! There are two values in the ADCC module. The first value controls
413 //! ADC memory locations ADC_MEMORY_0 through ADC_MEMORY_7 and
414 //! ADC_MEMORY_24 through ADC_MEMORY_31, while the second value
415 //! controls memory locations ADC_MEMORY_8 through ADC_MEMORY_23.
417 //! \param firstPulseWidth Pulse width of the first pulse in ADCCLK cycles
418 //! Possible values must be one of the following:
419 //! - \b ADC_PULSE_WIDTH_4 [DEFAULT]
420 //! - \b ADC_PULSE_WIDTH_8
421 //! - \b ADC_PULSE_WIDTH_16
422 //! - \b ADC_PULSE_WIDTH_32
423 //! - \b ADC_PULSE_WIDTH_64
424 //! - \b ADC_PULSE_WIDTH_96
425 //! - \b ADC_PULSE_WIDTH_128
426 //! - \b ADC_PULSE_WIDTH_192
427 //! \param secondPulseWidth Pulse width of the second pulse in ADCCLK
428 //! cycles. Possible values must be one of the following:
429 //! - \b ADC_PULSE_WIDTH_4 [DEFAULT]
430 //! - \b ADC_PULSE_WIDTH_8
431 //! - \b ADC_PULSE_WIDTH_16
432 //! - \b ADC_PULSE_WIDTH_32
433 //! - \b ADC_PULSE_WIDTH_64
434 //! - \b ADC_PULSE_WIDTH_96
435 //! - \b ADC_PULSE_WIDTH_128
436 //! - \b ADC_PULSE_WIDTH_192
438 //! \return false if setting fails due to an in progress conversion
440 //*****************************************************************************
441 extern bool ADC14_setSampleHoldTime(uint32_t firstPulseWidth,
442 uint32_t secondPulseWidth);
444 //*****************************************************************************
447 //! Configures the ADC module to use a multiple memory sample scheme. This
448 //! means that multiple samples will consecutively take place and be stored in
449 //! multiple memory locations. The first sample/conversion will be placed in
450 //! memoryStart, while the last sample will be stored in memoryEnd.
451 //! Each memory location should be configured individually using the
452 //! ADC14_configureConversionMemory function.
454 //! The ADC module can be started in "repeat" mode which will cause the
455 //! ADC module to resume sampling once the initial sample/conversion set is
456 //! executed. For multi-sample mode, this means that the sampling of the
457 //! entire memory provided.
459 //! \param memoryStart Memory location to store first sample/conversion
460 //! value. Possible values include:
461 //! - \b ADC_MEM0 through \b ADC_MEM31
462 //! \param memoryEnd Memory location to store last sample.
463 //! Possible values include:
464 //! - \b ADC_MEM0 through \b ADC_MEM31
465 //! \param repeatMode Specifies whether or not to repeat the conversion/sample
466 //! cycle after the first round of sample/conversions. Valid values
467 //! are true or false.
469 //! \return false if setting fails due to an in progress conversion
471 //*****************************************************************************
472 extern bool ADC14_configureMultiSequenceMode(uint32_t memoryStart,
473 uint32_t memoryEnd, bool repeatMode);
475 //*****************************************************************************
478 //! Configures the ADC module to use a a single ADC memory location for
479 //! sampling/conversion. This is used when only one channel might be needed for
480 //! conversion, or where using a multiple sampling scheme is not important.
482 //! The ADC module can be started in "repeat" mode which will cause the
483 //! ADC module to resume sampling once the initial sample/conversion set is
484 //! executed. In single sample mode, this will cause the ADC module to
485 //! continuously sample into the memory destination provided.
487 //! \param memoryDestination Memory location to store sample/conversion
488 //! value. Possible values include:
489 //! - \b ADC_MEM0 through \b ADC_MEM31
491 //! \param repeatMode Specifies whether or not to repeat the conversion/sample
492 //! cycle after the first round of sample/conversions
494 //! \return false if setting fails due to an in progress conversion
496 //*****************************************************************************
497 extern bool ADC14_configureSingleSampleMode(uint32_t memoryDestination,
500 //*****************************************************************************
503 //! Enables conversion of ADC data. Note that this only enables conversion.
504 //! To trigger the conversion, you will have to call the
505 //! ADC14_toggleConversionTrigger or use the source trigger configured in
506 //! ADC14_setSampleHoldTrigger.
508 //! \return false if setting fails due to an in progress conversion
510 //*****************************************************************************
511 extern bool ADC14_enableConversion(void);
513 //*****************************************************************************
516 //! Halts conversion conversion of the ADC module. Note that the software bit
517 //! for triggering conversions will also be cleared with this function.
519 //! If multi-sequence conversion mode was enabled, the position of the last
520 //! completed conversion can be retrieved using ADCLastConversionMemoryGet
524 //*****************************************************************************
525 extern void ADC14_disableConversion(void);
527 //*****************************************************************************
530 //! Toggles the trigger for conversion of the ADC module by toggling the
531 //! trigger software bit. Note that this will cause the ADC to start
532 //! conversion regardless if the software bit was set as the trigger using
533 //! ADC14_setSampleHoldTrigger.
535 //! \return false if setting fails due to an in progress conversion
537 //*****************************************************************************
538 extern bool ADC14_toggleConversionTrigger(void);
540 //*****************************************************************************
543 //! Returns a boolean value that tells if a conversion/sample is in progress
545 //! Originally a public function, but moved to static. External customers should
546 //! use the ADC14_isBusy function.
548 //! \return true if conversion is active, false otherwise
550 //*****************************************************************************
551 extern bool ADC14_isBusy(void);
553 //*****************************************************************************
556 //! Configures an individual memory location for the ADC module.
558 //! \param memorySelect is the individual ADC memory location to
559 //! configure. If multiple memory locations want to be configured with the
560 //! same configuration, this value can be logically ORed together with other
562 //! - \b ADC_MEM0 through \b ADC_MEM31
563 //! \param refSelect is the voltage reference to use for the selected
564 //! memory spot. Possible values include:
565 //! - \b ADC_VREFPOS_AVCC_VREFNEG_VSS [DEFAULT]
566 //! - \b ADC_VREFPOS_INTBUF_VREFNEG_VSS
567 //! - \b ADC_VREFPOS_EXTPOS_VREFNEG_EXTNEG
568 //! - \b ADC_VREFPOS_EXTBUF_VREFNEG_EXTNEG
569 //! \param channelSelect selects the channel to be used for ADC sampling.
570 //! Note if differential mode is enabled, the value sampled will be
571 //! equal to the difference between the corresponding even/odd memory
572 //! locations. Possible values are:
573 //! - \b ADC_INPUT_A0 through \b ADC_INPUT_A31
575 //! \param differntialMode selects if the channel selected by the
576 //! channelSelect will be configured in differential mode. If this
577 //! parameter is given for false, the configured channel will be paired
578 //! with its neighbor in differential mode. for example, if channel A0 or A1
579 //! is selected, the channel configured will be the difference between A0
580 //! and A1. If A2 or A3 are selected, the channel configured will be the
581 //! difference between A2 and A3 (and so on). Users can enter true or false,
582 //! or one ofl the following values:
583 //! - ADC_NONDIFFERENTIAL_INPUTS
584 //! - ADC_DIFFERENTIAL_INPUTS
587 //! \return false if setting fails due to an in progress conversion
590 //*****************************************************************************
591 extern bool ADC14_configureConversionMemory(uint32_t memorySelect,
592 uint32_t refSelect, uint32_t channelSelect, bool differntialMode);
594 //*****************************************************************************
597 //! Enables the specified mask of memory channels to use the specified
598 //! comparator window. THe ADCC module has two different comparator windows
599 //! that can be set with this function.
601 //! \param memorySelect is the mask of memory locations to enable the
602 //! comparator window for. This can be a bitwise OR of the following
604 //! - \b ADC_MEM0 through \b ADC_MEM31
605 //! \param windowSelect Memory location to store sample/conversion
606 //! value. Possible values include:
607 //! \b ADCOMP_WINDOW0 [DEFAULT]
608 //! \b ADCOMP_WINDOW1
610 //! \return false if setting fails due to an in progress conversion
612 //*****************************************************************************
613 extern bool ADC14_enableComparatorWindow(uint32_t memorySelect,
614 uint32_t windowSelect);
616 //*****************************************************************************
619 //! Disables the comparator window on the specified memory channels
621 //! \param memorySelect is the mask of memory locations to disable the
622 //! comparator window for. This can be a bitwise OR of the following
624 //! - \b ADC_MEM0 through \b ADC_MEM31
626 //! \return false if setting fails due to an in progress conversion
628 //*****************************************************************************
629 extern bool ADC14_disableComparatorWindow(uint32_t memorySelect);
631 //*****************************************************************************
634 //! Sets the lower and upper limits of the specified window comparator. Note
635 //! that this function will truncate values based of the resolution/data
636 //! format configured. If the ADC is operating in 10-bit mode, and a 12-bit
637 //! value is passed into this function the most significant 2 bits will be
640 //! The parameters provided to this function for the upper and lower threshold
641 //! depend on the current resolution for the ADC. For example, if configured
642 //! in 12-bit mode, a 12-bit resolution is the maximum that can be provided
643 //! for the window. If in 2's complement mode, Bit 15 is used as the MSB.
645 //! \param window Memory location to store sample/conversion
646 //! value. Possible values include:
647 //! \b ADC_COMP_WINDOW0 [DEFAULT]
648 //! \b ADC_COMP_WINDOW1
649 //! \param low is the lower limit of the window comparator
650 //! \param high is the upper limit of the window comparator
652 //! \return false if setting fails due to an in progress conversion
655 //*****************************************************************************
656 extern bool ADC14_setComparatorWindowValue(uint32_t window, int16_t low,
659 //*****************************************************************************
662 //! Switches between a binary unsigned data format and a signed 2's complement
665 //! \param resultFormat Format for result to conversion results.
666 //! Possible values include:
667 //! \b ADC_UNSIGNED_BINARY [DEFAULT]
668 //! \b ADC_SIGNED_BINARY
670 //! \return false if setting fails due to an in progress conversion
673 //*****************************************************************************
674 extern bool ADC14_setResultFormat(uint32_t resultFormat);
676 //*****************************************************************************
679 //! Returns the conversion result for the specified memory channel in the format
680 //! assigned by the ADC14_setResultFormat (unsigned binary by default) function.
682 //! \param memorySelect is the memory location to get the conversion result.
683 //! Valid values are:
684 //! - \b ADC_MEM0 through \b ADC_MEM31
685 //! \return conversion result of specified memory channel
688 //*****************************************************************************
689 extern uint_fast16_t ADC14_getResult(uint32_t memorySelect);
691 //*****************************************************************************
694 //! Returns the conversion results of the currently configured multi-sequence
695 //! conversion. If a multi-sequence conversion has not happened, this value
696 //! is unreliable. Note that it is up to the user to verify the integrity of
697 //! and proper size of the array being passed. If there are 16 multi-sequence
698 //! results, and an array with only 4 elements allocated is passed, invalid
699 //! memory settings will occur
701 //! \param res conversion result of the last multi-sequence sample
702 //! in an array of unsigned 16-bit integers
707 //*****************************************************************************
708 extern void ADC14_getMultiSequenceResult(uint16_t* res);
710 //*****************************************************************************
713 //! Returns the conversion results of the specified ADC memory locations.
714 //! Note that it is up to the user to verify the integrity of
715 //! and proper size of the array being passed. If there are 16 multi-sequence
716 //! results, and an array with only 4 elements allocated is passed, invalid
717 //! memory settings will occur. This function is inclusive.
719 //! \param memoryStart is the memory location to get the conversion result.
720 //! Valid values are:
721 //! - \b ADC_MEM0 through \b ADC_MEM31
723 //! \param memoryEnd is the memory location to get the conversion result.
724 //! Valid values are:
725 //! - \b ADC_MEM0 through \b ADC_MEM31
726 //! \param res conversion result of the last multi-sequence sample
727 //! in an array of unsigned 16-bit integers
732 //*****************************************************************************
733 extern void ADC14_getResultArray(uint32_t memoryStart, uint32_t memoryEnd,
736 //*****************************************************************************
739 //! Enables the "on-demand" activity of the voltage reference register. If this
740 //! setting is enabled, the internal voltage reference buffer will only be
741 //! updated during a sample or conversion cycle. This is used to optimize
742 //! power consumption.
744 //! \return false if setting fails due to an in progress conversion
747 //*****************************************************************************
748 extern bool ADC14_enableReferenceBurst(void);
750 //*****************************************************************************
753 //! Disables the "on-demand" activity of the voltage reference register.
755 //! \return false if setting fails due to an in progress conversion
758 //*****************************************************************************
759 extern bool ADC14_disableReferenceBurst(void);
761 //*****************************************************************************
764 //! Sets the power mode of the ADC module. A more aggressive power mode will
765 //! restrict the number of samples per second for sampling while optimizing
766 //! power consumption. Ideally, if power consumption is a concern, this value
767 //! should be set to the most restrictive setting that satisfies your sampling
770 //! \param adcPowerMode is the power mode to set. Valid values are:
771 //! - \b ADC_UNRESTRICTED_POWER_MODE (no restriction)
772 //! - \b ADC_LOW_POWER_MODE (500ksps restriction)
773 //! - \b ADC_ULTRA_LOW_POWER_MODE (200ksps restriction)
774 //! - \b ADC_EXTREME_LOW_POWER_MODE (50ksps restriction)
776 //! \return false if setting fails due to an in progress conversion
779 //*****************************************************************************
780 extern bool ADC14_setPowerMode(uint32_t powerMode);
782 //*****************************************************************************
785 //! Enables SAMPCON to be sourced from the sampling timer and to configures
786 //! multi sample and conversion mode.
787 //! \param multiSampleConvert - Switches between manual and automatic
788 //! iteration when using the sample timer. Valid values are:
789 //! - \b ADC_MANUAL_ITERATION The user will have to manually set the SHI signal
790 //! ( usually by ADC14_toggleConversionTrigger ) at the end
791 //! of each sample/conversion cycle.
792 //! - \b ADC_AUTOMATIC_ITERATION After one sample/convert is finished, the ADC
793 //! module will automatically continue on to the next sample
795 //! \return false if the initialization fails due to an in progress conversion
797 //*****************************************************************************
798 extern bool ADC14_enableSampleTimer(uint32_t multiSampleConvert);
800 //*****************************************************************************
803 //! Disables SAMPCON from being sourced from the sample timer.
805 //! \return false if the initialization fails due to an in progress conversion
807 //*****************************************************************************
808 extern bool ADC14_disableSampleTimer(void);
810 //*****************************************************************************
813 //! Enables the indicated ADCC interrupt sources. The ADC_INT0
814 //! through ADC_INT31 parameters correspond to a completion event of the
815 //! corresponding memory location. For example, when the ADC_MEM0 location
816 //! finishes a conversion cycle, the ADC_INT0 interrupt will be set.
818 //! \param mask is the bit mask of interrupts to enable.
819 //! Valid values are a bitwise OR of the following values:
820 //! - \b ADC_INT0 through ADC_INT31
821 //! - \b ADC_IN_INT - Interrupt enable for a conversion in the result
822 //! register is either greater than the ADCLO or
823 //! lower than the ADCHI threshold.
824 //! - \b ADC_LO_INT - Interrupt enable for the falling short of the
825 //! lower limit interrupt of the window comparator for
826 //! the result register.
827 //! - \b ADC_HI_INT - Interrupt enable for the exceeding the upper
828 //! limit of the window comparator for the result
830 //! - \b ADC_OV_INT - Interrupt enable for a conversion that is about
831 //! to save to a memory buffer that has not been read
833 //! - \b ADC_TOV_INT -Interrupt enable for a conversion that is about
834 //! to start before the previous conversion has been
836 //! - \b ADC_RDY_INT -Interrupt enable for the local buffered reference
842 //*****************************************************************************
843 extern void ADC14_enableInterrupt(uint_fast64_t mask);
845 //*****************************************************************************
848 //! Disables the indicated ADCC interrupt sources. Only the sources that
849 //! are enabled can be reflected to the processor interrupt; disabled sources
850 //! have no effect on the processor. The ADC_INT0 through ADC_INT31
851 //! parameters correspond to a completion event of the corresponding memory
852 //! location. For example, when the ADC_MEM0 location finishes a conversion
853 //! cycle, the ADC_INT0 interrupt will be set.
855 //! \param mask is the bit mask of interrupts to disable.
856 //! Valid values are a bitwise OR of the following values:
857 //! - \b ADC_INT0 through ADC_INT31
858 //! - \b ADC_IN_INT - Interrupt enable for a conversion in the result
859 //! register is either greater than the ADCLO or
860 //! lower than the ADCHI threshold.
861 //! - \b ADC_LO_INT - Interrupt enable for the falling short of the
862 //! lower limit interrupt of the window comparator for
863 //! the result register.
864 //! - \b ADC_HI_INT - Interrupt enable for the exceeding the upper
865 //! limit of the window comparator for the result
867 //! - \b ADC_OV_INT - Interrupt enable for a conversion that is about
868 //! to save to a memory buffer that has not been read
870 //! - \b ADC_TOV_INT -Interrupt enable for a conversion that is about
871 //! to start before the previous conversion has been
873 //! - \b ADC_RDY_INT -Interrupt enable for the local buffered reference
879 //*****************************************************************************
880 extern void ADC14_disableInterrupt(uint_fast64_t mask);
882 //*****************************************************************************
885 //! Returns the status of a the ADC interrupt register. The ADC_INT0
886 //! through ADC_INT31 parameters correspond to a completion event of the
887 //! corresponding memory location. For example, when the ADC_MEM0 location
888 //! finishes a conversion cycle, the ADC_INT0 interrupt will be set.
890 //! \return The interrupt status. Value is a bitwise OR of the following values:
891 //! - \b ADC_INT0 through ADC_INT31
892 //! - \b ADC_IN_INT - Interrupt enable for a conversion in the result
893 //! register is either greater than the ADCLO or
894 //! lower than the ADCHI threshold.
895 //! - \b ADC_LO_INT - Interrupt enable for the falling short of the
896 //! lower limit interrupt of the window comparator for
897 //! the result register.
898 //! - \b ADC_HI_INT - Interrupt enable for the exceeding the upper
899 //! limit of the window comparator for the result
901 //! - \b ADC_OV_INT - Interrupt enable for a conversion that is about
902 //! to save to a memory buffer that has not been read
904 //! - \b ADC_TOV_INT -Interrupt enable for a conversion that is about
905 //! to start before the previous conversion has been
907 //! - \b ADC_RDY_INT -Interrupt enable for the local buffered reference
912 //*****************************************************************************
913 extern uint_fast64_t ADC14_getInterruptStatus(void);
915 //*****************************************************************************
918 //! Returns the status of a the ADC interrupt register masked with the
919 //! enabled interrupts. This function is useful to call in ISRs to get a list
920 //! of pending interrupts that are actually enabled and could have caused the
921 //! ISR. The ADC_INT0 through ADC_INT31 parameters correspond to a
922 //! completion event of the corresponding memory location. For example,
923 //! when the ADC_MEM0 location finishes a conversion cycle, the ADC_INT0
924 // !interrupt will be set.
926 //! \return The interrupt status. Value is a bitwise OR of the following values:
927 //! - \b ADC_INT0 through ADC_INT31
928 //! - \b ADC_IN_INT - Interrupt enable for a conversion in the result
929 //! register is either greater than the ADCLO or
930 //! lower than the ADCHI threshold.
931 //! - \b ADC_LO_INT - Interrupt enable for the falling short of the
932 //! lower limit interrupt of the window comparator for
933 //! the result register.
934 //! - \b ADC_HI_INT - Interrupt enable for the exceeding the upper
935 //! limit of the window comparator for the result
937 //! - \b ADC_OV_INT - Interrupt enable for a conversion that is about
938 //! to save to a memory buffer that has not been read
940 //! - \b ADC_TOV_INT -Interrupt enable for a conversion that is about
941 //! to start before the previous conversion has been
943 //! - \b ADC_RDY_INT -Interrupt enable for the local buffered reference
948 //*****************************************************************************
949 extern uint_fast64_t ADC14_getEnabledInterruptStatus(void);
951 //*****************************************************************************
954 //! Clears the indicated ADCC interrupt sources.
956 //! \param mask is the bit mask of interrupts to clear. The ADC_INT0
957 //! through ADC_INT31 parameters correspond to a completion event of the
958 //! corresponding memory location. For example, when the ADC_MEM0 location
959 //! finishes a conversion cycle, the ADC_INT0 interrupt will be set.
960 //! Valid values are a bitwise OR of the following values:
961 //! - \b ADC_INT0 through ADC_INT31
962 //! - \b ADC_IN_INT - Interrupt enable for a conversion in the result
963 //! register is either greater than the ADCLO or
964 //! lower than the ADCHI threshold.
965 //! - \b ADC_LO_INT - Interrupt enable for the falling short of the
966 //! lower limit interrupt of the window comparator for
967 //! the result register.
968 //! - \b ADC_HI_INT - Interrupt enable for the exceeding the upper
969 //! limit of the window comparator for the result
971 //! - \b ADC_OV_INT - Interrupt enable for a conversion that is about
972 //! to save to a memory buffer that has not been read
974 //! - \b ADC_TOV_INT -Interrupt enable for a conversion that is about
975 //! to start before the previous conversion has been
977 //! - \b ADC_RDY_INT -Interrupt enable for the local buffered reference
983 //*****************************************************************************
984 extern void ADC14_clearInterruptFlag(uint_fast64_t mask);
986 //*****************************************************************************
989 //! Registers an interrupt handler for the ADC interrupt.
991 //! \param intHandler is a pointer to the function to be called when the ADC
992 //! interrupt occurs.
994 //! This function registers the handler to be called when an ADC
995 //! interrupt occurs. This function enables the global interrupt in the
996 //! interrupt controller; specific ADC14 interrupts must be enabled
997 //! via ADC14_enableInterrupt(). It is the interrupt handler's responsibility
998 //! to clear the interrupt source via ADC14_clearInterruptFlag().
1000 //! \sa Interrupt_registerInterrupt() for important information about
1001 //! registering interrupt handlers.
1005 //*****************************************************************************
1006 extern void ADC14_registerInterrupt(void (*intHandler)(void));
1008 //*****************************************************************************
1011 //! Unregisters the interrupt handler for the ADCC module.
1013 //! This function unregisters the handler to be called when an ADCC
1014 //! interrupt occurs. This function also masks off the interrupt in the
1015 //! interrupt controller so that the interrupt handler no longer is called.
1017 //! \sa Interrupt_registerInterrupt() for important information about
1018 //! registering interrupt handlers.
1022 //*****************************************************************************
1023 extern void ADC14_unregisterInterrupt(void);
1025 /* Defines for future devices that might have multiple instances */
1026 #define ADC14_enableModuleMultipleInstance(a) ADC14_enableModule()
1027 #define ADC14_disableModuleMultipleInstance(a) ADC14_disableModule()
1028 #define ADC14_initModuleMultipleInstance(a,b,c,d,e) ADC14_initModule(b,c,d,e)
1029 #define ADC14_setResolutionMutlipleInstance(a,b) ADC14_setResolution(b)
1030 #define ADC14_getResolutionMutlipleInstance(a) ADC14_getResolution()
1031 #define ADC14_setSampleHoldTriggerMultipleInstance(a,b,c) ADC14_setSampleHoldTrigger(b,c)
1032 #define ADC14_setSampleHoldTimeMultipleInstance(a,b,c) ADC14_setSampleHoldTime(b,c)
1033 #define ADC14_configureMultiSequenceModeMultipleInstance(a,b,c,d) ADC14_configureMultiSequenceMode(b,c,d)
1034 #define ADC14_configureSingleSampleModeMultipleInstance(a,b,c) ADC14_configureSingleSampleMode(b,c)
1035 #define ADC14_enableConversionMultipleInstance(a,b) ADC14_enableConversion(b)
1036 #define ADC14_disableConversionMultipleInstance(a) ADC14_disableConversion()
1037 #define ADC14_toggleConversionTriggerMultipleInstance(a) ADC14_toggleConversionTrigger()
1038 #define ADC14_isBusyMultipleInstance(a) ADC14_isBusy()
1039 #define ADC14_configureConversionMemoryMultipleInstance(a,b,c,d,e) ADC14_enableModule(b,c,d,e)
1040 #define ADC14_enableComparatorWindowMultipleInstance(a,b,c) ADC14_enableComparatorWindow(b,c)
1041 #define ADC14_disableComparatorWindowMultipleInstance(a,b) ADC14_disableComparatorWindow(b)
1042 #define ADC14_setComparatorWindowValueMultipleInstance(a,b,c,d) ADC14_setComparatorWindowValue(b,c,d)
1043 #define ADC14_setResultFormatMultipleInstance(a,b) ADC14_setResultFormat(b)
1044 #define ADC14_getResultMultipleInstance(a,b) ADC14_getResult(b)
1045 #define ADC14_getMultiSequenceResultMultipleInstance(a,b) ADC14_getMultiSequenceResult(b)
1046 #define ADC14_getResultArrayMultipleInstance(a,b,c,d) ADC14_getResultArray(b,c,d)
1047 #define ADC14_enableReferenceBurstMultipleInstance(a) ADC14_enableReferenceBurst()
1048 #define ADC14_disableReferenceBurstMultipleInstance(a) ADC14_disableReferenceBurst()
1049 #define ADC14_setPowerModeMultipleInstance(a,b) ADC14_setPowerMode(b)
1050 #define ADC14_enableSampleTimerMultipleInstance(a,b) ADC14_enableSampleTimer(b)
1051 #define ADC14_disableSampleTimerMultipleInstance(a) ADC14_disableSampleTimer()
1052 #define ADC14_enableInterruptMultipleInstance(a,b) ADC14_enableInterrupt(b)
1053 #define ADC14_disableInterruptMultipleInstance(a,b) ADC14_disableInterrupt(b)
1054 #define ADC14_getInterruptStatusMultipleInstance(a) ADC14_getInterruptStatus()
1055 #define ADC14_getEnabledInterruptStatusMultipleInstance(a) ADC14_getEnabledInterruptStatus()
1056 #define ADC14_clearInterruptFlagMultipleInstance(a,b) ADC14_clearInterruptFlag(b)
1057 #define ADC14_registerInterruptMultipleInstance(a,b) ADC14_registerInterrupt(b)
1058 #define ADC14_unregisterInterruptMultipleInstance(a) ADC14_unregisterInterrupt()
1060 //*****************************************************************************
1062 // Mark the end of the C bindings section for C++ compilers.
1064 //*****************************************************************************
1069 //*****************************************************************************
1071 // Close the Doxygen group.
1074 //*****************************************************************************
1076 #endif /* ADC14_H_ */