WatchdogLPF3.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-2023, 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 WatchdogLPF3.h
34  *
35  * @brief Watchdog driver implementation for Low Power 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/WatchdogLPF3.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 WatchdogLPF3_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 CC23X0
55  * device. Before using the Watchdog on CC23X0, 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 #WatchdogLPF3_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 LFCLK. The watchdog
63  * driver assumes LFCLK is running at 32768Hz and will not produce accurate
64  * timeouts at other frequencies. LFOSC is an inherently inaccurate clock
65  * source and will present variations around the target 32768 Hz frequency.
66  * These inaccuracies have to be taken into consideration at the application
67  * level.
68  *
69  * The reload value from which the Watchdog timer counts down may be changed
70  * during runtime using #Watchdog_setReload(). This value should be specified
71  * in Watchdog clock ticks and should not exceed "2^32 - 1". This corresponds to
72  * a timeout period of 131071 seconds, calculated at the highest rate of 32768
73  * kHz. If the reload value is set to zero, the Watchdog reset is immediately
74  * generated.
75  *
76  * Watchdog_close() is <b>not</b> supported by this driver implementation. Once
77  * started, the Watchdog timer can only be stopped by a hardware reset.
78  *
79  * <b>No</b> CC23X0 specific command has been implemented. Any call to
80  * Watchdog_control() will receive the return code Watchdog_STATUS_UNDEFINEDCMD.
81  *
82  * The Watchdog module available on CC23X0 devices does not support reset
83  * masking or interrupt generation. Therefore, the two parameters \ref
84  * Watchdog_Params.resetMode and \ref Watchdog_Params.callbackFxn in the \ref
85  * Watchdog_Params struct are not supported and will be ignored by the Watchdog
86  * driver.
87  *
88  * # Power Management #
89  * Once started, the Watchdog will keep running in Active, Idle and Standby mode.
90  *
91  * # Supported Functions #
92  * | Generic API Function | API Function | Description |
93  * |------------------------------ |----------------------------------
94  * |--------------------------------------------------- | | #Watchdog_init() | WatchdogLPF3_init() |
95  * Initialize Watchdog driver | | #Watchdog_open() | WatchdogLPF3_open() |
96  * Initialize Watchdog HW and set system dependencies | | #Watchdog_clear() | WatchdogLPF3_clear() |
97  * Reload Watchdog counter | | #Watchdog_setReload() | WatchdogLPF3_setReload() |
98  * Update Watchdog timer reload value in clock ticks | | #Watchdog_convertMsToTicks() |
99  * WatchdogLPF3_convertMsToTicks() | Converts milliseconds to clock ticks |
100  *
101  * @note All calls should go through the generic API. Please refer to @ref Watchdog.h for a
102  * complete description of the generic APIs.
103  *
104  * # Use Cases #
105  * ## Basic Watchdog #
106  * In this basic watchdog example, the application is expected to start the Watchdog
107  * timer by calling #Watchdog_open(). If needed, #Watchdog_setReload() may be
108  * called to change the timeout period. If all monitored tasks are doing alright,
109  * #Watchdog_clear() should be called regularly to reload the counter so as to
110  * restart the timeout period and to avoid the Watchdog resetting the device.
111  * If the #Watchdog_clear() is missed and the Watchdog timer is allowed to
112  * timeout, the device will be reset.
113  *
114  * The following code example shows how to correctly initialize the driver's
115  * parameters, start the Watchdog timer and modify at runtime the timeout period.
116  * @code
117  *
118  * Watchdog_Handle handle;
119  * Watchdog_Params params;
120  * uint32_t tickValue;
121  *
122  * Watchdog_init();
123  * Watchdog_Params_init(&params);
124  * handle = Watchdog_open(Watchdog_configIndex, &params);
125  * // set timeout period to 100 ms
126  * tickValue = Watchdog_convertMsToTicks(handle, 100);
127  * Watchdog_setReload(handle, tickValue);
128  *
129  * @endcode
130  */
131 
132 #ifndef ti_drivers_watchdog_WatchdogLPF3__include
133 #define ti_drivers_watchdog_WatchdogLPF3__include
134 
135 #include <stdint.h>
136 #include <stdbool.h>
137 #include <ti/drivers/Watchdog.h>
138 #include <ti/drivers/dpl/HwiP.h>
139 
140 #ifdef __cplusplus
141 extern "C" {
142 #endif
143 
154 /* Add WatchdogLPF3_STATUS_* macros here */
155 
168 /* Add WatchdogLPF3_CMD_* macros here */
169 
174 
178 typedef struct
179 {
180  unsigned long reloadValue;
182 
188 typedef struct
189 {
190  bool isOpen; /* Flag for open/close status */
191  Watchdog_DebugMode debugStallMode; /* Mode to stall Watchdog at breakpoints */
192  /* Watchdog OS objects */
193  HwiP_Struct hwi; /* Hwi object */
195 
196 #ifdef __cplusplus
197 }
198 #endif
199 
200 #endif /* ti_drivers_watchdog_WatchdogLPF3__include */
unsigned long reloadValue
Definition: WatchdogLPF3.h:180
Watchdog_DebugMode debugStallMode
Definition: WatchdogLPF3.h:191
Watchdog driver interface.
Watchdog Object for CC23X0.
Definition: WatchdogLPF3.h:188
bool isOpen
Definition: WatchdogLPF3.h:190
const Watchdog_FxnTable WatchdogLPF3_fxnTable
Watchdog function table for CC23X0.
Watchdog_DebugMode
Watchdog debug stall settings.
Definition: Watchdog.h:264
HwiP_Struct hwi
Definition: WatchdogLPF3.h:193
Watchdog hardware attributes for CC23X0.
Definition: WatchdogLPF3.h:178
The definition of a Watchdog function table that contains the required set of functions to control a ...
Definition: Watchdog.h:360
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale