MSPM0G1X0X_G3X0X Driver Library  1.10.01.05
dl_vref.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_vref.h
34  * @brief Voltage Reference (VREF) Driver Library
35  * @defgroup VREF Voltage Reference (VREF)
36  *
37  * @anchor ti_dl_dl_vref_Overview
38  * # Overview
39  *
40  * The Voltage Reference Driver Library allows full configuration of
41  * the MSPM0 VREF module.
42  * The VREF module contains a configurable voltage reference buffer which
43  * allows users to supply a stable internal reference to on-board analog
44  * peripherals. It also supports bringing in an external reference for
45  * applications where higher accuracy is required.
46  *
47  * <hr>
48  ******************************************************************************
49  */
53 #ifndef ti_dl_dl_m0p_vref__include
54 #define ti_dl_dl_m0p_vref__include
55 
56 #include <stdbool.h>
57 #include <stdint.h>
58 
59 #include <ti/devices/msp/msp.h>
60 #include <ti/driverlib/dl_common.h>
61 
62 #ifdef __MSPM0_HAS_VREF__
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
68 /* clang-format off */
69 
77 #define DL_VREF_CTL1_READY_NOTRDY (VREF_CTL1_READY_NOTRDY)
78 
82 #define DL_VREF_CTL1_READY_RDY (VREF_CTL1_READY_RDY)
83 
84 
94 #define DL_VREF_SH_MIN (VREF_CTL2_SHCYCLE_MINIMUM)
95 
99 #define DL_VREF_SH_MAX (VREF_CTL2_SHCYCLE_MAXIMUM)
100 
110 #define DL_VREF_HOLD_MIN (VREF_CTL2_HCYCLE_MINIMUM)
111 
115 #define DL_VREF_HOLD_MAX (VREF_CTL2_HCYCLE_MAXIMUM)
116 
119 /* clang-format on */
120 
122 typedef enum {
124  DL_VREF_CLOCK_LFCLK = VREF_CLKSEL_LFCLK_SEL_MASK,
126  DL_VREF_CLOCK_MFCLK = VREF_CLKSEL_MFCLK_SEL_MASK,
128  DL_VREF_CLOCK_BUSCLK = VREF_CLKSEL_BUSCLK_SEL_MASK,
129 } DL_VREF_CLOCK;
130 
132 typedef enum {
144 
146 typedef enum {
148  DL_VREF_ENABLE_DISABLE = VREF_CTL0_ENABLE_DISABLE,
150  DL_VREF_ENABLE_ENABLE = VREF_CTL0_ENABLE_ENABLE,
152 
154 typedef enum {
156  DL_VREF_BUFCONFIG_OUTPUT_2_5V = VREF_CTL0_BUFCONFIG_OUTPUT2P5V,
158  DL_VREF_BUFCONFIG_OUTPUT_1_4V = VREF_CTL0_BUFCONFIG_OUTPUT1P4V,
160 
162 typedef enum {
164  DL_VREF_SHMODE_DISABLE = VREF_CTL0_SHMODE_DISABLE,
166  DL_VREF_SHMODE_ENABLE = VREF_CTL0_SHMODE_ENABLE,
168 
172 typedef struct {
174  DL_VREF_CLOCK clockSel;
178 
182 typedef struct {
184  DL_VREF_ENABLE vrefEnable;
186  DL_VREF_BUFCONFIG bufConfig;
188  DL_VREF_SHMODE shModeEnable;
190  uint32_t shCycleCount;
192  uint32_t holdCycleCount;
194 
200 __STATIC_INLINE void DL_VREF_enablePower(VREF_Regs *vref)
201 {
202  vref->GPRCM.PWREN = VREF_PWREN_KEY_UNLOCK_W | VREF_PWREN_ENABLE_ENABLE;
203 }
204 
210 __STATIC_INLINE void DL_VREF_disablePower(VREF_Regs *vref)
211 {
212  vref->GPRCM.PWREN = VREF_PWREN_KEY_UNLOCK_W | VREF_PWREN_ENABLE_DISABLE;
213 }
214 
225 __STATIC_INLINE void DL_VREF_enableInternalRef(VREF_Regs *vref)
226 {
227  vref->CTL0 |= VREF_CTL0_ENABLE_ENABLE;
228 }
229 
238 __STATIC_INLINE void DL_VREF_disableInternalRef(VREF_Regs *vref)
239 {
240  vref->CTL0 &= ~VREF_CTL0_ENABLE_MASK;
241 }
242 
253 __STATIC_INLINE bool DL_VREF_isEnabled(VREF_Regs *vref)
254 {
255  return ((vref->CTL0 & VREF_CTL0_ENABLE_MASK) == VREF_CTL0_ENABLE_ENABLE);
256 }
257 
265 void DL_VREF_setClockConfig(VREF_Regs *vref, DL_VREF_ClockConfig *config);
266 
274 void DL_VREF_getClockConfig(VREF_Regs *vref, DL_VREF_ClockConfig *config);
275 
281 __STATIC_INLINE void DL_VREF_reset(VREF_Regs *vref)
282 {
283  vref->GPRCM.RSTCTL =
284  VREF_RSTCTL_RESETASSERT_MASK | VREF_RSTCTL_KEY_UNLOCK_W;
285 }
286 
296 __STATIC_INLINE bool DL_VREF_isReset(VREF_Regs *vref)
297 {
298  return (vref->GPRCM.STAT & VREF_STAT_RESETSTKY_MASK) ==
299  VREF_STAT_RESETSTKY_RESET;
300 }
301 
310 __STATIC_INLINE uint32_t DL_VREF_getStatus(VREF_Regs *vref)
311 {
312  return vref->CTL1 & VREF_CTL1_READY_MASK;
313 }
314 
323 void DL_VREF_configReference(VREF_Regs *vref, DL_VREF_Config *config);
324 
325 #ifdef __cplusplus
326 }
327 #endif
328 
329 #endif /* __MSPM0_HAS_VREF__ */
330 
331 #endif /* ti_dl_dl_m0p_vref__include */
332 
__STATIC_INLINE bool DL_VREF_isEnabled(VREF_Regs *vref)
Checks if the internal VREF is enabled.
Definition: dl_vref.h:253
__STATIC_INLINE void DL_VREF_disableInternalRef(VREF_Regs *vref)
Disables Internal VREF, allows for External VREF.
Definition: dl_vref.h:238
Definition: dl_vref.h:158
__STATIC_INLINE void DL_VREF_enablePower(VREF_Regs *vref)
Enables power on VREF module.
Definition: dl_vref.h:200
uint32_t holdCycleCount
Definition: dl_vref.h:192
__STATIC_INLINE void DL_VREF_reset(VREF_Regs *vref)
Resets the VREF module.
Definition: dl_vref.h:281
Definition: dl_vref.h:142
Definition: dl_vref.h:140
Definition: dl_vref.h:126
Definition: dl_vref.h:150
__STATIC_INLINE void DL_VREF_enableInternalRef(VREF_Regs *vref)
Enables Internal VREF.
Definition: dl_vref.h:225
DL_VREF_CLOCK
Definition: dl_vref.h:122
Definition: dl_vref.h:124
DL_VREF_ENABLE vrefEnable
Definition: dl_vref.h:184
__STATIC_INLINE bool DL_VREF_isReset(VREF_Regs *vref)
Returns if VREF peripheral was reset.
Definition: dl_vref.h:296
DL_VREF_SHMODE
Definition: dl_vref.h:162
DriverLib Common APIs.
DL_VREF_CLOCK_DIVIDE divideRatio
Definition: dl_vref.h:176
Definition: dl_vref.h:164
uint32_t shCycleCount
Definition: dl_vref.h:190
Definition: dl_vref.h:166
void DL_VREF_configReference(VREF_Regs *vref, DL_VREF_Config *config)
Configure VREF enable, control registers.
DL_VREF_BUFCONFIG bufConfig
Definition: dl_vref.h:186
__STATIC_INLINE void DL_VREF_disablePower(VREF_Regs *vref)
Disable power on VREF module.
Definition: dl_vref.h:210
Definition: dl_vref.h:148
DL_VREF_SHMODE shModeEnable
Definition: dl_vref.h:188
DL_VREF_CLOCK clockSel
Definition: dl_vref.h:174
DL_VREF_BUFCONFIG
Definition: dl_vref.h:154
__STATIC_INLINE uint32_t DL_VREF_getStatus(VREF_Regs *vref)
Returns VREF register status.
Definition: dl_vref.h:310
void DL_VREF_getClockConfig(VREF_Regs *vref, DL_VREF_ClockConfig *config)
Copy the clock select and clock divide fields in VREF to config.
Configuration struct for DL_VREF_Config.
Definition: dl_vref.h:182
Definition: dl_vref.h:138
Definition: dl_vref.h:128
void DL_VREF_setClockConfig(VREF_Regs *vref, DL_VREF_ClockConfig *config)
Set the clock select and clock divide fields in VREF.
Definition: dl_vref.h:136
Configuration struct for DL_VREF_setClockConfig.
Definition: dl_vref.h:172
DL_VREF_ENABLE
Definition: dl_vref.h:146
DL_VREF_CLOCK_DIVIDE
Definition: dl_vref.h:132
Definition: dl_vref.h:134
Definition: dl_vref.h:156
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale