ADCMSP432.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2019, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!****************************************************************************
33  * @file ADCMSP432.h
34  * @brief ADC driver implementation for the ADC peripheral on MSP432P4
35  *
36  * This ADC driver implementation is designed to operate on a ADC14 peripheral
37  * for MSP432P4.
38  *
39  * Refer to @ref ADC.h for a complete description of APIs & example of use.
40  *
41  ******************************************************************************
42  */
43 #ifndef ti_drivers_adc_ADCMSP432__include
44 #define ti_drivers_adc_ADCMSP432__include
45 
46 #include <stdint.h>
47 #include <stdbool.h>
48 
49 #include <ti/drivers/ADC.h>
50 #include <ti/drivers/dpl/HwiP.h>
51 #include <ti/drivers/dpl/SemaphoreP.h>
52 #include <ti/drivers/Power.h>
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 /*
59  * ADC port/pin defines for pin configuration. Ports P2, P3, and P7 are
60  * configurable through the port mapping controller. None of the port
61  * mappings support ADC.
62  * Channel specifies the ADC channel and ranges from 0 to 23.
63  * pin range: 0 - 7, port range: 0 - 15
64  *
65  *
66  * 15 - 10 9 8 7 - 4 3 - 0
67  * ---------------------------------
68  * | CHANNEL | X | X | PORT | PIN |
69  * ---------------------------------
70  *
71  * channel = pinConfig >> 10
72  * port = (pinConfig >> 4) & 0xf
73  * pin = 1 << (pinConfig & 0xf)
74  * moduleFunction = (pinConfig >> 8) & 0x3
75  *
76  * For non-configurable ports (bits 20 - 12 will be 0).
77  * Bits 8 and 9 hold the module function (PRIMARY, SECONDARY, or
78  * TERTIALRY). All ADC modes are TERTIALRY, so bits 8 and 9
79  * are 1.
80  *
81  * MAP_GPIO_setAsPeripheralModuleFunctionInputPin(port,
82  * pin, moduleFunction);
83  * or:
84  * MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(port,
85  * pin, moduleFunction);
86  *
87  */
88 /* Port 4 */
89 #define ADCMSP432_P4_0_A13 ((13 << 10) | 0x0340) /* ch 13, port 4, pin 0 */
90 #define ADCMSP432_P4_1_A12 ((12 << 10) | 0x0341) /* ch 12, port 4, pin 1 */
91 #define ADCMSP432_P4_2_A11 ((11 << 10) | 0x0342) /* ch 11, port 4, pin 2 */
92 #define ADCMSP432_P4_3_A10 ((10 << 10) | 0x0343) /* ch 10, port 4, pin 3 */
93 #define ADCMSP432_P4_4_A9 ((9 << 10) | 0x0344) /* ch 9, port 4, pin 4 */
94 #define ADCMSP432_P4_5_A8 ((8 << 10) | 0x0345) /* ch 8, port 4, pin 5 */
95 #define ADCMSP432_P4_6_A7 ((7 << 10) | 0x0346) /* ch 7, port 4, pin 6 */
96 #define ADCMSP432_P4_7_A6 ((6 << 10) | 0x0347) /* ch 6, port 4, pin 7 */
97 
98 /* Port 5 */
99 #define ADCMSP432_P5_0_A5 ((5 << 10) | 0x0350) /* ch 5, port 5, pin 0 */
100 #define ADCMSP432_P5_1_A4 ((4 << 10) | 0x0351) /* ch 4, port 5, pin 1 */
101 #define ADCMSP432_P5_2_A3 ((3 << 10) | 0x0352) /* ch 3, port 5, pin 2 */
102 #define ADCMSP432_P5_3_A2 ((2 << 10) | 0x0353) /* ch 2, port 5, pin 3 */
103 #define ADCMSP432_P5_4_A1 ((1 << 10) | 0x0354) /* ch 1, port 5, pin 4 */
104 #define ADCMSP432_P5_5_A0 ((0 << 10) | 0x0355) /* ch 0, port 5, pin 5 */
105 
106 /* Port 6 */
107 #define ADCMSP432_P6_0_A15 ((15 << 10) | 0x0360) /* ch 15, port 6, pin 0 */
108 #define ADCMSP432_P6_1_A14 ((14 << 10) | 0x0361) /* ch 14, port 6, pin 1 */
109 
110 /* Port 8 */
111 #define ADCMSP432_P8_2_A23 ((23 << 10) | 0x0382) /* ch 23, port 8, pin 2 */
112 #define ADCMSP432_P8_3_A22 ((22 << 10) | 0x0383) /* ch 22, port 8, pin 3 */
113 #define ADCMSP432_P8_4_A21 ((21 << 10) | 0x0384) /* ch 21, port 8, pin 4 */
114 #define ADCMSP432_P8_5_A20 ((20 << 10) | 0x0385) /* ch 20, port 8, pin 5 */
115 #define ADCMSP432_P8_6_A19 ((19 << 10) | 0x0386) /* ch 19, port 8, pin 6 */
116 #define ADCMSP432_P8_7_A18 ((18 << 10) | 0x0387) /* ch 18, port 8, pin 7 */
117 
118 /* Port 9 */
119 #define ADCMSP432_P9_0_A17 ((17 << 10) | 0x0390) /* ch 17, port 9, pin 0 */
120 #define ADCMSP432_P9_1_A16 ((16 << 10) | 0x0391) /* ch 16, port 9, pin 1 */
121 
122 /*
123  * ADCMSP432_HWAttrsV1.refVoltage values
124  */
125 #define ADCMSP432_REF_VOLTAGE_VDD ADC_VREFPOS_AVCC_VREFNEG_VSS | 0xFF /* 0x00FF */
126 #define ADCMSP432_REF_VOLTAGE_INT_1_2V REF_A_VREF1_2V /* 0x0000 */
127 #define ADCMSP432_REF_VOLTAGE_INT_1_45V REF_A_VREF1_45V /* 0x0010 */
128 #define ADCMSP432_REF_VOLTAGE_INT_2_5V REF_A_VREF2_5V /* 0x0030 */
129 #define ADCMSP432_REF_VOLTAGE_EXT ADC_VREFPOS_EXTPOS_VREFNEG_EXTNEG /* 0x0E00 */
130 #define ADCMSP432_REF_VOLTAGE_EXT_BUF ADC_VREFPOS_EXTBUF_VREFNEG_EXTNEG /* 0x0F00 */
131 
132 
133 /* ADC function table pointer */
134 extern const ADC_FxnTable ADCMSP432_fxnTable;
135 
156 typedef struct {
157  uint_fast16_t adcPin;
158  uint_fast16_t refVoltage;
159  uint_fast32_t resolution;
160  uint_fast32_t refExtValue;
162 
168 typedef struct {
169  bool isOpen; /* To determine if the ADC is open */
170  bool isProtected; /* Flag to indicate if thread safety is ensured
171  by the driver */
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif /* ti_drivers_adc_ADCMSP432__include */
const ADC_FxnTable ADCMSP432_fxnTable
uint_fast16_t refVoltage
Definition: ADCMSP432.h:158
bool isProtected
Definition: ADCMSP432.h:170
bool isOpen
Definition: ADCMSP432.h:169
Power Manager.
uint_fast32_t refExtValue
Definition: ADCMSP432.h:160
uint_fast16_t adcPin
Definition: ADCMSP432.h:157
Analog to Digital Conversion (ADC) Input Driver.
The definition of an ADC function table that contains the required set of functions to control a spec...
Definition: ADC.h:319
ADCMSP432 Hardware attributes These fields are used by driverlib APIs and therefore must be populated...
Definition: ADCMSP432.h:156
uint_fast32_t resolution
Definition: ADCMSP432.h:159
ADCMSP432 Object.
Definition: ADCMSP432.h:168
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale