WatchdogCC32XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2019, 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 WatchdogCC32XX.h
34  * @brief Watchdog timer driver implementation for CC32XX
35  *
36  * The Watchdog header file for CC32XX should be included in an application
37  * as follows:
38  * @code
39  * #include <ti/drivers/Watchdog.h>
40  * #include <ti/drivers/watchdog/WatchdogCC32XX.h>
41  * @endcode
42  *
43  * Refer to @ref Watchdog.h for a complete description of APIs.
44  *
45  * This Watchdog driver implementation is designed to operate on a CC32XX
46  * device. Once opened, CC32XX Watchdog will count down from the reload
47  * value specified in the WatchdogCC32XX_HWAttrs. If it times out, the
48  * Watchdog interrupt flag will be set, and a user-provided callback function
49  * will be called. If the Watchdog Timer is allowed to time out again while
50  * the interrupt flag is still pending, a reset signal will be generated.
51  * To prevent a reset, Watchdog_clear() must be called to clear the interrupt
52  * flag.
53  *
54  * @warning The watchdog peripheral does not support a Non-Maskable Interrupt (NMI).
55  *
56  * The reload value from which the Watchdog Timer counts down may be changed
57  * during runtime using Watchdog_setReload().
58  *
59  * Watchdog_close() is <b>not</b> supported by this driver implementation.
60  *
61  * By default the Watchdog driver has resets turned on. This feature cannot
62  * be disabled.
63  *
64  * To have a user-defined function run at the warning interrupt, first define
65  * a void-type function that takes a Watchdog_Handle cast to a UArg as an
66  * argument. The callback and code to start the Watchdog timer are shown below.
67  *
68  * @code
69  * void watchdogCallback(UArg handle);
70  *
71  * ...
72  *
73  * Watchdog_Handle handle;
74  * Watchdog_Params params;
75  * uint32_t tickValue;
76  *
77  * Watchdog_Params_init(&params);
78  * params.callbackFxn = watchdogCallback;
79  * handle = Watchdog_open(Watchdog_configIndex, &params);
80  * // Set timeout period to 100 ms
81  * tickValue = Watchdog_convertMsToTicks(handle, 100);
82  * Watchdog_setReload(handle, tickValue);
83  *
84  * ...
85  *
86  * void watchdogCallback(UArg handle)
87  * {
88  * // User-defined code here
89  * ...
90  *
91  * }
92  * @endcode
93  *
94  * # Power Driver Usage #
95  *
96  * The watchdog timer driver does not set any power constraints. If the power
97  * driver is enabled, the application will continue to aggressively attempt
98  * to place the device into the lowest power state possible.
99  *
100  * When the device enters Low Power Deep Sleep, the peripheral registers are
101  * reset. After a transition from Low Power Deep Sleep, the watchdog timer will
102  * be re-initialized automatically with the most recently set reload value. If
103  * Watchdog_setReload() was never called, the
104  * #WatchdogCC32XX_HWAttrs.reloadValue is used. With each transition to and
105  * from Low Power Deep Sleep, the watchdog timer is implicitly cleared.
106  *
107  ******************************************************************************
108  */
109 
110 #ifndef ti_drivers_watchdog_WatchdogCC32XX__include
111 #define ti_drivers_watchdog_WatchdogCC32XX__include
112 
113 #include <stdint.h>
114 #include <stdbool.h>
115 #include <ti/drivers/Watchdog.h>
116 
117 #ifdef __cplusplus
118 extern "C" {
119 #endif
120 
131 /* Add WatchdogCC32XX_STATUS_* macros here */
132 
153 #define WatchdogCC32XX_CMD_IS_TIMER_ENABLE (Watchdog_CMD_RESERVED + 0)
154 
155 
163 #define WatchdogCC32XX_CMD_GET_TIMER_VALUE (Watchdog_CMD_RESERVED + 1)
164 
165 
174 #define WatchdogCC32XX_CMD_IS_TIMER_LOCKED (Watchdog_CMD_RESERVED + 2)
175 
176 
185 #define WatchdogCC32XX_CMD_GET_TIMER_RELOAD_VALUE (Watchdog_CMD_RESERVED + 3)
186 
187 
192 
206 typedef struct {
207  unsigned int baseAddr;
208  unsigned int intNum;
209  unsigned int intPriority;
210  uint32_t reloadValue;
212 
218 typedef struct {
220  /*
221  * The reload value can be set at runtime; therefore we can't rely
222  * on the reload value supplied in the HWAttrs after a LPDS transition.
223  */
224  uint32_t reloadValue;
226  bool isOpen;
228 
229 #ifdef __cplusplus
230 }
231 #endif
232 
233 #endif /* ti_drivers_watchdog_WatchdogCC32XX__include */
Watchdog_DebugMode debugMode
Definition: WatchdogCC32XX.h:225
unsigned int intPriority
Definition: WatchdogCC32XX.h:209
uint32_t reloadValue
Definition: WatchdogCC32XX.h:210
Watchdog driver interface.
Watchdog Object for CC32XX.
Definition: WatchdogCC32XX.h:218
Watchdog hardware attributes for CC32XX.
Definition: WatchdogCC32XX.h:206
Power_NotifyObj notifyObj
Definition: WatchdogCC32XX.h:219
Watchdog_DebugMode
Watchdog debug stall settings.
Definition: Watchdog.h:264
uint32_t reloadValue
Definition: WatchdogCC32XX.h:224
unsigned int baseAddr
Definition: WatchdogCC32XX.h:207
Power notify object structure.
Definition: Power.h:443
const Watchdog_FxnTable WatchdogCC32XX_fxnTable
Watchdog function table for CC32XX.
unsigned int intNum
Definition: WatchdogCC32XX.h:208
The definition of a Watchdog function table that contains the required set of functions to control a ...
Definition: Watchdog.h:362
bool isOpen
Definition: WatchdogCC32XX.h:226
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale