ADCMSP432E4.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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  */
49 #ifndef ti_drivers_adc_ADCMSP432E4__include
50 #define ti_drivers_adc_ADCMSP432E4__include
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 #include <stdint.h>
57 #include <stdbool.h>
58 
59 #include <ti/drivers/ADC.h>
60 #include <ti/devices/msp432e4/inc/msp432.h>
61 #include <ti/devices/msp432e4/driverlib/adc.h>
62 /*
63  * ADC port/pin defines for pin configuration. Ports B, D, E, and K are
64  * configurable through the port mapping controller. None of the port
65  * mappings support ADC.
66  * Channel specifies the ADC channel and ranges from 0 to 20.
67  * pin range: 0 - 7, port range: 0 - 15
68  *
69  *
70  * 32 - 21 20 - 16 15 - 8 7 - 0
71  * ---------------------------------
72  * | X X X X | CHANNEL | PORT | PIN |
73  * ---------------------------------
74  *
75  * channel = (((config) >> 16) & 0x1F)
76  * port = (((config << 4) & 0x000FF000) | 0x40000000)
77  * pin = ((config) & 0xFF)
78  *
79  */
80 /* Port B */
81 #define ADCMSP432E4_PB_4_A10 ((10 << 16) | 0x5910) /* ch 10, port B, pin 4 */
82 #define ADCMSP432E4_PB_5_A11 ((11 << 16) | 0x5920) /* ch 11, port B, pin 5 */
83 
84 /* Port D */
85 #define ADCMSP432E4_PD_0_A15 ((15 << 16) | 0x5B01) /* ch 15, port D, pin 0 */
86 #define ADCMSP432E4_PD_1_A14 ((14 << 16) | 0x5B02) /* ch 14, port D, pin 1 */
87 #define ADCMSP432E4_PD_2_A13 ((13 << 16) | 0x5B04) /* ch 13, port D, pin 2 */
88 #define ADCMSP432E4_PD_3_A12 ((12 << 16) | 0x5B08) /* ch 12, port D, pin 3 */
89 #define ADCMSP432E4_PD_4_A7 ((7 << 16) | 0x5B10) /* ch 7, port D, pin 4 */
90 #define ADCMSP432E4_PD_5_A6 ((6 << 16) | 0x5B20) /* ch 6, port D, pin 5 */
91 #define ADCMSP432E4_PD_6_A5 ((5 << 16) | 0x5B40) /* ch 5, port D, pin 6 */
92 #define ADCMSP432E4_PD_7_A4 ((4 << 16) | 0x5B80) /* ch 4, port D, pin 7 */
93 
94 /* Port E */
95 #define ADCMSP432E4_PE_0_A3 ((3 << 16) | 0x5C01) /* ch 3, port E, pin 0 */
96 #define ADCMSP432E4_PE_1_A2 ((2 << 16) | 0x5C02) /* ch 2, port E, pin 1 */
97 #define ADCMSP432E4_PE_2_A1 ((1 << 16) | 0x5C04) /* ch 1, port E, pin 2 */
98 #define ADCMSP432E4_PE_3_A0 ((0 << 16) | 0x5C08) /* ch 0, port E, pin 3 */
99 #define ADCMSP432E4_PE_4_A9 ((9 << 16) | 0x5C10) /* ch 9, port E, pin 4 */
100 #define ADCMSP432E4_PE_5_A8 ((8 << 16) | 0x5C20) /* ch 8, port E, pin 5 */
101 #define ADCMSP432E4_PE_6_A20 ((20 << 16) | 0x5C40) /* ch 20, port E, pin 6 */
102 #define ADCMSP432E4_PE_7_A21 ((21 << 16) | 0x5C80) /* ch 21, port E, pin 7 */
103 
104 /* Port K */
105 #define ADCMSP432E4_PK_0_A16 ((16 << 16) | 0x6101) /* ch 16, port K, pin 0 */
106 #define ADCMSP432E4_PK_1_A17 ((17 << 16) | 0x6102) /* ch 17, port K, pin 1 */
107 #define ADCMSP432E4_PK_2_A18 ((18 << 16) | 0x6104) /* ch 18, port K, pin 2 */
108 #define ADCMSP432E4_PK_3_A19 ((19 << 16) | 0x6108) /* ch 19, port K, pin 3 */
109 
110 /* Port P */
111 #define ADCMSP432E4_PP_6_A22 ((22 << 16) | 0x6540) /* ch 22, port P, pin 6 */
112 #define ADCMSP432E4_PP_7_A23 ((23 << 16) | 0x6580) /* ch 23, port P, pin 7 */
113 
124 
125 
132 typedef enum ADCMSP432E4_Sequencer {
138 
145 typedef enum ADCMSP432E4_Module {
146  ADCMSP432E4_MOD0 = ADC0_BASE,
147  ADCMSP432E4_MOD1 = ADC1_BASE
149 
150 
151 /* ADC function table pointer */
153 
173 typedef struct ADCMSP432E4_HWAttrsV1 {
174  uint_fast16_t adcPin;
175  uint_fast16_t refVoltage;
176  ADCMSP432E4_Module adcModule;
179 
185 typedef struct ADCMSP432E4_Object {
186  bool isOpen; /* To determine if the ADC is open */
187  bool isProtected; /* Flag to indicate if thread safety is ensured by the driver */
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif /* ti_drivers_adc_ADCMSP432E4__include */
Definition: ADCMSP432E4.h:122
Definition: ADCMSP432E4.h:147
ADCMSP432E4_Sequencer adcSeq
Definition: ADCMSP432E4.h:177
Definition: ADCMSP432E4.h:121
struct ADCMSP432E4_HWAttrsV1 ADCMSP432E4_HWAttrsV1
ADCMSP432E4 Hardware attributes These fields are used by driverlib APIs and therefore must be populat...
Definition: ADCMSP432E4.h:146
uint_fast16_t adcPin
Definition: ADCMSP432E4.h:174
ADCMSP432 Object.
Definition: ADCMSP432E4.h:185
ADCMSP432E4_ReferenceSource
ADCMSP432E4 reference source These fields are used by ADCMSP432E4_HWAttrs to specify the reference vo...
Definition: ADCMSP432E4.h:120
const ADC_FxnTable ADCMSP432E4_fxnTable
ADC driver interface.
Definition: ADCMSP432E4.h:135
The definition of a ADC function table that contains the required set of functions to control a speci...
Definition: ADC.h:273
ADCMSP432E4_Module
ADCMSP432E4 Module These fields are used by ADCMSP432E4_HWAttrs to specify the ADC module for each ch...
Definition: ADCMSP432E4.h:145
Definition: ADCMSP432E4.h:136
uint_fast16_t refVoltage
Definition: ADCMSP432E4.h:175
bool isProtected
Definition: ADCMSP432E4.h:187
Definition: ADCMSP432E4.h:134
Definition: ADCMSP432E4.h:133
struct ADCMSP432E4_Object ADCMSP432E4_Object
ADCMSP432 Object.
ADCMSP432E4 Hardware attributes These fields are used by driverlib APIs and therefore must be populat...
Definition: ADCMSP432E4.h:173
ADCMSP432E4_Module adcModule
Definition: ADCMSP432E4.h:176
bool isOpen
Definition: ADCMSP432E4.h:186
ADCMSP432E4_Sequencer
ADCMSP432E4 Sequencer These fields are used by ADCMSP432E4_HWAttrs to specify the sample sequencer fo...
Definition: ADCMSP432E4.h:132
Copyright 2018, Texas Instruments Incorporated