CC27xxDriverLibrary
pmctl.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Filename: pmctl.h
3  *
4  * Description: Defines and prototypes for the PMCTL module.
5  *
6  * Copyright (c) 2022-2025 Texas Instruments Incorporated
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1) Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * 2) Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3) Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  ******************************************************************************/
35 
36 #ifndef __PMCTL_H__
37 #define __PMCTL_H__
38 
39 //*****************************************************************************
40 //
45 //
46 //*****************************************************************************
47 
48 //*****************************************************************************
49 //
50 // If building with a C++ compiler, make all of the definitions in this header
51 // have a C binding.
52 //
53 //*****************************************************************************
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 #include <stdbool.h>
59 #include <stdint.h>
60 
61 #include "../inc/hw_types.h"
62 #include "../inc/hw_memmap.h"
63 #include "../inc/hw_pmctl.h"
64 
65 #include "../cmsis/cc27xx.h"
66 #include "../cmsis/core/core_cm33.h"
67 
68 //*****************************************************************************
70 
71 //*****************************************************************************
73 #define PMCTL_RESET_SHUTDOWN_IO (PMCTL_RSTSTA_SDDET | PMCTL_RSTSTA_IOWUSD)
74 #define PMCTL_RESET_SHUTDOWN_SWD PMCTL_RSTSTA_SDDET
76 #define PMCTL_RESET_WATCHDOG (PMCTL_RSTSTA_SYSSRC_WDTEV | PMCTL_RSTSTA_RESETSRC_SYSRESET)
78 #define PMCTL_RESET_SYSTEM (PMCTL_RSTSTA_SYSSRC_SYSRSTEV | PMCTL_RSTSTA_RESETSRC_SYSRESET)
80 #define PMCTL_RESET_CPU (PMCTL_RSTSTA_SYSSRC_CPURSTEV | PMCTL_RSTSTA_RESETSRC_SYSRESET)
82 #define PMCTL_RESET_LOCKUP (PMCTL_RSTSTA_SYSSRC_LOCKUPEV | PMCTL_RSTSTA_RESETSRC_SYSRESET)
84 #define PMCTL_RESET_ANALOG_FSM_TIMEOUT (PMCTL_RSTSTA_SYSSRC_AFSMEV | PMCTL_RSTSTA_RESETSRC_SYSRESET)
86 #define PMCTL_RESET_EM_SENSOR (PMCTL_RSTSTA_SYSSRC_EMSEV | PMCTL_RSTSTA_RESETSRC_SYSRESET)
88 #define PMCTL_RESET_TAMPER (PMCTL_RSTSTA_SYSSRC_TAMPEREV | PMCTL_RSTSTA_RESETSRC_SYSRESET)
90 #define PMCTL_RESET_SRAM_PARITY_ERROR (PMCTL_RSTSTA_SYSSRC_SRAMEV | PMCTL_RSTSTA_RESETSRC_SYSRESET)
92 #define PMCTL_RESET_ANALOG_ERROR (PMCTL_RSTSTA_SYSSRC_AERREV | PMCTL_RSTSTA_RESETSRC_SYSRESET)
94 #define PMCTL_RESET_DIGITAL_ERROR (PMCTL_RSTSTA_SYSSRC_DERREV | PMCTL_RSTSTA_RESETSRC_SYSRESET)
96 #define PMCTL_RESET_SWD (PMCTL_RSTSTA_SYSSRC_SWDRSTEV | PMCTL_RSTSTA_RESETSRC_SYSRESET)
98 #define PMCTL_RESET_LFXT (PMCTL_RSTSTA_SYSSRC_LFLOSSEV | PMCTL_RSTSTA_RESETSRC_SYSRESET)
100 #define PMCTL_RESET_TSD (PMCTL_RSTSTA_TSDEV | PMCTL_RSTSTA_RESETSRC_PINRESET)
102 #define PMCTL_RESET_VDDR PMCTL_RSTSTA_RESETSRC_VDDRLOSS
104 #define PMCTL_RESET_VDDS PMCTL_RSTSTA_RESETSRC_VDDSLOSS
106 #define PMCTL_RESET_PIN PMCTL_RSTSTA_RESETSRC_PINRESET
108 #define PMCTL_RESET_POR PMCTL_RSTSTA_RESETSRC_PWRON
110 
111 
112 //*****************************************************************************
114 
115 //*****************************************************************************
117 #define PMCTL_VOLTAGE_REGULATOR_DCDC PMCTL_VDDRCTL_SELECT_DCDC
118 #define PMCTL_VOLTAGE_REGULATOR_GLDO PMCTL_VDDRCTL_SELECT_GLDO
120 
121 
122 //*****************************************************************************
123 //
124 // API Functions and prototypes
125 //
126 //*****************************************************************************
127 
128 #ifndef DRIVERLIB_NS
129 //*****************************************************************************
130 //
131 // Below functions will only be compiled into the driverlib.a library and not
132 // the driverlib_ns.a library.
133 // Non-secure applications might be able to access some/all of these functions
134 // through veneers declared further below in the #else case.
135 //
136 //*****************************************************************************
137 
138 //*****************************************************************************
139 //
164 //
165 //*****************************************************************************
167 {
168  // Read the RSTSTA register but mask out the RTCSTA bit
169  return HWREG(PMCTL_BASE + PMCTL_O_RSTSTA) & ~PMCTL_RSTSTA_RTCSTA_M;
170 }
171 
172 //*****************************************************************************
173 //
182 //*****************************************************************************
184 {
185  return (HWREG(PMCTL_BASE + PMCTL_O_RSTSTA) & PMCTL_RSTSTA_RTCSTA_M) == PMCTL_RSTSTA_RTCSTA_CLR;
186 }
187 
188 //*****************************************************************************
189 //
196 //
197 //*****************************************************************************
199 {
200  // Disable interrupts
201  __disable_irq();
202 
203  // Write reset register
204  HWREG(PMCTL_BASE + PMCTL_O_RSTCTL) |= PMCTL_RSTCTL_SYSRST_SET;
205 
206  // Should never return from this function
207  while (1) {}
208 }
209 
210 //*****************************************************************************
211 //
222 //
223 //*****************************************************************************
225 {
226  // Write to VDDR regulator register while preserving other configuration
227  // fields
228  uint32_t tmp = HWREG(PMCTL_BASE + PMCTL_O_VDDRCTL) & ~PMCTL_VDDRCTL_SELECT_M;
229  HWREG(PMCTL_BASE + PMCTL_O_VDDRCTL) = tmp | regulator;
230 }
231 
232 //*****************************************************************************
233 //
241 //
242 //*****************************************************************************
244 {
245  return (HWREG(PMCTL_BASE + PMCTL_O_VDDRCTL) & PMCTL_VDDRCTL_SELECT_M);
246 }
247 
248 //*****************************************************************************
249 //
253 //
254 //*****************************************************************************
256 {
257  HWREG(PMCTL_BASE + PMCTL_O_AONRSET1) |= PMCTL_AONRSET1_VDDIOPGIO_SET;
258 }
259 
260 #else
261 //*****************************************************************************
262 //
263 // Secure-only API functions available from non-secure context through
264 // veneers.
265 //
266 // These functions must be linked in from from the secure veneer library.
267 //
268 //*****************************************************************************
269 
270 extern bool PMCTLGetRtcResetStatus_veneer(void);
271  #define PMCTLGetRtcResetStatus PMCTLGetRtcResetStatus_veneer
272 
273 extern bool PMCTLEnableVddioGpioPadPower_veneer(void);
274  #define PMCTLEnableVddioGpioPadPower PMCTLEnableVddioGpioPadPower_veneer
275 
276 #endif
277 
278 //*****************************************************************************
279 //
280 // Mark the end of the C bindings section for C++ compilers.
281 //
282 //*****************************************************************************
283 #ifdef __cplusplus
284 }
285 #endif
286 
287 //*****************************************************************************
288 //
292 //
293 //*****************************************************************************
294 
295 #endif // __PMCTL_H__
__STATIC_INLINE void PMCTLResetSystem(void)
Issue a system reset.
Definition: pmctl.h:198
__tz_c_veneer void PMCTLEnableVddioGpioPadPower_veneer(void)
Definition: pmctl_veneers.c:46
__tz_c_veneer bool PMCTLGetRtcResetStatus_veneer(void)
Definition: pmctl_veneers.c:41
__STATIC_INLINE uint32_t PMCTLGetVoltageRegulator(void)
Get the current VDDR regulator.
Definition: pmctl.h:243
__STATIC_FORCEINLINE void __disable_irq(void)
Disable IRQ Interrupts.
Definition: cmsis_gcc.h:966
__STATIC_INLINE void PMCTLEnableVddioGpioPadPower(void)
Enable pad power for GPIOs that uses VDDIO.
Definition: pmctl.h:255
__STATIC_INLINE void PMCTLSetVoltageRegulator(uint32_t regulator)
Set the VDDR regulator.
Definition: pmctl.h:224
__STATIC_INLINE uint32_t PMCTLGetResetReason(void)
Get the reason for the system reset.
Definition: pmctl.h:166
#define __STATIC_INLINE
Definition: cmsis_gcc.h:47
__STATIC_INLINE bool PMCTLGetRtcResetStatus(void)
Get the RTC reset status.
Definition: pmctl.h:183