WatchdogWFF3.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024-2025, 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 WatchdogWFF3.h
34  *
35  * @brief Watchdog driver implementation for WiFi F3 devices
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/WatchdogWFF3.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 WatchdogWFF3_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 WFF3 device.
55  * Before using the Watchdog on WFF3, the Watchdog driver is initialized by
56  * calling #Watchdog_init(). The Watchdog HW is configured by calling
57  * #Watchdog_open(). Once opened, the Watchdog will count up from zero to the
58  * reload value specified in #WatchdogWFF3_HWAttrs. If it times out, a reset
59  * signal will be generated. To prevent a reset, #Watchdog_clear() must be
60  * called to clear the timer, or #Watchdog_close() to stop the Watchdog timer.
61  *
62  * @note
63  * In these devices, the Watchdog Timer operates differently: it counts up to
64  * the reload value (reset threshold) instead of counting down from a reload
65  * value to zero as described in the general API. However, the device-specific
66  * API abstracts this difference, allowing the user to interact with the
67  * Watchdog Timer as though it behaves as described in the general API. Be
68  * aware that internally, the implementation and naming conventions may differ
69  * to accommodate this behavior.
70  *
71  * The Watchdog counts up at the rate of the device clock LFCLK divided by 2^8,
72  * which results in a frequency of 128 Hz. The watchdog driver assumes LFCLK is
73  * running at 32768 Hz and will not produce accurate timeouts at other
74  * frequencies. LFOSC is an inherently inaccurate clock source and will present
75  * variations around the target 32768 Hz frequency. These inaccuracies have to
76  * be taken into consideration at the application level.
77  *
78  * The reload value which the Watchdog timer counts up to may be changed during
79  * runtime using #Watchdog_setReload(). This value should be specified in
80  * Watchdog threshold ticks and should not exceed "2^23 - 1" or fall below "1".
81  * At the rate of 128 Hz, the resolution of each threshold tick is 7.8125 ms.
82  * This corresponds to a maximum timeout period of 65535992 ms and a minimum
83  * period of 7.8125 ms. Calling #Watchdog_setReload() will also reset counter
84  * value.
85  *
86  * The function #Watchdog_convertMsToTicks() can be used to convert from ms
87  * to Watchdog threshold ticks. If the converted value exceeds or falls below
88  * the allowed range, a zero (0) will be returned to indicate
89  * overflow/underflow. The period has a resolution of 7.8125 ms, which imposes
90  * limitations on achieving certain exact values. When a requested period
91  * cannot be precisely implemented, the system will automatically adjust to the
92  * nearest possible value within the resolution. For instance, if a period of
93  * 22 ms is specified, the actual implemented period will be 23.4375 ms.
94  *
95  * #Watchdog_close() can be used to stop the Watchdog timer.
96  *
97  * <b>No</b> WFF3 specific command exists. Any call to #Watchdog_control() will
98  * return #Watchdog_STATUS_UNDEFINEDCMD.
99  *
100  * The Watchdog module available on WFF3 devices does not support debug
101  * stalling. Therefore, the #Watchdog_Params.debugStallMode parameter in the
102  * #Watchdog_Params struct must be Watchdog_DEBUG_STALL_OFF will. Calling
103  * #Watchdog_open() with the debug stall mode to Watchdog_DEBUG_STALL_ON will
104  * fail and return a NULL handle.
105  *
106  * The Watchdog driver available for WFF3 only supports reset enabled mode, it
107  * cannot be used as a timer interrupt, that is, specifying a callback function
108  * is not supported by the driver.
109  *
110  * # Power Management #
111  * Once started, the Watchdog will keep running in Active, Idle and Standby
112  * mode. Note that the Watchdog timer is restarted by the Power driver whenever
113  * the device enters Standby. If the device remains in Standby for a duration
114  * longer than the Watchdog timeout, the device will reset.
115  *
116  * # Supported Functions #
117  * | Generic API Function | API Function | Description |
118  * |------------------------------|---------------------------------|-------------------------------------------|
119  * | #Watchdog_init() | WatchdogWFF3_init() | Initialize Watchdog driver |
120  * | #Watchdog_open() | WatchdogWFF3_open() | Initialize HW and set system dependencies |
121  * | #Watchdog_clear() | WatchdogWFF3_clear() | Reload Watchdog counter |
122  * | #Watchdog_setReload() | WatchdogWFF3_setReload() | Update timer reload value in clock ticks |
123  * | #Watchdog_convertMsToTicks() | WatchdogWFF3_convertMsToTicks() | Converts milliseconds to clock ticks |
124  * | #Watchdog_close() | WatchdogWFF3_close() | Stop Watchdog timer |
125  *
126  * @note All calls should go through the generic API. Please refer to @ref
127  * Watchdog.h for a complete description of the generic APIs.
128  *
129  * # Use Cases #
130  * ## Basic Watchdog #
131  * In this basic watchdog example, the application is expected to start the
132  * Watchdog timer by calling #Watchdog_open(). If needed, #Watchdog_setReload()
133  * may be called to change the timeout period. If all monitored tasks are doing
134  * alright, #Watchdog_clear() should be called regularly to reload the counter
135  * so as to restart the timeout period and to avoid the Watchdog resetting the
136  * device. If the #Watchdog_clear() is missed and the Watchdog timer is allowed
137  * to timeout, the device will be reset.
138  *
139  * The following code example shows how to correctly initialize the driver's
140  * parameters, start the Watchdog timer and modify at runtime the timeout
141  * period.
142  * @code
143  *
144  * Watchdog_Handle handle;
145  * Watchdog_Params params;
146  * uint32_t tickValue;
147  *
148  * Watchdog_init();
149  * Watchdog_Params_init(&params);
150  * params.debugStallMode = Watchdog_DEBUG_STALL_OFF;
151  * handle = Watchdog_open(Watchdog_configIndex, &params);
152  * // set timeout period to 100 ms
153  * tickValue = Watchdog_convertMsToTicks(handle, 100);
154  * Watchdog_setReload(handle, tickValue);
155  *
156  * @endcode
157  */
158 
159 #ifndef ti_drivers_watchdog_WatchdogWFF3__include
160 #define ti_drivers_watchdog_WatchdogWFF3__include
161 
162 #include <stdint.h>
163 #include <stdbool.h>
164 #include <ti/drivers/Watchdog.h>
165 
166 #ifdef __cplusplus
167 extern "C" {
168 #endif
169 
174 
178 typedef struct
179 {
180  uint32_t reloadValue;
182 
188 typedef struct
189 {
190  bool isOpen; /* Flag for open/close status */
192 
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif /* ti_drivers_watchdog_WatchdogWFF3__include */
uint32_t reloadValue
Definition: WatchdogWFF3.h:180
Watchdog driver interface.
Watchdog hardware attributes for WFF3.
Definition: WatchdogWFF3.h:178
bool isOpen
Definition: WatchdogWFF3.h:190
The definition of a Watchdog function table that contains the required set of functions to control a ...
Definition: Watchdog.h:357
Watchdog Object for WFF3.
Definition: WatchdogWFF3.h:188
const Watchdog_FxnTable WatchdogWFF3_fxnTable
Watchdog function table for WFF3.
© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale