CC35xxDriverLibrary
watchdog.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Filename: watchdog.h
3  *
4  * Description: Defines and prototypes for the Watchdog capabilities of the
5  * ELPTMR peripheral.
6  *
7  * Copyright (c) 2025 Texas Instruments Incorporated
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * 1) Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2) Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * 3) Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from this
21  * software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  ******************************************************************************/
36 
37 #ifndef __WATCHDOG_H__
38 #define __WATCHDOG_H__
39 
40 //*****************************************************************************
41 //
46 //
47 //*****************************************************************************
48 
49 #include <stdint.h>
50 #include <stdbool.h>
51 #include "../inc/hw_types.h"
52 #include "../inc/hw_memmap.h"
53 #include "../inc/hw_hostmcu_aon.h"
54 #include "../inc/hw_ints.h"
55 
56 //*****************************************************************************
57 //
58 // If building with a C++ compiler, make all of the definitions in this header
59 // have a C binding.
60 //
61 //*****************************************************************************
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
66 //*****************************************************************************
67 //
68 // Extended hw_hostmcu_aon.h defines - shift 0 because ELP TMR is bit 0 of VAL
69 // bitfield.
70 //
71 //*****************************************************************************
72 #define HOSTMCU_AON_CFGWICSNS_ELP_TMR_EN (HOSTMCU_AON_CFGWICSNS_VAL_TMRREQ_EN << 0)
73 #define HOSTMCU_AON_CFGWUTP_ELP_TMR_FAST (HOSTMCU_AON_CFGWUTP_VAL_TMRREQ << 0)
74 
75 //*****************************************************************************
76 //
77 // API Functions and prototypes
78 //
79 //*****************************************************************************
80 
81 //*****************************************************************************
82 //
86 //
87 //*****************************************************************************
89 {
91 }
92 
93 //*****************************************************************************
94 //
98 //
99 //*****************************************************************************
101 {
102  // Disable ELP TMR event as a sleep wake-up source
104 
105  // Disable the wake-up threshold
107 }
108 
109 //*****************************************************************************
110 //
114 //
115 //*****************************************************************************
117 {
119 }
120 
121 //*****************************************************************************
122 //
129 //
130 //*****************************************************************************
132 {
133  // Configure the ELP TMR event to be a fast wake-up source
135 
136  // Configure the ELP TMR event as a sleep wake-up source
138 
139  // Enable the wake-up event
141 }
142 
143 //*****************************************************************************
144 //
148 //
149 //*****************************************************************************
151 {
153 }
154 
155 //*****************************************************************************
156 //
160 
161 //
162 //*****************************************************************************
164 {
167  return timerStatus;
168 }
169 
170 //*****************************************************************************
171 //
175 
176 //
177 //*****************************************************************************
179 {
181 }
182 
183 //*****************************************************************************
184 //
188 
189 //
190 //*****************************************************************************
192 {
194 }
195 
196 //*****************************************************************************
197 //
201 //
202 //*****************************************************************************
204 {
206 }
207 
208 //*****************************************************************************
209 //
219 //
220 //*****************************************************************************
222 {
223  // Align the wake-up threshold resolution to match the reset resolution.
224  // Each reset threshold tick corresponds to 256 (2^8) wake-up threshold
225  // ticks because the reset threshold bit field is smaller.
226  uint32_t ticksInResetResolution = (ticks << HOSTMCU_AON_CFGWDT_THR_S) & HOSTMCU_AON_CFGWDT_THR_M;
227 
228  uint32_t temp = HWREG(HOSTMCU_AON_BASE + HOSTMCU_AON_O_CFGTMRWU);
230  temp |= ticksInResetResolution;
232 }
233 
234 //*****************************************************************************
235 //
244 //
245 //*****************************************************************************
247 {
248  uint32_t temp = HWREG(HOSTMCU_AON_BASE + HOSTMCU_AON_O_CFGWDT);
249  temp &= ~HOSTMCU_AON_CFGWDT_THR_M;
250  temp |= ((ticks << HOSTMCU_AON_CFGWDT_THR_S) & HOSTMCU_AON_CFGWDT_THR_M);
252 }
253 
254 //*****************************************************************************
255 //
262 //
263 //*****************************************************************************
265 {
267 }
268 
269 //*****************************************************************************
270 //
277 //
278 //*****************************************************************************
279 extern void WatchdogStartSequence(void);
280 
281 //*****************************************************************************
282 //
289 //
290 //*****************************************************************************
291 extern void WatchdogStopSequence(void);
292 
293 //*****************************************************************************
294 //
295 // Mark the end of the C bindings section for C++ compilers.
296 //
297 //*****************************************************************************
298 #ifdef __cplusplus
299 }
300 #endif
301 
302 //*****************************************************************************
303 //
307 //
308 //*****************************************************************************
309 
310 #endif // __WATCHDOG_H__
#define HOSTMCU_AON_O_CFGWUTP
Definition: hw_hostmcu_aon.h:51
__STATIC_INLINE void WatchdogEnableWakeUpEvent(void)
Enables the timer wake-up event.
Definition: watchdog.h:131
__STATIC_INLINE void WatchdogSetSwMode(void)
Configures the timer to work in software mode.
Definition: watchdog.h:264
#define HOSTMCU_AON_CFGWDT_THR_M
Definition: hw_hostmcu_aon.h:491
#define HWREG(x)
Definition: hw_types.h:78
#define __STATIC_INLINE
Definition: hw_types.h:57
__STATIC_INLINE void WatchdogDisableResetEvent(void)
Disables the timer reset event.
Definition: watchdog.h:116
#define HOSTMCU_AON_CFGTMRWU_THR_M
Definition: hw_hostmcu_aon.h:422
void WatchdogStopSequence(void)
Sequence to stop the timer.
Definition: watchdog.c:72
#define HOSTMCU_AON_CFGTMRWU_EN
Definition: hw_hostmcu_aon.h:441
#define HOSTMCU_AON_O_CFGWICSNS
Definition: hw_hostmcu_aon.h:48
__STATIC_INLINE void WatchdogClearWakeUpEvent(void)
Clears the timer wake-up event.
Definition: watchdog.h:88
__STATIC_INLINE void WatchdogSetWakeUpThreshold(uint32_t ticks)
Sets the wake-up threshold.
Definition: watchdog.h:221
#define HOSTMCU_AON_ELPTMREN_VAL_S
Definition: hw_hostmcu_aon.h:336
#define HOSTMCU_AON_ELPTMREN_TMRSWCTL_SW
Definition: hw_hostmcu_aon.h:355
#define HOSTMCU_AON_TMRWUREQ_CLR_M
Definition: hw_hostmcu_aon.h:465
#define HOSTMCU_AON_CFGWDT_EN
Definition: hw_hostmcu_aon.h:505
#define HOSTMCU_AON_ELPTMREN_VAL_EN
Definition: hw_hostmcu_aon.h:338
#define HOSTMCU_AON_ELPTMREN_VAL_DIS
Definition: hw_hostmcu_aon.h:337
#define HOSTMCU_AON_ELPTMREN_ELPTMRLD
Definition: hw_hostmcu_aon.h:395
#define HOSTMCU_AON_O_CFGWDT
Definition: hw_hostmcu_aon.h:63
__STATIC_INLINE void WatchdogEnableResetEvent(void)
Enables the timer reset event.
Definition: watchdog.h:150
__STATIC_INLINE void WatchdogWaitUntilDisabled(void)
Waits until the timer is disabled.
Definition: watchdog.h:191
#define HOSTMCU_AON_BASE
Definition: hw_memmap.h:81
void WatchdogStartSequence(void)
Sequence to start the timer.
Definition: watchdog.c:44
#define HOSTMCU_AON_CFGWUTP_ELP_TMR_FAST
Definition: watchdog.h:73
#define HOSTMCU_AON_ELPTMREN_VAL_M
Definition: hw_hostmcu_aon.h:335
__STATIC_INLINE void WatchdogSetResetThreshold(uint32_t ticks)
Sets the reset threshold.
Definition: watchdog.h:246
__STATIC_INLINE bool WatchdogStatus(void)
Reads the status of the timer.
Definition: watchdog.h:163
__STATIC_INLINE void WatchdogWaitUntilEnabled(void)
Waits until the timer is enabled.
Definition: watchdog.h:178
#define HOSTMCU_AON_O_ELPTMREN
Definition: hw_hostmcu_aon.h:54
#define HOSTMCU_AON_CFGWDT_THR_S
Definition: hw_hostmcu_aon.h:492
__STATIC_INLINE void WatchdogDisableWakeUpEvent(void)
Disables the timer wake-up event.
Definition: watchdog.h:100
#define HOSTMCU_AON_O_TMRWUREQ
Definition: hw_hostmcu_aon.h:60
#define HOSTMCU_AON_O_CFGTMRWU
Definition: hw_hostmcu_aon.h:57
#define HOSTMCU_AON_CFGWICSNS_ELP_TMR_EN
Definition: watchdog.h:72
__STATIC_INLINE void WatchdogReset(void)
Re-sets the timer back to zero.
Definition: watchdog.h:203