MSPM0H321X Driver Library  2.05.01.00
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 
206 __STATIC_INLINE void DL_VREF_enablePower(VREF_Regs *vref)
207 {
208  vref->GPRCM.PWREN = VREF_PWREN_KEY_UNLOCK_W | VREF_PWREN_ENABLE_ENABLE;
209 }
210 
222 __STATIC_INLINE void DL_VREF_disablePower(VREF_Regs *vref)
223 {
224  vref->GPRCM.PWREN = VREF_PWREN_KEY_UNLOCK_W | VREF_PWREN_ENABLE_DISABLE;
225 }
242 __STATIC_INLINE bool DL_VREF_isPowerEnabled(VREF_Regs *vref)
243 {
244  return ((VREF->GPRCM.PWREN & VREF_PWREN_ENABLE_MASK) ==
245  VREF_PWREN_ENABLE_ENABLE);
246 }
247 
258 __STATIC_INLINE void DL_VREF_enableInternalRef(VREF_Regs *vref)
259 {
260  vref->CTL0 |= VREF_CTL0_ENABLE_ENABLE;
261 }
262 
271 __STATIC_INLINE void DL_VREF_disableInternalRef(VREF_Regs *vref)
272 {
273  vref->CTL0 &= ~VREF_CTL0_ENABLE_MASK;
274 }
275 
286 __STATIC_INLINE bool DL_VREF_isEnabled(const VREF_Regs *vref)
287 {
288  return ((vref->CTL0 & VREF_CTL0_ENABLE_MASK) == VREF_CTL0_ENABLE_ENABLE);
289 }
290 
291 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_MSPM0L122X_L222X)
292 
297 __STATIC_INLINE void DL_VREF_enableInternalRefCOMP(VREF_Regs *vref)
298 {
299  vref->CTL0 |= VREF_CTL0_COMP_VREF_ENABLE_ENABLE;
300 }
301 
312 __STATIC_INLINE bool DL_VREF_isInternalRefCOMPEnabled(const VREF_Regs *vref)
313 {
314  return ((vref->CTL0 & VREF_CTL0_COMP_VREF_ENABLE_MASK) ==
315  VREF_CTL0_COMP_VREF_ENABLE_ENABLE);
316 }
317 
323 __STATIC_INLINE void DL_VREF_disableInternalRefCOMP(VREF_Regs *vref)
324 {
325  vref->CTL0 &= ~(VREF_CTL0_COMP_VREF_ENABLE_MASK);
326 }
327 #endif
328 
337  VREF_Regs *vref, const DL_VREF_ClockConfig *config);
338 
347  const VREF_Regs *vref, DL_VREF_ClockConfig *config);
348 
354 __STATIC_INLINE void DL_VREF_reset(VREF_Regs *vref)
355 {
356  vref->GPRCM.RSTCTL =
357  VREF_RSTCTL_RESETASSERT_MASK | VREF_RSTCTL_KEY_UNLOCK_W;
358 }
359 
369 __STATIC_INLINE bool DL_VREF_isReset(const VREF_Regs *vref)
370 {
371  return (vref->GPRCM.STAT & VREF_STAT_RESETSTKY_MASK) ==
372  VREF_STAT_RESETSTKY_RESET;
373 }
374 
383 __STATIC_INLINE uint32_t DL_VREF_getStatus(const VREF_Regs *vref)
384 {
385  return vref->CTL1 & VREF_CTL1_READY_MASK;
386 }
387 
396 void DL_VREF_configReference(VREF_Regs *vref, const DL_VREF_Config *config);
397 
398 #ifdef __cplusplus
399 }
400 #endif
401 
402 #endif /* __MSPM0_HAS_VREF__ */
403 
404 #endif /* ti_dl_dl_m0p_vref__include */
405 
__STATIC_INLINE bool DL_VREF_isInternalRefCOMPEnabled(const VREF_Regs *vref)
Checks if VREF buffer for comparator is enabled.
Definition: dl_vref.h:312
__STATIC_INLINE void DL_VREF_disableInternalRef(VREF_Regs *vref)
Disables Internal VREF, allows for External VREF.
Definition: dl_vref.h:271
Definition: dl_vref.h:158
__STATIC_INLINE void DL_VREF_enablePower(VREF_Regs *vref)
Enables the Peripheral Write Enable (PWREN) register for the VREF.
Definition: dl_vref.h:206
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:354
Definition: dl_vref.h:142
Definition: dl_vref.h:140
Definition: dl_vref.h:126
__STATIC_INLINE void DL_VREF_enableInternalRefCOMP(VREF_Regs *vref)
Enable VREF buffer as internal reference input for comparator.
Definition: dl_vref.h:297
Definition: dl_vref.h:150
__STATIC_INLINE void DL_VREF_enableInternalRef(VREF_Regs *vref)
Enables Internal VREF.
Definition: dl_vref.h:258
DL_VREF_CLOCK
Definition: dl_vref.h:122
__STATIC_INLINE bool DL_VREF_isPowerEnabled(VREF_Regs *vref)
Returns if the Peripheral Write Enable (PWREN) register for the VREF is enabled.
Definition: dl_vref.h:242
Definition: dl_vref.h:124
DL_VREF_ENABLE vrefEnable
Definition: dl_vref.h:184
__STATIC_INLINE uint32_t DL_VREF_getStatus(const VREF_Regs *vref)
Returns VREF register status.
Definition: dl_vref.h:383
DL_VREF_SHMODE
Definition: dl_vref.h:162
__STATIC_INLINE bool DL_VREF_isEnabled(const VREF_Regs *vref)
Checks if the internal VREF is enabled.
Definition: dl_vref.h:286
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
DL_VREF_BUFCONFIG bufConfig
Definition: dl_vref.h:186
void DL_VREF_getClockConfig(const VREF_Regs *vref, DL_VREF_ClockConfig *config)
Copy the clock select and clock divide fields in VREF to config.
void DL_VREF_configReference(VREF_Regs *vref, const DL_VREF_Config *config)
Configure VREF enable, control registers.
__STATIC_INLINE void DL_VREF_disableInternalRefCOMP(VREF_Regs *vref)
Disable VREF buffer as internal reference input for comparator.
Definition: dl_vref.h:323
__STATIC_INLINE void DL_VREF_disablePower(VREF_Regs *vref)
Disables the Peripheral Write Enable (PWREN) register for the VREF.
Definition: dl_vref.h:222
__STATIC_INLINE bool DL_VREF_isReset(const VREF_Regs *vref)
Returns if VREF peripheral was reset.
Definition: dl_vref.h:369
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
Configuration struct for DL_VREF_Config.
Definition: dl_vref.h:182
Definition: dl_vref.h:138
Definition: dl_vref.h:128
Definition: dl_vref.h:136
void DL_VREF_setClockConfig(VREF_Regs *vref, const DL_VREF_ClockConfig *config)
Set the clock select and clock divide fields in VREF.
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-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale