ADCMSP432E4.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-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 ADCMSP432E4.h
34  * @brief ADC driver implementation for the ADC peripheral on MSP432E4
35  *
36  * This ADC driver implementation is designed to operate on a ADC peripheral
37  * for MSP432E4.
38  *
39  * Refer to @ref ADC.h for a complete description of APIs & example of use.
40  *
41  ******************************************************************************
42  */
43 #ifndef ti_drivers_adc_ADCMSP432E4__include
44 #define ti_drivers_adc_ADCMSP432E4__include
45 
46 #include <stdint.h>
47 #include <stdbool.h>
48 
49 #include <ti/drivers/ADC.h>
50 #include <ti/devices/msp432e4/inc/msp432.h>
51 #include <ti/devices/msp432e4/driverlib/adc.h>
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 /*
58  * ADC port/pin defines for pin configuration. Ports B, D, E, and K are
59  * configurable through the port mapping controller. None of the port
60  * mappings support ADC.
61  * Channel specifies the ADC channel and ranges from 0 to 20.
62  * pin range: 0 - 7, port range: 0 - 15
63  *
64  *
65  * 32 - 21 20 - 16 15 - 8 7 - 0
66  * ---------------------------------
67  * | X X X X | CHANNEL | PORT | PIN |
68  * ---------------------------------
69  *
70  * channel = (((config) >> 16) & 0x1F)
71  * port = (((config << 4) & 0x000FF000) | 0x40000000)
72  * pin = ((config) & 0xFF)
73  *
74  */
75 /* Port B */
76 #define ADCMSP432E4_PB_4_A10 ((10 << 16) | 0x5910) /* ch 10, port B, pin 4 */
77 #define ADCMSP432E4_PB_5_A11 ((11 << 16) | 0x5920) /* ch 11, port B, pin 5 */
78 
79 /* Port D */
80 #define ADCMSP432E4_PD_0_A15 ((15 << 16) | 0x5B01) /* ch 15, port D, pin 0 */
81 #define ADCMSP432E4_PD_1_A14 ((14 << 16) | 0x5B02) /* ch 14, port D, pin 1 */
82 #define ADCMSP432E4_PD_2_A13 ((13 << 16) | 0x5B04) /* ch 13, port D, pin 2 */
83 #define ADCMSP432E4_PD_3_A12 ((12 << 16) | 0x5B08) /* ch 12, port D, pin 3 */
84 #define ADCMSP432E4_PD_4_A7 ((7 << 16) | 0x5B10) /* ch 7, port D, pin 4 */
85 #define ADCMSP432E4_PD_5_A6 ((6 << 16) | 0x5B20) /* ch 6, port D, pin 5 */
86 #define ADCMSP432E4_PD_6_A5 ((5 << 16) | 0x5B40) /* ch 5, port D, pin 6 */
87 #define ADCMSP432E4_PD_7_A4 ((4 << 16) | 0x5B80) /* ch 4, port D, pin 7 */
88 
89 /* Port E */
90 #define ADCMSP432E4_PE_0_A3 ((3 << 16) | 0x5C01) /* ch 3, port E, pin 0 */
91 #define ADCMSP432E4_PE_1_A2 ((2 << 16) | 0x5C02) /* ch 2, port E, pin 1 */
92 #define ADCMSP432E4_PE_2_A1 ((1 << 16) | 0x5C04) /* ch 1, port E, pin 2 */
93 #define ADCMSP432E4_PE_3_A0 ((0 << 16) | 0x5C08) /* ch 0, port E, pin 3 */
94 #define ADCMSP432E4_PE_4_A9 ((9 << 16) | 0x5C10) /* ch 9, port E, pin 4 */
95 #define ADCMSP432E4_PE_5_A8 ((8 << 16) | 0x5C20) /* ch 8, port E, pin 5 */
96 #define ADCMSP432E4_PE_6_A20 ((20 << 16) | 0x5C40) /* ch 20, port E, pin 6 */
97 #define ADCMSP432E4_PE_7_A21 ((21 << 16) | 0x5C80) /* ch 21, port E, pin 7 */
98 
99 /* Port K */
100 #define ADCMSP432E4_PK_0_A16 ((16 << 16) | 0x6101) /* ch 16, port K, pin 0 */
101 #define ADCMSP432E4_PK_1_A17 ((17 << 16) | 0x6102) /* ch 17, port K, pin 1 */
102 #define ADCMSP432E4_PK_2_A18 ((18 << 16) | 0x6104) /* ch 18, port K, pin 2 */
103 #define ADCMSP432E4_PK_3_A19 ((19 << 16) | 0x6108) /* ch 19, port K, pin 3 */
104 
105 /* Port P */
106 #define ADCMSP432E4_PP_6_A23 ((23 << 16) | 0x6540) /* ch 23, port P, pin 6 */
107 #define ADCMSP432E4_PP_7_A22 ((22 << 16) | 0x6580) /* ch 22, port P, pin 7 */
108 
115 typedef enum {
119 
120 
129 typedef enum {
135 
142 typedef enum {
143  ADCMSP432E4_MOD0 = ADC0_BASE,
144  ADCMSP432E4_MOD1 = ADC1_BASE
146 
147 
148 /* ADC function table pointer */
150 
170 typedef struct {
171  uint_fast16_t adcPin;
172  uint_fast16_t refVoltage;
173  ADCMSP432E4_Module adcModule;
176 
182 typedef struct {
183  bool isOpen; /* To determine if the ADC is open */
184  bool isProtected; /* Flag to indicate if thread safety is ensured
185  by the driver */
187 
188 #ifdef __cplusplus
189 }
190 #endif
191 
192 #endif /* ti_drivers_adc_ADCMSP432E4__include */
Definition: ADCMSP432E4.h:117
Definition: ADCMSP432E4.h:144
ADCMSP432E4_Sequencer adcSeq
Definition: ADCMSP432E4.h:174
Definition: ADCMSP432E4.h:116
Definition: ADCMSP432E4.h:143
uint_fast16_t adcPin
Definition: ADCMSP432E4.h:171
ADCMSP432 Object.
Definition: ADCMSP432E4.h:182
ADCMSP432E4_ReferenceSource
ADCMSP432E4 reference source These fields are used by ADCMSP432E4_HWAttrs to specify the reference vo...
Definition: ADCMSP432E4.h:115
const ADC_FxnTable ADCMSP432E4_fxnTable
Analog to Digital Conversion (ADC) Input Driver.
Definition: ADCMSP432E4.h:132
ADCMSP432E4_Module
ADCMSP432E4 Module These fields are used by ADCMSP432E4_HWAttrs to specify the ADC module for each ch...
Definition: ADCMSP432E4.h:142
The definition of an ADC function table that contains the required set of functions to control a spec...
Definition: ADC.h:319
Definition: ADCMSP432E4.h:133
uint_fast16_t refVoltage
Definition: ADCMSP432E4.h:172
bool isProtected
Definition: ADCMSP432E4.h:184
Definition: ADCMSP432E4.h:131
Definition: ADCMSP432E4.h:130
ADCMSP432E4 Hardware attributes These fields are used by driverlib APIs and therefore must be populat...
Definition: ADCMSP432E4.h:170
ADCMSP432E4_Module adcModule
Definition: ADCMSP432E4.h:173
bool isOpen
Definition: ADCMSP432E4.h:183
ADCMSP432E4_Sequencer
ADCMSP432E4 Sequencer These fields are used by ADCMSP432E4_HWAttrs to specify the sample sequencer fo...
Definition: ADCMSP432E4.h:129
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale