2 * -------------------------------------------
3 * MSP432 DriverLib - v01_04_00_18
4 * -------------------------------------------
6 * --COPYRIGHT--,BSD,BSD
7 * Copyright (c) 2015, Texas Instruments Incorporated
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * * Neither the name of Texas Instruments Incorporated nor the names of
22 * its contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #ifndef __WATCHDOG_H__
38 #define __WATCHDOG_H__
40 //*****************************************************************************
42 //! \addtogroup wdt_api
45 //*****************************************************************************
47 //*****************************************************************************
49 // If building with a C++ compiler, make all of the definitions in this header
52 //*****************************************************************************
62 #define WDT_A_HARD_RESET SYSCTL_HARD_RESET
63 #define WDT_A_SOFT_RESET SYSCTL_SOFT_RESET
65 //*****************************************************************************
67 // The following are values that can be passed to the clockSelect parameter for
68 // functions: WDT_A_watchdogTimerInit(), and WDT_A_intervalTimerInit().
70 //*****************************************************************************
71 #define WDT_A_CLOCKSOURCE_SMCLK (WDTSSEL_0)
72 #define WDT_A_CLOCKSOURCE_ACLK (WDTSSEL_1)
73 #define WDT_A_CLOCKSOURCE_VLOCLK (WDTSSEL_2)
74 #define WDT_A_CLOCKSOURCE_XCLK (WDTSSEL_3)
76 //*****************************************************************************
78 // The following are values that can be passed to the clockDivider parameter
79 // for functions: WDT_A_watchdogTimerInit(), and WDT_A_intervalTimerInit().
81 //*****************************************************************************
82 #define WDT_A_CLOCKDIVIDER_2G (WDTIS_0)
83 #define WDT_A_CLOCKDIVIDER_128M (WDTIS_1)
84 #define WDT_A_CLOCKDIVIDER_8192K (WDTIS_2)
85 #define WDT_A_CLOCKDIVIDER_512K (WDTIS_3)
86 #define WDT_A_CLOCKDIVIDER_32K (WDTIS_4)
87 #define WDT_A_CLOCKDIVIDER_8192 (WDTIS_5)
88 #define WDT_A_CLOCKDIVIDER_512 (WDTIS_6)
89 #define WDT_A_CLOCKDIVIDER_64 (WDTIS_7)
90 #define WDT_A_CLOCKITERATIONS_2G WDT_A_CLOCKDIVIDER_2G
91 #define WDT_A_CLOCKITERATIONS_128M WDT_A_CLOCKDIVIDER_128M
92 #define WDT_A_CLOCKITERATIONS_8192K WDT_A_CLOCKDIVIDER_8192K
93 #define WDT_A_CLOCKITERATIONS_512K WDT_A_CLOCKDIVIDER_512K
94 #define WDT_A_CLOCKITERATIONS_32K WDT_A_CLOCKDIVIDER_32K
95 #define WDT_A_CLOCKITERATIONS_8192 WDT_A_CLOCKDIVIDER_8192
96 #define WDT_A_CLOCKITERATIONS_512 WDT_A_CLOCKDIVIDER_512
97 #define WDT_A_CLOCKITERATIONS_64 WDT_A_CLOCKDIVIDER_64
99 //*****************************************************************************
101 // Prototypes for the APIs.
103 //*****************************************************************************
105 //*****************************************************************************
107 //! Holds the Watchdog Timer.
109 //! This function stops the watchdog timer from running. This way no interrupt
110 //! or PUC is asserted.
114 //*****************************************************************************
115 extern void WDT_A_holdTimer(void);
117 //*****************************************************************************
119 //! Starts the Watchdog Timer.
121 //! This function starts the watchdog timer functionality to start counting.
125 //*****************************************************************************
126 extern void WDT_A_startTimer(void);
128 //*****************************************************************************
130 //! Clears the timer counter of the Watchdog Timer.
132 //! This function clears the watchdog timer count to 0x0000h. This function
133 //! is used to "service the dog" when operating in watchdog mode.
137 //*****************************************************************************
138 extern void WDT_A_clearTimer(void);
140 //*****************************************************************************
142 //! Sets the clock source for the Watchdog Timer in watchdog mode.
144 //! \param clockSelect is the clock source that the watchdog timer will use.
146 //! - \b WDT_A_CLOCKSOURCE_SMCLK [Default]
147 //! - \b WDT_A_CLOCKSOURCE_ACLK
148 //! - \b WDT_A_CLOCKSOURCE_VLOCLK
149 //! - \b WDT_A_CLOCKSOURCE_XCLK
150 //! \param clockIterations is the number of clock iterations for a watchdog
153 //! - \b WDT_A_CLOCKITERATIONS_2G [Default]
154 //! - \b WDT_A_CLOCKITERATIONS_128M
155 //! - \b WDT_A_CLOCKITERATIONS_8192K
156 //! - \b WDT_A_CLOCKITERATIONS_512K
157 //! - \b WDT_A_CLOCKITERATIONS_32K
158 //! - \b WDT_A_CLOCKITERATIONS_8192
159 //! - \b WDT_A_CLOCKITERATIONS_512
160 //! - \b WDT_A_CLOCKITERATIONS_64
162 //! This function sets the watchdog timer in watchdog mode, which will cause a
163 //! PUC when the timer overflows. When in the mode, a PUC can be avoided with a
164 //! call to WDT_A_resetTimer() before the timer runs out.
168 //*****************************************************************************
169 extern void WDT_A_initWatchdogTimer(uint_fast8_t clockSelect,
170 uint_fast8_t clockDivider);
172 //*****************************************************************************
174 //! Sets the clock source for the Watchdog Timer in timer interval mode.
176 //! \param clockSelect is the clock source that the watchdog timer will use.
178 //! - \b WDT_A_CLOCKSOURCE_SMCLK [Default]
179 //! - \b WDT_A_CLOCKSOURCE_ACLK
180 //! - \b WDT_A_CLOCKSOURCE_VLOCLK
181 //! - \b WDT_A_CLOCKSOURCE_XCLK
182 //! \param clockIterations is the number of clock iterations for a watchdog
185 //! - \b WDT_A_CLOCKITERATIONS_2G [Default]
186 //! - \b WDT_A_CLOCKITERATIONS_128M
187 //! - \b WDT_A_CLOCKITERATIONS_8192K
188 //! - \b WDT_A_CLOCKITERATIONS_512K
189 //! - \b WDT_A_CLOCKITERATIONS_32K
190 //! - \b WDT_A_CLOCKITERATIONS_8192
191 //! - \b WDT_A_CLOCKITERATIONS_512
192 //! - \b WDT_A_CLOCKITERATIONS_64
194 //! This function sets the watchdog timer as timer interval mode, which will
195 //! assert an interrupt without causing a PUC.
199 //*****************************************************************************
200 extern void WDT_A_initIntervalTimer(uint_fast8_t clockSelect,
201 uint_fast8_t clockDivider);
203 //*****************************************************************************
205 //! Registers an interrupt handler for the watchdog interrupt.
207 //! \param intHandler is a pointer to the function to be called when the
208 //! watchdog interrupt occurs.
212 //*****************************************************************************
213 extern void WDT_A_registerInterrupt(void (*intHandler)(void));
215 //*****************************************************************************
217 //! Unregisters the interrupt handler for the watchdog.
219 //! This function unregisters the handler to be called when a watchdog
220 //! interrupt occurs. This function also masks off the interrupt in the
221 //! interrupt controller so that the interrupt handler no longer is called.
223 //! \sa Interrupt_registerInterrupt() for important information about
224 //! registering interrupt handlers.
228 //*****************************************************************************
229 extern void WDT_A_unregisterInterrupt(void);
231 //*****************************************************************************
233 //! Sets the type of RESET that happens when a watchdog password violation
236 //! \param resetType The type of reset to set
238 //! The \e resetType parameter must be only one of the following values:
239 //! - \b WDT_A_HARD_RESET
240 //! - \b WDT_A_SOFT_RESET
245 //*****************************************************************************
246 extern void WDT_A_setPasswordViolationReset(uint_fast8_t resetType);
248 //*****************************************************************************
250 //! Sets the type of RESET that happens when a watchdog timeout occurs.
252 //! \param resetType The type of reset to set
254 //! The \e resetType parameter must be only one of the following values:
255 //! - \b WDT_A_HARD_RESET
256 //! - \b WDT_A_SOFT_RESET
261 //*****************************************************************************
262 extern void WDT_A_setTimeoutReset(uint_fast8_t resetType);
264 /* Defines for future devices that might have multiple instances */
265 #define WDT_A_holdTimerMultipleTimer(a) WDT_A_holdTimer()
266 #define WDT_A_startTimerMultipleTimer(a) WDT_A_startTimer()
267 #define WDT_A_resetTimerMultipleTimer(a) WDT_A_resetTimer()
268 #define WDT_A_initWatchdogTimerMultipleTimer(a,b,c) WDT_A_initWatchdogTimer(b,c)
269 #define WDT_A_initIntervalTimerMultipleTimer(a,b,c) WDT_A_initIntervalTimer(b,c)
270 #define WDT_A_registerInterruptMultipleTimer(a,b) WDT_A_registerInterrupt(b)
271 #define WDT_A_unregisterInterruptMultipleTimer(a) WDT_A_unregisterInterrupt()
273 /* Backwards compatibility layer */
274 #define WDT_A_hold WDT_A_holdTimerMultipleTimer
275 #define WDT_A_start WDT_A_startTimerMultipleTimer
276 #define WDT_A_resetTimer WDT_A_resetTimerMultipleTimer
277 #define WDT_A_watchdogTimerInit WDT_A_initWatchdogTimerMultipleTimer
278 #define WDT_A_intervalTimerInit WDT_A_initIntervalTimerMultipleTimer
280 //*****************************************************************************
282 // Mark the end of the C bindings section for C++ compilers.
284 //*****************************************************************************
289 //*****************************************************************************
291 // Close the Doxygen group.
294 //*****************************************************************************
296 #endif // __WATCHDOG_H__