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  */
32 /*!****************************************************************************
33  * @file ADCBufMSP432E4.h
34  *
35  * @brief ADCBuf driver implementation for a MSP432E4 analog-to-digital
36  * converter
37  *
38  * # Driver include #
39  * The ADCBuf header file should be included in an application as follows:
40  * @code
41  * #include <ti/drivers/ADCBuf.h>
42  * #include <ti/drivers/adcbuf/ADCBufMSP432E4.h>
43  * @endcode
44  *
45  * # Overview #
46  * This driver takes \p n samples using the ADC and stores the results in a
47  * buffer. This implementation supports both #ADCBuf_RECURRENCE_MODE_ONE_SHOT
48  * and #ADCBuf_RECURRENCE_MODE_CONTINUOUS. The ADCBuf_MSP432E4 driver
49  * supports use of both ADC peripherals and their sample sequencers.
50  *
51  * # General Behavior #
52  * Each ADC module has four sample sequencers, SS0-SS3, that control and
53  * capture sample data. Sequencer priority can be initialized
54  * in #ADCBufMSP432E4_HWAttrsV1 by creating an array that holds the
55  * corresponding #ADCBufMSP432E4_SequencePriorities.
56  *
57  * The MSP432E4 ADC sample sequencers can be triggered by several
58  * different types of software and hardware events. The driver currently
59  * only supports #ADCBufMSP432E4_SOFTWARE_AUTOMATIC_TRIGGER and
60  * #ADCBufMSP432E4_TIMER_TRIGGER trigger sources.
61  *
62  * This driver supports various modes of operation and sampling.
63  * #ADCBufMSP432E4_HWAttrsV1.useDMA can be set to \p 1 to improve performance.
64  * Additionally, samples can be performed using #ADCBufMSP432E4_DIFFERENTIAL
65  * or #ADCBufMSP432E4_TEMPERATURE_MODE modes.
66  *
67  * The application should call ADCBuf_init() once per ADC module.
68  *
69  * Refer to @ref ADCBuf.h for a complete description of APIs & example use.
70  *
71  * ===========================================================================
72  */
73 
74 #ifndef ti_drivers_adcbuf_ADCBufMSP432E4__include
75 #define ti_drivers_adcbuf_ADCBufMSP432E4__include
76 
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80 
81 #include <stdint.h>
82 #include <stdbool.h>
83 
84 #include <ti/drivers/ADCBuf.h>
85 #include <ti/drivers/dpl/HwiP.h>
86 #include <ti/drivers/dpl/SemaphoreP.h>
88 #include <ti/devices/msp432e4/driverlib/adc.h>
89 
90 /*
91  * ADCBuf port/pin defines for pin configuration. Ports B, D, E, and K are
92  * configurable through the port mapping controller. None of the port
93  * mappings support ADC.
94  * Channel specifies the ADC channel and ranges from 0 to 23.
95  * pin range: 0 - 7, port range: 0 - 15
96  *
97  * 31-24 23-16 15-8 7-0
98  * -------------------------------------------
99  * | RESERVED | CHANNEL | PORT | PIN |
100  * -------------------------------------------
101  *
102  * channel = (((config) >> 16) & 0x1F)
103  * port = (((config << 4) & 0x000FF000) | 0x40000000)
104  * pin = ((config) & 0xFF)
105  *
106  */
107 
120 #define ADCBufMSP432E4_PB_4_A10 ((10 << 16) | 0x5910)
121 
126 #define ADCBufMSP432E4_PB_5_A11 ((11 << 16) | 0x5920)
127 
133 #define ADCBufMSP432E4_PD_0_A15 ((15 << 16) | 0x5B01)
134 
139 #define ADCBufMSP432E4_PD_1_A14 ((14 << 16) | 0x5B02)
140 
145 #define ADCBufMSP432E4_PD_2_A13 ((13 << 16) | 0x5B04)
146 
151 #define ADCBufMSP432E4_PD_3_A12 ((12 << 16) | 0x5B08)
152 
157 #define ADCBufMSP432E4_PD_4_A7 ((7 << 16) | 0x5B10)
158 
163 #define ADCBufMSP432E4_PD_5_A6 ((6 << 16) | 0x5B20)
164 
169 #define ADCBufMSP432E4_PD_6_A5 ((5 << 16) | 0x5B40)
170 
175 #define ADCBufMSP432E4_PD_7_A4 ((4 << 16) | 0x5B80)
176 
181 #define ADCBufMSP432E4_PE_0_A3 ((3 << 16) | 0x5C01)
182 
187 #define ADCBufMSP432E4_PE_1_A2 ((2 << 16) | 0x5C02)
188 
193 #define ADCBufMSP432E4_PE_2_A1 ((1 << 16) | 0x5C04)
194 
199 #define ADCBufMSP432E4_PE_3_A0 ((0 << 16) | 0x5C08)
200 
205 #define ADCBufMSP432E4_PE_4_A9 ((9 << 16) | 0x5C10)
206 
211 #define ADCBufMSP432E4_PE_5_A8 ((8 << 16) | 0x5C20)
212 
217 #define ADCBufMSP432E4_PE_6_A20 ((20 << 16) | 0x5C40)
218 
223 #define ADCBufMSP432E4_PE_7_A21 ((21 << 16) | 0x5C80)
224 
229 #define ADCBufMSP432E4_PK_0_A16 ((16 << 16) | 0x6101)
230 
235 #define ADCBufMSP432E4_PK_1_A17 ((17 << 16) | 0x6102)
236 
241 #define ADCBufMSP432E4_PK_2_A18 ((18 << 16) | 0x6104)
242 
247 #define ADCBufMSP432E4_PK_3_A19 ((19 << 16) | 0x6108)
248 
253 #define ADCBufMSP432E4_PP_6_A23 ((23 << 16) | 0x6540)
254 
259 #define ADCBufMSP432E4_PP_7_A22 ((22 << 16) | 0x6580)
260 
265 #define ADCBufMSP432E4_PIN_NONE 0
266 
270 #define MSP432E4_NUM_ADC_CHANNELS (24)
271 
273 #define ADCBufMSP432E4_SEQUENCER_COUNT 4
274 
275 /* ADC function table pointer */
277 
308 
311 
314 
317 
321 
336 
339 
342 
346 
358 
366 
378 
386 
424 
431  ADCBufMSP432E4_TIMER_TRIGGER = ADC_TRIGGER_TIMER,
433 
447 typedef enum ADCBufMSP432E4_Phase {
450 
453 
456 
459 
462 
465 
468 
471 
474 
477 
480 
483 
486 
489 
492 
496 
508 
511 
514 
517 
520 
523 
527 
538 
542 
553  ADCBufMSP432E4_SamplingDuration samplingDuration;
555 
601 typedef struct ADCBufMSP432E4_Channels {
603  uint32_t refVoltage;
604 
606  uint32_t adcPin;
607 
610 
616  ADCBufMSP432E4_DifferentialMode adcInputMode;
617 
622  ADCBufMSP432E4_InternalSourceMode adcInternalSource;
623 
631 
681 typedef struct ADCBufMSP432E4_HWAttrsV1 {
683  uint32_t intPriority;
684 
686  uint32_t adcBase;
687 
694  uint32_t adcTimerSource;
695 
698 
700  ADCBufMSP432E4_TriggerSource *adcTriggerSource;
701 
706  ADCBufMSP432E4_Phase modulePhase;
707 
709  ADCBufMSP432E4_ReferenceSource refSource;
710 
713 
718  uint8_t useDMA;
720 
721 /*
722  * @brief ADCBufMSP432E4 Object
723  *
724  * The application must not access any member variables of this structure!
725  */
726 typedef struct ADCBufMSP432E4_Object {
727  /* Grants exclusive access to ADC */
728  SemaphoreP_Handle mutex;
729  /* Notify finished ADC convert */
730  SemaphoreP_Handle convertComplete;
731 
732  /* Hardware interrupt handles, one per sequencer */
733  HwiP_Handle sequencerHwiHandles[4];
734 
735  /* PingPong flag indicates which sample buffer is active in the conversion */
736  uint_fast8_t pingpongFlag[4];
737  /* Count of sampling channels */
738  uint_fast8_t channelCount[4];
739  ADCBuf_Conversion *conversions[4];
740 
741  /* Callback function pointer */
743 
744  uint16_t *sampleBuffer[4];
745  /* Internal dec. conversion buffer counter */
746  uint_fast16_t sampleIndex[4];
747  /* Total sampling count per channel */
748  uint_fast16_t sampleCount[4];
749 
750  /* ADC sampling duration */
751  ADCBufMSP432E4_SamplingDuration samplingDuration;
752  /* Timeout for read semaphore in ADCBuf_RETURN_MODE_BLOCKING */
754  /* Frequency in Hz at which the ADC is triggered */
756  /* Should we convert continuously or one-shot */
758  /* Mode for all conversions */
761  /* To determine if the ADC is open */
762  bool isOpen;
764 
765 #ifdef __cplusplus
766 }
767 #endif
768 
769 #endif /* ti_drivers_adcbuf_ADCBufMSP432E4__include */
Definition: ADCBufMSP432E4.h:464
Definition: ADCBufMSP432E4.h:461
Definition: ADCBufMSP432E4.h:313
struct ADCBufMSP432E4_Object ADCBufMSP432E4_Object
MSP432E4 ADCBuf_Params Parameter Extensions.
Definition: ADCBufMSP432E4.h:551
Definition: ADCBufMSP432E4.h:338
enum ADCBuf_Recurrence_Mode_ ADCBuf_Recurrence_Mode
ADC trigger mode settings.
UDMAMSP432E4 Global configuration.
Definition: UDMAMSP432E4.h:143
ADCBufMSP432E4 Channel Settings.
Definition: ADCBufMSP432E4.h:601
Definition: ADCBufMSP432E4.h:519
ADCBufMSP432E4_InternalSourceMode
ADCBufMSP432E4 Internal Source Mode.
Definition: ADCBufMSP432E4.h:355
const ADCBuf_FxnTable ADCBufMSP432E4_fxnTable
struct ADCBufMSP432E4_ParamsExtension ADCBufMSP432E4_ParamsExtension
MSP432E4 ADCBuf_Params Parameter Extensions.
SemaphoreP_Handle convertComplete
Definition: ADCBufMSP432E4.h:730
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:686
ADCBufMSP432E4_Sequencer
ADCBufMSP432E4 Sequencer.
Definition: ADCBufMSP432E4.h:333
uDMA driver implementation for MSP432E4.
ADCBuf_Callback callBackFxn
Definition: ADCBufMSP432E4.h:742
ADCBuf driver interface.
UDMAMSP432E4_Handle dmaHandle
Definition: ADCBufMSP432E4.h:760
enum ADCBuf_Return_Mode_ ADCBuf_Return_Mode
ADC return mode settings.
Definition: ADCBufMSP432E4.h:377
Definition: ADCBufMSP432E4.h:364
Definition: ADCBufMSP432E4.h:513
Definition: ADCBufMSP432E4.h:467
Definition: ADCBufMSP432E4.h:482
uint8_t useDMA
Definition: ADCBufMSP432E4.h:718
uint32_t adcDifferentialPin
Definition: ADCBufMSP432E4.h:629
Definition: ADCBufMSP432E4.h:476
Definition: ADCBufMSP432E4.h:316
uint32_t intPriority
Definition: ADCBufMSP432E4.h:683
Definition: ADCBufMSP432E4.h:344
Definition: ADCBufMSP432E4.h:473
Definition: ADCBufMSP432E4.h:449
SemaphoreP_Handle mutex
Definition: ADCBufMSP432E4.h:728
Definition: ADCBufMSP432E4.h:319
Definition: ADCBufMSP432E4.h:488
Definition: ADCBufMSP432E4.h:470
uint32_t refVoltage
Definition: ADCBufMSP432E4.h:603
ADCBufMSP432E4_Phase
ADCBufMSP432E4 phase delay.
Definition: ADCBufMSP432E4.h:447
ADCBufMSP432E4_SequencePriorities
ADCBufMSP432E4 Sequencer Priorities.
Definition: ADCBufMSP432E4.h:305
Definition: ADCBufMSP432E4.h:540
bool isOpen
Definition: ADCBufMSP432E4.h:762
Definition: ADCBufMSP432E4.h:494
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:431
ADCBufMSP432E4_InternalSourceMode adcInternalSource
Definition: ADCBufMSP432E4.h:622
uint32_t adcTimerSource
Definition: ADCBufMSP432E4.h:694
ADCBuf_Recurrence_Mode recurrenceMode
Definition: ADCBufMSP432E4.h:757
Definition: ADCBufMSP432E4.h:491
ADCBufMSP432E4_SequencePriorities * sequencePriority
Definition: ADCBufMSP432E4.h:712
ADCBufMSP432E4_DifferentialMode
ADCBufMSP432E4 Differential Mode.
Definition: ADCBufMSP432E4.h:375
Definition: ADCBufMSP432E4.h:516
ADCBufMSP432E4_Sequencer adcSequence
Definition: ADCBufMSP432E4.h:609
Definition: ADCBufMSP432E4.h:455
Definition: ADCBufMSP432E4.h:335
ADCBufMSP432E4_Phase modulePhase
Definition: ADCBufMSP432E4.h:706
ADCBufMSP432E4_ReferenceSource
ADCBufMSP432E4 Reference Source.
Definition: ADCBufMSP432E4.h:535
Definition: ADCBufMSP432E4.h:307
Definition: ADCBufMSP432E4.h:479
Definition: ADCBufMSP432E4.h:357
ADCBufMSP432E4_SamplingDuration samplingDuration
Definition: ADCBufMSP432E4.h:553
ADCBufMSP432E4_ReferenceSource refSource
Definition: ADCBufMSP432E4.h:709
struct ADCBufMSP432E4_HWAttrsV1 ADCBufMSP432E4_HWAttrsV1
ADCBufMSP432E4 Hardware attributes.
Definition: ADCBufMSP432E4.h:522
ADCBufMSP432E4_SamplingDuration samplingDuration
Definition: ADCBufMSP432E4.h:751
ADCBufMSP432E4_SamplingDuration
ADCMSP432E4 Sampling Duration.
Definition: ADCBufMSP432E4.h:505
ADCBufMSP432E4_DifferentialMode adcInputMode
Definition: ADCBufMSP432E4.h:616
Definition: ADCBufMSP432E4.h:507
uint32_t semaphoreTimeout
Definition: ADCBufMSP432E4.h:753
ADCBufMSP432E4_TriggerSource
ADCBufMSP432E4 Trigger Source.
Definition: ADCBufMSP432E4.h:414
Definition: ADCBufMSP432E4.h:341
Definition: ADCBufMSP432E4.h:537
struct ADCBufMSP432E4_Channels ADCBufMSP432E4_Channels
ADCBufMSP432E4 Channel Settings.
Definition: ADCBufMSP432E4.h:452
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:485
uint32_t samplingFrequency
Definition: ADCBufMSP432E4.h:755
Definition: ADCBufMSP432E4.h:510
Definition: ADCBufMSP432E4.h:384
uint32_t adcPin
Definition: ADCBufMSP432E4.h:606
Definition: ADCBufMSP432E4.h:458
ADCBufMSP432E4 Hardware attributes.
Definition: ADCBufMSP432E4.h:681
ADCBufMSP432E4_Channels * channelSetting
Definition: ADCBufMSP432E4.h:697
Definition: ADCBufMSP432E4.h:423
Definition: ADCBufMSP432E4.h:310
Definition: ADCBufMSP432E4.h:726
ADCBufMSP432E4_TriggerSource * adcTriggerSource
Definition: ADCBufMSP432E4.h:700
Definition: ADCBufMSP432E4.h:525
ADCBuf_Return_Mode returnMode
Definition: ADCBufMSP432E4.h:759
© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale