WatchdogCC26X4.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022, 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 WatchdogCC26X4.h
34  *
35  * @brief Watchdog driver implementation for CC13X4/CC26X4
36  *
37  * # Driver include #
38  * The Watchdog header file should be included in an application as follows:
39  * @code
40  * #include <ti/drivers/Watchdog.h>
41  * #include <ti/drivers/watchdog/WatchdogCC26X4.h>
42  * @endcode
43  *
44  * Refer to @ref Watchdog.h for a complete description of APIs.
45  *
46  * # Overview #
47  *
48  * The general Watchdog API should be used in application code, i.e.
49  * #Watchdog_open() should be used instead of WatchdogCC26X4_open(). The board
50  * file will define the device specific config, and casting in the general API
51  * will ensure that the correct device specific functions are called.
52  *
53  * # General Behavior #
54  * This Watchdog driver implementation is designed to operate on a CC13X4/CC26X4
55  * device. Before using the Watchdog on CC13X4/CC26X4, the Watchdog driver is
56  * initialized by calling #Watchdog_init(). The Watchdog HW is configured by
57  * calling #Watchdog_open(). Once opened, the Watchdog will count down from
58  * the reload value specified in #WatchdogCC26X4_HWAttrs. If it times out, a reset
59  * signal will be generated. To prevent a reset, #Watchdog_clear() must be called
60  * to reload the timer.
61  *
62  * The Watchdog counts down at the rate of the device clock SCLK_LF. SCLK_LF will
63  * tick at different rates depending on the SCLK_LF source selected in CCFG,
64  * ranging between 31250 Hz and 32768 Hz. The Watchdog driver internally calculates
65  * the correct tick value depending on the target SCLK_LF source selected in CCFG.
66  * RCOSC_LF is an inherently inaccurate clock source and will present variations
67  * around the target 32768 Hz frequency. These inaccuracies have to be taken into
68  * consideration at the application level if RSCOC_LF is selected as the source
69  * of SCLK_LF.
70  *
71  * The reload value from which the Watchdog timer counts down may be changed
72  * during runtime using #Watchdog_setReload(). This value should be specified
73  * in Watchdog clock ticks and should not exceed "2^32 - 1". This corresponds to
74  * a timeout period of 131071 seconds, calculated at the highest rate of 32768
75  * kHz. If the reload value is set to zero, the Watchdog reset is immediately
76  * generated.
77  *
78  * Watchdog_close() is <b>not</b> supported by this driver implementation. Once
79  * started, the Watchdog timer can only be stopped by a hardware reset.
80  *
81  * <b>No</b> CC13X4/CC26X4 specific command has been implemented. Any call to
82  * Watchdog_control() will receive the return code Watchdog_STATUS_UNDEFINEDCMD.
83  *
84  * The Watchdog module available on CC13X4/CC26X4 devices does not support reset
85  * masking or interrupt generation. Therefore, the two parameters \ref
86  * Watchdog_Params.resetMode and \ref Watchdog_Params.callbackFxn in the \ref
87  * Watchdog_Params struct are not supported and will be ignored by the Watchdog
88  * driver.
89  *
90  * # Power Management #
91  * Once started, the Watchdog will keep running in Active, Idle and Standby mode.
92  *
93  * # Supported Functions #
94  * | Generic API Function | API Function | Description |
95  * |------------------------------ |----------------------------------
96  * |--------------------------------------------------- | | #Watchdog_init() | WatchdogCC26X4_init() |
97  * Initialize Watchdog driver | | #Watchdog_open() | WatchdogCC26X4_open() |
98  * Initialize Watchdog HW and set system dependencies | | #Watchdog_clear() | WatchdogCC26X4_clear() |
99  * Reload Watchdog counter | | #Watchdog_setReload() | WatchdogCC26X4_setReload() |
100  * Update Watchdog timer reload value in clock ticks | | #Watchdog_convertMsToTicks() |
101  * WatchdogCC26X4_convertMsToTicks() | Converts milliseconds to clock ticks |
102  *
103  * @note All calls should go through the generic API. Please refer to @ref Watchdog.h for a
104  * complete description of the generic APIs.
105  *
106  * # Use Cases #
107  * ## Basic Watchdog #
108  * In this basic watchdog example, the application is expected to start the Watchdog
109  * timer by calling #Watchdog_open(). If needed, #Watchdog_setReload() may be
110  * called to change the timeout period. If all monitored tasks are doing alright,
111  * #Watchdog_clear() should be called regularly to reload the counter so as to
112  * restart the timeout period and to avoid the Watchdog resetting the device.
113  * If the #Watchdog_clear() is missed and the Watchdog timer is allowed to
114  * timeout, the device will be reset.
115  *
116  * The following code example shows how to correctly initialize the driver's
117  * parameters, start the Watchdog timer and modify at runtime the timeout period.
118  * @code
119  *
120  * Watchdog_Handle handle;
121  * Watchdog_Params params;
122  * uint32_t tickValue;
123  *
124  * Watchdog_init();
125  * Watchdog_Params_init(&params);
126  * handle = Watchdog_open(Watchdog_configIndex, &params);
127  * // set timeout period to 100 ms
128  * tickValue = Watchdog_convertMsToTicks(handle, 100);
129  * Watchdog_setReload(handle, tickValue);
130  *
131  * @endcode
132  */
133 
134 #ifndef ti_drivers_watchdog_WatchdogCC26X4__include
135 #define ti_drivers_watchdog_WatchdogCC26X4__include
136 
137 #include <stdint.h>
138 #include <stdbool.h>
139 #include <ti/drivers/Watchdog.h>
140 #include <ti/drivers/dpl/HwiP.h>
141 
142 #ifdef __cplusplus
143 extern "C" {
144 #endif
145 
156 /* Add WatchdogCC26X4_STATUS_* macros here */
157 
170 /* Add WatchdogCC26X4_CMD_* macros here */
171 
176 
180 typedef struct
181 {
182  unsigned long reloadValue;
184 
190 typedef struct
191 {
192  bool isOpen; /* Flag for open/close status */
193  Watchdog_DebugMode debugStallMode; /* Mode to stall Watchdog at breakpoints */
194  /* Watchdog SYS/BIOS objects */
195  HwiP_Struct hwi; /* Hwi object */
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 
202 #endif /* ti_drivers_watchdog_WatchdogCC26X4__include */
const Watchdog_FxnTable WatchdogCC26X4_fxnTable
Watchdog function table for CC26X4.
Watchdog_DebugMode debugStallMode
Definition: WatchdogCC26X4.h:193
Watchdog driver interface.
Watchdog Object for CC26X4.
Definition: WatchdogCC26X4.h:190
bool isOpen
Definition: WatchdogCC26X4.h:192
Watchdog_DebugMode
Watchdog debug stall settings.
Definition: Watchdog.h:264
HwiP_Struct hwi
Definition: WatchdogCC26X4.h:195
The definition of a Watchdog function table that contains the required set of functions to control a ...
Definition: Watchdog.h:360
Watchdog hardware attributes for CC26X4.
Definition: WatchdogCC26X4.h:180
unsigned long reloadValue
Definition: WatchdogCC26X4.h:182
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale