xref: /btstack/port/msp432p401lp-cc256x/ti/devices/msp432p4xx/driverlib/wdt_a.h (revision cd5f23a3250874824c01a2b3326a9522fea3f99f)
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, 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  * --/COPYRIGHT--*/
32 #ifndef __WATCHDOG_H__
33 #define __WATCHDOG_H__
34 
35 //*****************************************************************************
36 //
37 //! \addtogroup wdt_api
38 //! @{
39 //
40 //*****************************************************************************
41 
42 //*****************************************************************************
43 //
44 // If building with a C++ compiler, make all of the definitions in this header
45 // have a C binding.
46 //
47 //*****************************************************************************
48 #ifdef __cplusplus
49 extern "C"
50 {
51 #endif
52 
53 /* Includes */
54 #include <ti/devices/msp432p4xx/inc/msp.h>
55 #include <stdint.h>
56 
57 #ifdef __MCU_HAS_SYSCTL_A__
58 
59 #define WDT_A_HARD_RESET SYSCTL_A_HARD_RESET
60 #define WDT_A_SOFT_RESET SYSCTL_A_SOFT_RESET
61 
62 #else
63 
64 #define WDT_A_HARD_RESET SYSCTL_HARD_RESET
65 #define WDT_A_SOFT_RESET SYSCTL_SOFT_RESET
66 
67 #endif
68 
69 //*****************************************************************************
70 //
71 // The following are values that can be passed to the clockSelect parameter for
72 // functions: WDT_A_watchdogTimerInit(), and WDT_A_intervalTimerInit().
73 //
74 //*****************************************************************************
75 #define WDT_A_CLOCKSOURCE_SMCLK                                     (WDT_A_CTL_SSEL_0)
76 #define WDT_A_CLOCKSOURCE_ACLK                                      (WDT_A_CTL_SSEL_1)
77 #define WDT_A_CLOCKSOURCE_VLOCLK                                    (WDT_A_CTL_SSEL_2)
78 #define WDT_A_CLOCKSOURCE_BCLK                                      (WDT_A_CTL_SSEL_3)
79 
80 //*****************************************************************************
81 //
82 // The following are values that can be passed to the clockDivider parameter
83 // for functions: WDT_A_watchdogTimerInit(), and WDT_A_intervalTimerInit().
84 //
85 //*****************************************************************************
86 #define WDT_A_CLOCKDIVIDER_2G                                         (WDT_A_CTL_IS_0)
87 #define WDT_A_CLOCKDIVIDER_128M                                       (WDT_A_CTL_IS_1)
88 #define WDT_A_CLOCKDIVIDER_8192K                                      (WDT_A_CTL_IS_2)
89 #define WDT_A_CLOCKDIVIDER_512K                                       (WDT_A_CTL_IS_3)
90 #define WDT_A_CLOCKDIVIDER_32K                                        (WDT_A_CTL_IS_4)
91 #define WDT_A_CLOCKDIVIDER_8192                                       (WDT_A_CTL_IS_5)
92 #define WDT_A_CLOCKDIVIDER_512                                        (WDT_A_CTL_IS_6)
93 #define WDT_A_CLOCKDIVIDER_64                                         (WDT_A_CTL_IS_7)
94 #define WDT_A_CLOCKITERATIONS_2G    WDT_A_CLOCKDIVIDER_2G
95 #define WDT_A_CLOCKITERATIONS_128M  WDT_A_CLOCKDIVIDER_128M
96 #define WDT_A_CLOCKITERATIONS_8192K WDT_A_CLOCKDIVIDER_8192K
97 #define WDT_A_CLOCKITERATIONS_512K  WDT_A_CLOCKDIVIDER_512K
98 #define WDT_A_CLOCKITERATIONS_32K   WDT_A_CLOCKDIVIDER_32K
99 #define WDT_A_CLOCKITERATIONS_8192  WDT_A_CLOCKDIVIDER_8192
100 #define WDT_A_CLOCKITERATIONS_512   WDT_A_CLOCKDIVIDER_512
101 #define WDT_A_CLOCKITERATIONS_64    WDT_A_CLOCKDIVIDER_64
102 
103 //*****************************************************************************
104 //
105 // Prototypes for the APIs.
106 //
107 //*****************************************************************************
108 
109 //*****************************************************************************
110 //
111 //! Holds the Watchdog Timer.
112 //!
113 //! This function stops the watchdog timer from running. This way no interrupt
114 //! or PUC is asserted.
115 //!
116 //! \return None
117 //
118 //*****************************************************************************
119 extern void WDT_A_holdTimer(void);
120 
121 //*****************************************************************************
122 //
123 //! Starts the Watchdog Timer.
124 //!
125 //! This function starts the watchdog timer functionality to start counting.
126 //!
127 //! \return None
128 //
129 //*****************************************************************************
130 extern void WDT_A_startTimer(void);
131 
132 //*****************************************************************************
133 //
134 //! Clears the timer counter of the Watchdog Timer.
135 //!
136 //! This function clears the watchdog timer count to 0x0000h. This function
137 //! is used to "service the dog" when operating in watchdog mode.
138 //!
139 //! \return None
140 //
141 //*****************************************************************************
142 extern void WDT_A_clearTimer(void);
143 
144 //*****************************************************************************
145 //
146 //! Sets the clock source for the Watchdog Timer in watchdog mode.
147 //!
148 //! \param clockSelect is the clock source that the watchdog timer will use.
149 //!        Valid values are
150 //!        - \b WDT_A_CLOCKSOURCE_SMCLK [Default]
151 //!        - \b WDT_A_CLOCKSOURCE_ACLK
152 //!        - \b WDT_A_CLOCKSOURCE_VLOCLK
153 //!        - \b WDT_A_CLOCKSOURCE_BCLK
154 //! \param clockIterations is the number of clock iterations for a watchdog
155 //!         timeout.
156 //!        Valid values are
157 //!        - \b WDT_A_CLOCKITERATIONS_2G [Default]
158 //!        - \b WDT_A_CLOCKITERATIONS_128M
159 //!        - \b WDT_A_CLOCKITERATIONS_8192K
160 //!        - \b WDT_A_CLOCKITERATIONS_512K
161 //!        - \b WDT_A_CLOCKITERATIONS_32K
162 //!        - \b WDT_A_CLOCKITERATIONS_8192
163 //!        - \b WDT_A_CLOCKITERATIONS_512
164 //!        - \b WDT_A_CLOCKITERATIONS_64
165 //!
166 //! This function sets the watchdog timer in watchdog mode, which will cause a
167 //! PUC when the timer overflows. When in the mode, a PUC can be avoided with a
168 //! call to WDT_A_resetTimer() before the timer runs out.
169 //!
170 //! \return None
171 //
172 //*****************************************************************************
173 extern void WDT_A_initWatchdogTimer(uint_fast8_t clockSelect,
174         uint_fast8_t clockDivider);
175 
176 //*****************************************************************************
177 //
178 //! Sets the clock source for the Watchdog Timer in timer interval mode.
179 //!
180 //! \param clockSelect is the clock source that the watchdog timer will use.
181 //!        Valid values are
182 //!        - \b WDT_A_CLOCKSOURCE_SMCLK [Default]
183 //!        - \b WDT_A_CLOCKSOURCE_ACLK
184 //!        - \b WDT_A_CLOCKSOURCE_VLOCLK
185 //!        - \b WDT_A_CLOCKSOURCE_BCLK
186 //! \param clockIterations is the number of clock iterations for a watchdog
187 //!         interval.
188 //!        Valid values are
189 //!        - \b WDT_A_CLOCKITERATIONS_2G [Default]
190 //!        - \b WDT_A_CLOCKITERATIONS_128M
191 //!        - \b WDT_A_CLOCKITERATIONS_8192K
192 //!        - \b WDT_A_CLOCKITERATIONS_512K
193 //!        - \b WDT_A_CLOCKITERATIONS_32K
194 //!        - \b WDT_A_CLOCKITERATIONS_8192
195 //!        - \b WDT_A_CLOCKITERATIONS_512
196 //!        - \b WDT_A_CLOCKITERATIONS_64
197 //!
198 //! This function sets the watchdog timer as timer interval mode, which will
199 //! assert an interrupt without causing a PUC.
200 //!
201 //! \return None
202 //
203 //*****************************************************************************
204 extern void WDT_A_initIntervalTimer(uint_fast8_t clockSelect,
205         uint_fast8_t clockDivider);
206 
207 //*****************************************************************************
208 //
209 //! Registers an interrupt handler for the watchdog interrupt.
210 //!
211 //! \param intHandler is a pointer to the function to be called when the
212 //! watchdog interrupt occurs.
213 //!
214 //! \return None.
215 //
216 //*****************************************************************************
217 extern void WDT_A_registerInterrupt(void (*intHandler)(void));
218 
219 //*****************************************************************************
220 //
221 //! Unregisters the interrupt handler for the watchdog.
222 //!
223 //! This function unregisters the handler to be called when a watchdog
224 //! interrupt occurs.  This function also masks off the interrupt in the
225 //! interrupt controller so that the interrupt handler no longer is called.
226 //!
227 //! \sa Interrupt_registerInterrupt() for important information about
228 //! registering interrupt handlers.
229 //!
230 //! \return None.
231 //
232 //*****************************************************************************
233 extern void WDT_A_unregisterInterrupt(void);
234 
235 //*****************************************************************************
236 //
237 //! Sets the type of RESET that happens when a watchdog password violation
238 //! occurs.
239 //!
240 //! \param resetType The type of reset to set
241 //!
242 //! The \e resetType parameter must be only one of the following values:
243 //!     - \b WDT_A_HARD_RESET
244 //!     - \b WDT_A_SOFT_RESET
245 //!
246 //! \return None.
247 //
248 //
249 //*****************************************************************************
250 extern void WDT_A_setPasswordViolationReset(uint_fast8_t resetType);
251 
252 //*****************************************************************************
253 //
254 //! Sets the type of RESET that happens when a watchdog timeout occurs.
255 //!
256 //! \param resetType The type of reset to set
257 //!
258 //! The \e resetType parameter must be only one of the following values:
259 //!     - \b WDT_A_HARD_RESET
260 //!     - \b WDT_A_SOFT_RESET
261 //!
262 //! \return None.
263 //
264 //
265 //*****************************************************************************
266 extern void WDT_A_setTimeoutReset(uint_fast8_t resetType);
267 
268 /* Defines for future devices that might have multiple instances */
269 #define WDT_A_holdTimerMultipleTimer(a)  WDT_A_holdTimer()
270 #define WDT_A_startTimerMultipleTimer(a) WDT_A_startTimer()
271 #define WDT_A_resetTimerMultipleTimer(a) WDT_A_clearTimer()
272 #define WDT_A_initWatchdogTimerMultipleTimer(a,b,c) WDT_A_initWatchdogTimer(b,c)
273 #define WDT_A_initIntervalTimerMultipleTimer(a,b,c) WDT_A_initIntervalTimer(b,c)
274 #define WDT_A_registerInterruptMultipleTimer(a,b) WDT_A_registerInterrupt(b)
275 #define WDT_A_unregisterInterruptMultipleTimer(a) WDT_A_unregisterInterrupt()
276 
277 /* Backwards compatibility layer */
278 #define WDT_A_hold WDT_A_holdTimerMultipleTimer
279 #define WDT_A_start WDT_A_startTimerMultipleTimer
280 #define WDT_A_resetTimer WDT_A_resetTimerMultipleTimer
281 #define WDT_A_watchdogTimerInit WDT_A_initWatchdogTimerMultipleTimer
282 #define WDT_A_intervalTimerInit WDT_A_initIntervalTimerMultipleTimer
283 
284 //*****************************************************************************
285 //
286 // Mark the end of the C bindings section for C++ compilers.
287 //
288 //*****************************************************************************
289 #ifdef __cplusplus
290 }
291 #endif
292 
293 //*****************************************************************************
294 //
295 // Close the Doxygen group.
296 //! @}
297 //
298 //*****************************************************************************
299 
300 #endif // __WATCHDOG_H__
301