MSPM0L11XX_L13XX Driver Library  2.05.01.00
dl_gpamp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, 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 dl_gpamp.h
34  * @brief General Purpose Amplifier (GPAMP)
35  * @defgroup GPAMP General Purpose Amplifier (GPAMP)
36  *
37  ******************************************************************************
38  */
42 #ifndef ti_dl_m0p_dl_gpamp__include
43 #define ti_dl_m0p_dl_gpamp__include
44 
45 #include <stdbool.h>
46 #include <stdint.h>
47 
48 #include <ti/devices/msp/msp.h>
49 #include <ti/driverlib/dl_common.h>
50 
51 #ifdef __MSPM0_HAS_GPAMP__
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
58 typedef enum {
60  DL_GPAMP_NSEL_OUTPUT_PIN = SYSCTL_PMUOPAMP_NSEL_SEL0,
62  DL_GPAMP_NSEL_IN_NEG = SYSCTL_PMUOPAMP_NSEL_SEL1,
64  DL_GPAMP_NSEL_INTERNAL_OUTPUT = SYSCTL_PMUOPAMP_NSEL_SEL2,
66  DL_GPAMP_NSEL_OPEN = SYSCTL_PMUOPAMP_NSEL_SEL3,
68 
70 typedef enum {
72  DL_GPAMP_PSEL_OPEN = SYSCTL_PMUOPAMP_PCHENABLE_FALSE,
74  DL_GPAMP_PSEL_IN_POS = SYSCTL_PMUOPAMP_PCHENABLE_TRUE,
76 
78 typedef enum {
80  DL_GPAMP_OUTPUT_PIN_STATE_DISABLED = SYSCTL_PMUOPAMP_OUTENABLE_FALSE,
82  DL_GPAMP_OUTPUT_PIN_STATE_ENABLED = SYSCTL_PMUOPAMP_OUTENABLE_TRUE,
84 
86 typedef enum {
88  DL_GPAMP_RRI_MODE_PMOS_INPUT = SYSCTL_PMUOPAMP_RRI_MODE0,
90  DL_GPAMP_RRI_MODE_NMOS_INPUT = SYSCTL_PMUOPAMP_RRI_MODE1,
92  DL_GPAMP_RRI_MODE_RAIL_TO_RAIL = SYSCTL_PMUOPAMP_RRI_MODE2,
94  DL_GPAMP_RRI_MODE_SAMPLE_CHANNEL_0 = SYSCTL_PMUOPAMP_RRI_MODE3,
95 
97 
99 typedef enum {
101  DL_GPAMP_CHOPPING_FREQ_16KHZ = SYSCTL_PMUOPAMP_CHOPCLKFREQ_CLK16KHZ,
103  DL_GPAMP_CHOPPING_FREQ_8KHZ = SYSCTL_PMUOPAMP_CHOPCLKFREQ_CLK8KHZ,
105  DL_GPAMP_CHOPPING_FREQ_4KHZ = SYSCTL_PMUOPAMP_CHOPCLKFREQ_CLK4KHZ,
107  DL_GPAMP_CHOPPING_FREQ_2KHZ = SYSCTL_PMUOPAMP_CHOPCLKFREQ_CLK2KHZ,
109 
111 typedef enum {
113  DL_GPAMP_CHOPPING_MODE_DISABLED = SYSCTL_PMUOPAMP_CHOPCLKMODE_CHOPDISABLED,
115  DL_GPAMP_CHOPPING_MODE_STANDARD = SYSCTL_PMUOPAMP_CHOPCLKMODE_REGCHOP,
118  SYSCTL_PMUOPAMP_CHOPCLKMODE_ADCASSIST,
120 
124 typedef struct {
126  DL_GPAMP_CHOPPING_MODE choppingMode;
128  DL_GPAMP_CHOPPING_FREQ choppingFreq;
130  DL_GPAMP_OUTPUT_PIN_STATE outputPinState;
132  DL_GPAMP_PSEL pselChannel;
134  DL_GPAMP_NSEL nselChannel;
136 
137 /* clang-format on */
138 
142 __STATIC_INLINE void DL_GPAMP_enable(void)
143 {
144  SYSCTL->SOCLOCK.PMUOPAMP |= SYSCTL_PMUOPAMP_ENABLE_TRUE;
145 }
146 
155 __STATIC_INLINE bool DL_GPAMP_isEnabled(void)
156 {
157  return ((SYSCTL->SOCLOCK.PMUOPAMP & SYSCTL_PMUOPAMP_ENABLE_MASK) ==
158  SYSCTL_PMUOPAMP_ENABLE_TRUE);
159 }
160 
164 __STATIC_INLINE void DL_GPAMP_disable(void)
165 {
166  SYSCTL->SOCLOCK.PMUOPAMP &= ~(SYSCTL_PMUOPAMP_ENABLE_MASK);
167 }
168 
178 __STATIC_INLINE void DL_GPAMP_init(DL_GPAMP_Config *config)
179 {
180  DL_Common_updateReg(&SYSCTL->SOCLOCK.PMUOPAMP,
181  (uint32_t) config->choppingMode | (uint32_t) config->choppingFreq |
182  (uint32_t) config->outputPinState |
183  (uint32_t) config->pselChannel | (uint32_t) config->nselChannel,
184  SYSCTL_PMUOPAMP_CHOPCLKMODE_MASK | SYSCTL_PMUOPAMP_CHOPCLKFREQ_MASK |
185  SYSCTL_PMUOPAMP_OUTENABLE_MASK | SYSCTL_PMUOPAMP_PCHENABLE_MASK |
186  SYSCTL_PMUOPAMP_NSEL_MASK);
187 }
188 
192 __STATIC_INLINE void DL_GPAMP_enableNonInvertingInputChannel(void)
193 {
194  SYSCTL->SOCLOCK.PMUOPAMP |= SYSCTL_PMUOPAMP_PCHENABLE_TRUE;
195 }
196 
206 {
207  return ((SYSCTL->SOCLOCK.PMUOPAMP & SYSCTL_PMUOPAMP_PCHENABLE_MASK) ==
208  SYSCTL_PMUOPAMP_PCHENABLE_TRUE);
209 }
210 
215 {
216  SYSCTL->SOCLOCK.PMUOPAMP &= ~(SYSCTL_PMUOPAMP_PCHENABLE_MASK);
217 }
218 
226  DL_GPAMP_NSEL inputChannel)
227 {
228  DL_Common_updateReg(&SYSCTL->SOCLOCK.PMUOPAMP, (uint32_t) inputChannel,
229  SYSCTL_PMUOPAMP_NSEL_MASK);
230 }
231 
239 __STATIC_INLINE DL_GPAMP_NSEL DL_GPAMP_getInvertingInputChannel(void)
240 {
241  uint32_t nsel = (SYSCTL->SOCLOCK.PMUOPAMP & SYSCTL_PMUOPAMP_NSEL_MASK);
242 
243  return (DL_GPAMP_NSEL)(nsel);
244 }
245 
251 __STATIC_INLINE void DL_GPAMP_setRailToRailInputMode(DL_GPAMP_RRI_MODE mode)
252 {
254  &SYSCTL->SOCLOCK.PMUOPAMP, (uint32_t) mode, SYSCTL_PMUOPAMP_RRI_MASK);
255 }
256 
264 __STATIC_INLINE DL_GPAMP_RRI_MODE DL_GPAMP_getRailToRailInputMode(void)
265 {
266  uint32_t mode = (SYSCTL->SOCLOCK.PMUOPAMP & SYSCTL_PMUOPAMP_RRI_MASK);
267 
268  return (DL_GPAMP_RRI_MODE)(mode);
269 }
270 
274 __STATIC_INLINE void DL_GPAMP_enableOutputToPad(void)
275 {
276  SYSCTL->SOCLOCK.PMUOPAMP |= SYSCTL_PMUOPAMP_OUTENABLE_TRUE;
277 }
278 
287 __STATIC_INLINE bool DL_GPAMP_isOutputToPadEnabled(void)
288 {
289  return ((SYSCTL->SOCLOCK.PMUOPAMP & SYSCTL_PMUOPAMP_OUTENABLE_MASK) ==
290  SYSCTL_PMUOPAMP_OUTENABLE_TRUE);
291 }
292 
296 __STATIC_INLINE void DL_GPAMP_disableOutputToPad(void)
297 {
298  SYSCTL->SOCLOCK.PMUOPAMP &= ~(SYSCTL_PMUOPAMP_OUTENABLE_MASK);
299 }
300 
307 __STATIC_INLINE void DL_GPAMP_setChoppingFrequency(
308  DL_GPAMP_CHOPPING_FREQ frequency)
309 {
310  DL_Common_updateReg(&SYSCTL->SOCLOCK.PMUOPAMP, (uint32_t) frequency,
311  SYSCTL_PMUOPAMP_CHOPCLKFREQ_MASK);
312 }
313 
321 __STATIC_INLINE DL_GPAMP_CHOPPING_FREQ DL_GPAMP_getChoppingFrequency(void)
322 {
323  uint32_t freq =
324  (SYSCTL->SOCLOCK.PMUOPAMP & SYSCTL_PMUOPAMP_CHOPCLKFREQ_MASK);
325 
326  return (DL_GPAMP_CHOPPING_FREQ)(freq);
327 }
328 
335 __STATIC_INLINE void DL_GPAMP_setChoppingMode(DL_GPAMP_CHOPPING_MODE mode)
336 {
337  DL_Common_updateReg(&SYSCTL->SOCLOCK.PMUOPAMP, (uint32_t) mode,
338  SYSCTL_PMUOPAMP_CHOPCLKMODE_MASK);
339 }
340 
348 __STATIC_INLINE DL_GPAMP_CHOPPING_MODE DL_GPAMP_getChoppingMode(void)
349 {
350  uint32_t mode =
351  (SYSCTL->SOCLOCK.PMUOPAMP & SYSCTL_PMUOPAMP_CHOPCLKMODE_MASK);
352 
353  return (DL_GPAMP_CHOPPING_MODE)(mode);
354 }
355 
356 /* clang-format on */
357 
358 #ifdef __cplusplus
359 }
360 #endif
361 
362 #endif /* __MSPM0_HAS_GPAMP__ */
363 
364 #endif /* ti_dl_m0p_dl_gpamp__include */
365 
Definition: dl_gpamp.h:115
__STATIC_INLINE void DL_GPAMP_setInvertingInputChannel(DL_GPAMP_NSEL inputChannel)
Set the inverting input channel.
Definition: dl_gpamp.h:225
__STATIC_INLINE void DL_Common_updateReg(volatile uint32_t *reg, uint32_t val, uint32_t mask)
Writes value to specified register - retaining bits unaffected by mask.
Definition: dl_common.h:63
Definition: dl_gpamp.h:103
__STATIC_INLINE void DL_GPAMP_setChoppingMode(DL_GPAMP_CHOPPING_MODE mode)
Set the chopping mode.
Definition: dl_gpamp.h:335
Definition: dl_gpamp.h:101
__STATIC_INLINE void DL_GPAMP_setChoppingFrequency(DL_GPAMP_CHOPPING_FREQ frequency)
Set the chopping clock frequency.
Definition: dl_gpamp.h:307
Definition: dl_gpamp.h:64
Definition: dl_gpamp.h:88
Definition: dl_gpamp.h:90
DL_GPAMP_CHOPPING_MODE
Definition: dl_gpamp.h:111
Definition: dl_gpamp.h:60
DL_GPAMP_OUTPUT_PIN_STATE
Definition: dl_gpamp.h:78
__STATIC_INLINE void DL_GPAMP_disableNonInvertingInputChannel(void)
Disable the non-inverting input channel.
Definition: dl_gpamp.h:214
__STATIC_INLINE void DL_GPAMP_enableNonInvertingInputChannel(void)
Enable the non-inverting input channel.
Definition: dl_gpamp.h:192
Definition: dl_gpamp.h:82
DL_GPAMP_CHOPPING_MODE choppingMode
Definition: dl_gpamp.h:126
__STATIC_INLINE void DL_GPAMP_setRailToRailInputMode(DL_GPAMP_RRI_MODE mode)
Set the rail-to-rail input (RRI) mode.
Definition: dl_gpamp.h:251
Definition: dl_gpamp.h:72
DriverLib Common APIs.
__STATIC_INLINE bool DL_GPAMP_isEnabled(void)
Checks if the GPAMP peripheral is enabled.
Definition: dl_gpamp.h:155
Definition: dl_gpamp.h:94
DL_GPAMP_CHOPPING_FREQ
Definition: dl_gpamp.h:99
__STATIC_INLINE DL_GPAMP_RRI_MODE DL_GPAMP_getRailToRailInputMode(void)
Get the rail-to-rail input (RRI) mode.
Definition: dl_gpamp.h:264
__STATIC_INLINE bool DL_GPAMP_isNonInvertingInputChannelEnabled(void)
Checks if the non-inverting input channel is enabled.
Definition: dl_gpamp.h:205
Definition: dl_gpamp.h:117
DL_GPAMP_OUTPUT_PIN_STATE outputPinState
Definition: dl_gpamp.h:130
__STATIC_INLINE DL_GPAMP_CHOPPING_FREQ DL_GPAMP_getChoppingFrequency(void)
Get the chopping clock frequency.
Definition: dl_gpamp.h:321
DL_GPAMP_PSEL
Definition: dl_gpamp.h:70
Definition: dl_gpamp.h:62
Definition: dl_gpamp.h:74
DL_GPAMP_RRI_MODE
Definition: dl_gpamp.h:86
__STATIC_INLINE void DL_GPAMP_disableOutputToPad(void)
Disable output to pad.
Definition: dl_gpamp.h:296
DL_GPAMP_NSEL nselChannel
Definition: dl_gpamp.h:134
__STATIC_INLINE void DL_GPAMP_enable(void)
Enable the GPAMP peripheral.
Definition: dl_gpamp.h:142
__STATIC_INLINE DL_GPAMP_CHOPPING_MODE DL_GPAMP_getChoppingMode(void)
Get the chopping mode.
Definition: dl_gpamp.h:348
Definition: dl_gpamp.h:113
DL_GPAMP_NSEL
Definition: dl_gpamp.h:58
__STATIC_INLINE void DL_GPAMP_disable(void)
Disable the GPAMP peripheral.
Definition: dl_gpamp.h:164
__STATIC_INLINE void DL_GPAMP_init(DL_GPAMP_Config *config)
Initialize the GPAmp peripheral.
Definition: dl_gpamp.h:178
__STATIC_INLINE DL_GPAMP_NSEL DL_GPAMP_getInvertingInputChannel(void)
Get the inverting input channel.
Definition: dl_gpamp.h:239
Definition: dl_gpamp.h:66
__STATIC_INLINE void DL_GPAMP_enableOutputToPad(void)
Enable output to pad.
Definition: dl_gpamp.h:274
__STATIC_INLINE bool DL_GPAMP_isOutputToPadEnabled(void)
Checks if output to pad is enabled.
Definition: dl_gpamp.h:287
Definition: dl_gpamp.h:80
DL_GPAMP_CHOPPING_FREQ choppingFreq
Definition: dl_gpamp.h:128
DL_GPAMP_PSEL pselChannel
Definition: dl_gpamp.h:132
Configuration struct for DL_GPAMP_init.
Definition: dl_gpamp.h:124
Definition: dl_gpamp.h:105
Definition: dl_gpamp.h:92
Definition: dl_gpamp.h:107
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale