ADCBufMSP432E4.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  */
51 #ifndef ti_drivers_adcbuf_ADCBufMSP432E4__include
52 #define ti_drivers_adcbuf_ADCBufMSP432E4__include
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 #include <stdint.h>
59 #include <stdbool.h>
60 
61 #include <ti/drivers/ADCBuf.h>
62 #include <ti/drivers/dpl/HwiP.h>
63 #include <ti/drivers/dpl/SemaphoreP.h>
65 #include <ti/devices/msp432e4/driverlib/adc.h>
66 
67 /*
68  * ADCBuf port/pin defines for pin configuration. Ports B, D, E, and K are
69  * configurable through the port mapping controller. None of the port
70  * mappings support ADC.
71  * Channel specifies the ADC channel and ranges from 0 to 19.
72  * pin range: 0 - 7, port range: 0 - 15
73  *
74  *
75  * 15 - 10 19 - 16 15 - 8 7 - 0
76  * ---------------------------------
77  * | CHANNEL | X | X | PORT | PIN |
78  * ---------------------------------
79  *
80  * channel = (((config) >> 10) & 0x1F)
81  * port = (((config) << 4) & 0x40000000)
82  * pin = ((config) & 0xFF)
83  *
84  *
85  */
86 /* Port B */
87 #define ADCBufMSP432E4_PB_4_A10 ((10 << 16) | 0x5910) /* ch 10, port B, pin 4 */
88 #define ADCBufMSP432E4_PB_5_A11 ((11 << 16) | 0x5920) /* ch 11, port B, pin 5 */
89 
90 /* Port D */
91 #define ADCBufMSP432E4_PD_0_A15 ((15 << 16) | 0x5B01) /* ch 15, port D, pin 0 */
92 #define ADCBufMSP432E4_PD_1_A14 ((14 << 16) | 0x5B02) /* ch 14, port D, pin 1 */
93 #define ADCBufMSP432E4_PD_2_A13 ((13 << 16) | 0x5B04) /* ch 13, port D, pin 2 */
94 #define ADCBufMSP432E4_PD_3_A12 ((12 << 16) | 0x5B08) /* ch 12, port D, pin 3 */
95 #define ADCBufMSP432E4_PD_4_A7 ((7 << 16) | 0x5B10) /* ch 7, port D, pin 4 */
96 #define ADCBufMSP432E4_PD_5_A6 ((6 << 16) | 0x5B20) /* ch 6, port D, pin 5 */
97 #define ADCBufMSP432E4_PD_6_A5 ((5 << 16) | 0x5B40) /* ch 5, port D, pin 6 */
98 #define ADCBufMSP432E4_PD_7_A4 ((4 << 16) | 0x5B80) /* ch 4, port D, pin 7 */
99 
100 /* Port E */
101 #define ADCBufMSP432E4_PE_0_A3 ((3 << 16) | 0x5C01) /* ch 3, port E, pin 0 */
102 #define ADCBufMSP432E4_PE_1_A2 ((2 << 16) | 0x5C02) /* ch 2, port E, pin 1 */
103 #define ADCBufMSP432E4_PE_2_A1 ((1 << 16) | 0x5C04) /* ch 1, port E, pin 2 */
104 #define ADCBufMSP432E4_PE_3_A0 ((0 << 16) | 0x5C08) /* ch 0, port E, pin 3 */
105 #define ADCBufMSP432E4_PE_4_A9 ((9 << 16) | 0x5C10) /* ch 9, port E, pin 4 */
106 #define ADCBufMSP432E4_PE_5_A8 ((8 << 16) | 0x5C20) /* ch 8, port E, pin 5 */
107 #define ADCBufMSP432E4_PE_6_A20 ((20 << 16) | 0x5C40) /* ch 20, port E, pin 6 */
108 #define ADCBufMSP432E4_PE_7_A21 ((21 << 16) | 0x5C80) /* ch 21, port E, pin 7 */
109 
110 /* Port K */
111 #define ADCBufMSP432E4_PK_0_A16 ((16 << 16) | 0x6101) /* ch 16, port K, pin 0 */
112 #define ADCBufMSP432E4_PK_1_A17 ((17 << 16) | 0x6102) /* ch 17, port K, pin 1 */
113 #define ADCBufMSP432E4_PK_2_A18 ((18 << 16) | 0x6104) /* ch 18, port K, pin 2 */
114 #define ADCBufMSP432E4_PK_3_A19 ((19 << 16) | 0x6108) /* ch 19, port K, pin 3 */
115 
116 /* Port P */
117 #define ADCBufMSP432E4_PP_6_A22 ((22 << 16) | 0x6540) /* ch 22, port P, pin 6 */
118 #define ADCBufMSP432E4_PP_7_A23 ((23 << 16) | 0x6580) /* ch 23, port P, pin 7 */
119 
120  /*
121  * =============================================================================
122  * Constants
123  * =============================================================================
124  */
125 #define ADCBufMSP432E4_PIN_NONE 0
126 
127 /* Number of available ADC channels on device */
128 #define MSP432E4_NUM_ADC_CHANNELS (24)
129 
130 /* Number of ADC Sequencers per Module */
131 #define ADCBufMSP432E4_SEQUENCER_COUNT 4
132 
133 /* ADC function table pointer */
135 
149 
161 
171 
181 
189  ADCBufMSP432E4_TIMER_TRIGGER = ADC_TRIGGER_TIMER,
191 
197 typedef enum ADCBufMSP432E4_Phase {
215 
232 
243 
252  ADCBufMSP432E4_SamplingDuration samplingDuration;
254 
261 typedef struct ADCBufMSP432E4_Channels {
262  uint32_t refVoltage;
263  uint_fast16_t adcPin;
265  ADCBufMSP432E4_DifferentialMode adcInputMode;
266  ADCBufMSP432E4_InternalSourceMode adcInternalSource;
267  uint_fast16_t adcDifferentialPin;
269 
303 typedef struct ADCBufMSP432E4_HWAttrsV1 {
304  uint32_t intPriority;
305  uint32_t adcBase;
306  uint32_t adcTimerSource;
308  ADCBufMSP432E4_TriggerSource *adcTriggerSource;
309  ADCBufMSP432E4_Phase modulePhase;
310  ADCBufMSP432E4_ReferenceSource refSource;
312  uint8_t useDMA;
314 
320 typedef struct ADCBufMSP432E4_Object {
321  SemaphoreP_Handle mutex; /* Grants exclusive access to ADC */
322  SemaphoreP_Handle convertComplete; /* Notify finished ADC convert */
323  HwiP_Handle sequencerHwiHandles[4]; /* Hardware interrupt handles, one per sequencer */
324 
325  uint_fast8_t pingpongFlag[4]; /* PingPong flag indicates which sample buffer is active in the conversion */
326  uint_fast8_t channelCount[4]; /* Count of sampling channels */
327  ADCBuf_Conversion *conversions[4];
328 
329  ADCBuf_Callback callBackFxn; /* Callback function pointer */
330 
331  uint16_t *sampleBuffer[4];
332  uint_fast16_t sampleIndex[4]; /* Internal dec. conversion buffer counter */
333  uint_fast16_t sampleCount[4]; /* Total sampling count per channel */
334 
335  ADCBufMSP432E4_SamplingDuration samplingDuration;
336  uint32_t semaphoreTimeout;
337  uint32_t samplingFrequency;
341  bool isOpen; /* To determine if the ADC is open */
342 
344 
346  uint32_t timerSource;
347  uint32_t timerInstances;
348  uint32_t timerFrequency;
351 
352 #ifdef __cplusplus
353 }
354 #endif
355 
356 #endif /* ti_drivers_adcbuf_ADCBufMSP432E4__include */
Definition: ADCBufMSP432E4.h:203
uint32_t timerInstances
Definition: ADCBufMSP432E4.h:347
Definition: ADCBufMSP432E4.h:202
Definition: ADCBufMSP432E4.h:145
struct ADCBufMSP432E4_Object ADCBufMSP432E4_Object
ADCBufMSP432E4 Object.
struct ADCBufMSP432E4_TimerSettings ADCBufMSP432E4_TimerSettings
MSP432E4 specfic extension to ADCBuf_Params.
Definition: ADCBufMSP432E4.h:251
Definition: ADCBufMSP432E4.h:157
enum ADCBuf_Recurrence_Mode_ ADCBuf_Recurrence_Mode
ADC trigger mode settings.
UDMAMSP432E4 Global configuration.
Definition: UDMAMSP432E4.h:151
ADCBufMSP432E4 Channel setting These fields define channel-specific settings: GPIO, reference voltage, temperature mode, etc. These settings happen when ADCBuf_convert() is called.
Definition: ADCBufMSP432E4.h:261
Definition: ADCBufMSP432E4.h:228
ADCBufMSP432E4_InternalSourceMode
ADCBufMSP432E4 Internal Source Mode These fields are used by ADCBufMSP432E4_HWAttrsV1 to specify if a...
Definition: ADCBufMSP432E4.h:167
const ADCBuf_FxnTable ADCBufMSP432E4_fxnTable
struct ADCBufMSP432E4_ParamsExtension ADCBufMSP432E4_ParamsExtension
MSP432E4 specfic extension to ADCBuf_Params.
SemaphoreP_Handle convertComplete
Definition: ADCBufMSP432E4.h:322
An ADCBuf_Conversion data structure is used with ADCBuf_convert(). It indicates which channel to perf...
Definition: ADCBuf.h:237
uint32_t adcBase
Definition: ADCBufMSP432E4.h:305
ADCBufMSP432E4_Sequencer
ADCBufMSP432E4 Sequencer These fields are used by ADCBufMSP432E4_HWAttrsV1 to specify which ADC seque...
Definition: ADCBufMSP432E4.h:155
uDMA driver implementation for MSP432E4.
ADCBuf_Callback callBackFxn
Definition: ADCBufMSP432E4.h:329
ADCBuf driver interface.
UDMAMSP432E4_Handle dmaHandle
Definition: ADCBufMSP432E4.h:340
enum ADCBuf_Return_Mode_ ADCBuf_Return_Mode
ADC return mode settings.
Definition: ADCBufMSP432E4.h:178
Definition: ADCBufMSP432E4.h:169
Definition: ADCBufMSP432E4.h:226
Definition: ADCBufMSP432E4.h:204
Definition: ADCBufMSP432E4.h:209
uint8_t useDMA
Definition: ADCBufMSP432E4.h:312
Definition: ADCBufMSP432E4.h:207
Definition: ADCBufMSP432E4.h:146
uint32_t intPriority
Definition: ADCBufMSP432E4.h:304
Definition: ADCBufMSP432E4.h:159
uint_fast16_t adcDifferentialPin
Definition: ADCBufMSP432E4.h:267
Definition: ADCBufMSP432E4.h:206
Definition: ADCBufMSP432E4.h:198
uint32_t timerSource
Definition: ADCBufMSP432E4.h:346
SemaphoreP_Handle mutex
Definition: ADCBufMSP432E4.h:321
Definition: ADCBufMSP432E4.h:147
Definition: ADCBufMSP432E4.h:211
Definition: ADCBufMSP432E4.h:205
uint32_t refVoltage
Definition: ADCBufMSP432E4.h:262
ADCBufMSP432E4_Phase
ADCBufMSP432E4 phase delay These fields are used by ADCBufMSP432E4_HWAttrsV1 to specify the phase del...
Definition: ADCBufMSP432E4.h:197
ADCBufMSP432E4_SequencePriorities
ADCBufMSP432E4 Sequencer Priorities These fields are used by ADCBufMSP432E4_HWAttrsV1 to specify the ...
Definition: ADCBufMSP432E4.h:142
Definition: ADCBufMSP432E4.h:241
bool isOpen
Definition: ADCBufMSP432E4.h:341
Definition: ADCBufMSP432E4.h:213
The definition of an ADCBuf function table that contains the required set of functions to control a s...
Definition: ADCBuf.h:385
Definition: ADCBufMSP432E4.h:189
ADCBufMSP432E4_InternalSourceMode adcInternalSource
Definition: ADCBufMSP432E4.h:266
uint32_t adcTimerSource
Definition: ADCBufMSP432E4.h:306
ADCBuf_Recurrence_Mode recurrenceMode
Definition: ADCBufMSP432E4.h:338
Definition: ADCBufMSP432E4.h:212
ADCBufMSP432E4_SequencePriorities * sequencePriority
Definition: ADCBufMSP432E4.h:311
uint_fast16_t adcPin
Definition: ADCBufMSP432E4.h:263
ADCBufMSP432E4_DifferentialMode
ADCBufMSP432E4 Differential Mode These fields are used by ADCBufMSP432E4_HWAttrsV1 to specify if ADC ...
Definition: ADCBufMSP432E4.h:177
Definition: ADCBufMSP432E4.h:227
uint32_t timerFrequency
Definition: ADCBufMSP432E4.h:348
ADCBufMSP432E4_Sequencer adcSequence
Definition: ADCBufMSP432E4.h:264
Definition: ADCBufMSP432E4.h:200
Definition: ADCBufMSP432E4.h:156
ADCBufMSP432E4_Phase modulePhase
Definition: ADCBufMSP432E4.h:309
ADCBufMSP432E4_ReferenceSource
ADCBufMSP432E4 reference source These fields are used by ADCBufMSP432E4_HWAttrsV1 to specify the refe...
Definition: ADCBufMSP432E4.h:239
Definition: ADCBufMSP432E4.h:143
Definition: ADCBufMSP432E4.h:345
Definition: ADCBufMSP432E4.h:208
Definition: ADCBufMSP432E4.h:168
ADCBufMSP432E4_SamplingDuration samplingDuration
Definition: ADCBufMSP432E4.h:252
ADCBufMSP432E4_ReferenceSource refSource
Definition: ADCBufMSP432E4.h:310
struct ADCBufMSP432E4_HWAttrsV1 ADCBufMSP432E4_HWAttrsV1
ADCBufMSP432E4 Hardware attributes These fields are populated by PinMux tool but user is allowed to c...
bool isInitialized
Definition: ADCBufMSP432E4.h:349
Definition: ADCBufMSP432E4.h:229
ADCBufMSP432E4_SamplingDuration samplingDuration
Definition: ADCBufMSP432E4.h:335
ADCBufMSP432E4_SamplingDuration
ADCMSP432E4 sampling duration These fields define the MSP432E4 ADC sampling duration (sample and hold...
Definition: ADCBufMSP432E4.h:223
ADCBufMSP432E4_DifferentialMode adcInputMode
Definition: ADCBufMSP432E4.h:265
Definition: ADCBufMSP432E4.h:224
uint32_t semaphoreTimeout
Definition: ADCBufMSP432E4.h:336
ADCBufMSP432E4_TriggerSource
ADCBufMSP432E4 trigger source These fields are used by ADCBufMSP432E4_HWAttrsV1 to specify the trigge...
Definition: ADCBufMSP432E4.h:187
Definition: ADCBufMSP432E4.h:158
Definition: ADCBufMSP432E4.h:240
struct ADCBufMSP432E4_Channels ADCBufMSP432E4_Channels
ADCBufMSP432E4 Channel setting These fields define channel-specific settings: GPIO, reference voltage, temperature mode, etc. These settings happen when ADCBuf_convert() is called.
Definition: ADCBufMSP432E4.h:199
void(* ADCBuf_Callback)(ADCBuf_Handle handle, ADCBuf_Conversion *conversion, void *completedADCBuffer, uint32_t completedChannel)
The definition of a callback function used by the ADC driver when used in ADCBuf_RETURN_MODE_CALLBACK...
Definition: ADCBuf.h:251
Definition: ADCBufMSP432E4.h:210
uint32_t samplingFrequency
Definition: ADCBufMSP432E4.h:337
Definition: ADCBufMSP432E4.h:225
Definition: ADCBufMSP432E4.h:179
Definition: ADCBufMSP432E4.h:201
ADCBufMSP432E4 Hardware attributes These fields are populated by PinMux tool but user is allowed to c...
Definition: ADCBufMSP432E4.h:303
ADCBufMSP432E4_Channels * channelSetting
Definition: ADCBufMSP432E4.h:307
Definition: ADCBufMSP432E4.h:188
Definition: ADCBufMSP432E4.h:144
ADCBufMSP432E4 Object.
Definition: ADCBufMSP432E4.h:320
ADCBufMSP432E4_TriggerSource * adcTriggerSource
Definition: ADCBufMSP432E4.h:308
Definition: ADCBufMSP432E4.h:230
ADCBuf_Return_Mode returnMode
Definition: ADCBufMSP432E4.h:339
Copyright 2018, Texas Instruments Incorporated