2 * -------------------------------------------
3 * MSP432 DriverLib - v3_10_00_09
4 * -------------------------------------------
6 * --COPYRIGHT--,BSD,BSD
7 * Copyright (c) 2014, 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 (WDT_A_CTL_SSEL_0)
72 #define WDT_A_CLOCKSOURCE_ACLK (WDT_A_CTL_SSEL_1)
73 #define WDT_A_CLOCKSOURCE_VLOCLK (WDT_A_CTL_SSEL_2)
74 #define WDT_A_CLOCKSOURCE_XCLK (WDT_A_CTL_SSEL_3)
75 #define WDT_A_CLOCKSOURCE_BCLK (WDT_A_CTL_SSEL_4)
77 //*****************************************************************************
79 // The following are values that can be passed to the clockDivider parameter
80 // for functions: WDT_A_watchdogTimerInit(), and WDT_A_intervalTimerInit().
82 //*****************************************************************************
83 #define WDT_A_CLOCKDIVIDER_2G (WDT_A_CTL_IS_0)
84 #define WDT_A_CLOCKDIVIDER_128M (WDT_A_CTL_IS_1)
85 #define WDT_A_CLOCKDIVIDER_8192K (WDT_A_CTL_IS_2)
86 #define WDT_A_CLOCKDIVIDER_512K (WDT_A_CTL_IS_3)
87 #define WDT_A_CLOCKDIVIDER_32K (WDT_A_CTL_IS_4)
88 #define WDT_A_CLOCKDIVIDER_8192 (WDT_A_CTL_IS_5)
89 #define WDT_A_CLOCKDIVIDER_512 (WDT_A_CTL_IS_6)
90 #define WDT_A_CLOCKDIVIDER_64 (WDT_A_CTL_IS_7)
91 #define WDT_A_CLOCKITERATIONS_2G WDT_A_CLOCKDIVIDER_2G
92 #define WDT_A_CLOCKITERATIONS_128M WDT_A_CLOCKDIVIDER_128M
93 #define WDT_A_CLOCKITERATIONS_8192K WDT_A_CLOCKDIVIDER_8192K
94 #define WDT_A_CLOCKITERATIONS_512K WDT_A_CLOCKDIVIDER_512K
95 #define WDT_A_CLOCKITERATIONS_32K WDT_A_CLOCKDIVIDER_32K
96 #define WDT_A_CLOCKITERATIONS_8192 WDT_A_CLOCKDIVIDER_8192
97 #define WDT_A_CLOCKITERATIONS_512 WDT_A_CLOCKDIVIDER_512
98 #define WDT_A_CLOCKITERATIONS_64 WDT_A_CLOCKDIVIDER_64
100 //*****************************************************************************
102 // Prototypes for the APIs.
104 //*****************************************************************************
106 //*****************************************************************************
108 //! Holds the Watchdog Timer.
110 //! This function stops the watchdog timer from running. This way no interrupt
111 //! or PUC is asserted.
115 //*****************************************************************************
116 extern void WDT_A_holdTimer(void);
118 //*****************************************************************************
120 //! Starts the Watchdog Timer.
122 //! This function starts the watchdog timer functionality to start counting.
126 //*****************************************************************************
127 extern void WDT_A_startTimer(void);
129 //*****************************************************************************
131 //! Clears the timer counter of the Watchdog Timer.
133 //! This function clears the watchdog timer count to 0x0000h. This function
134 //! is used to "service the dog" when operating in watchdog mode.
138 //*****************************************************************************
139 extern void WDT_A_clearTimer(void);
141 //*****************************************************************************
143 //! Sets the clock source for the Watchdog Timer in watchdog mode.
145 //! \param clockSelect is the clock source that the watchdog timer will use.
147 //! - \b WDT_A_CLOCKSOURCE_SMCLK [Default]
148 //! - \b WDT_A_CLOCKSOURCE_ACLK
149 //! - \b WDT_A_CLOCKSOURCE_VLOCLK
150 //! - \b WDT_A_CLOCKSOURCE_BCLK
151 //! \param clockIterations is the number of clock iterations for a watchdog
154 //! - \b WDT_A_CLOCKITERATIONS_2G [Default]
155 //! - \b WDT_A_CLOCKITERATIONS_128M
156 //! - \b WDT_A_CLOCKITERATIONS_8192K
157 //! - \b WDT_A_CLOCKITERATIONS_512K
158 //! - \b WDT_A_CLOCKITERATIONS_32K
159 //! - \b WDT_A_CLOCKITERATIONS_8192
160 //! - \b WDT_A_CLOCKITERATIONS_512
161 //! - \b WDT_A_CLOCKITERATIONS_64
163 //! This function sets the watchdog timer in watchdog mode, which will cause a
164 //! PUC when the timer overflows. When in the mode, a PUC can be avoided with a
165 //! call to WDT_A_resetTimer() before the timer runs out.
169 //*****************************************************************************
170 extern void WDT_A_initWatchdogTimer(uint_fast8_t clockSelect,
171 uint_fast8_t clockDivider);
173 //*****************************************************************************
175 //! Sets the clock source for the Watchdog Timer in timer interval mode.
177 //! \param clockSelect is the clock source that the watchdog timer will use.
179 //! - \b WDT_A_CLOCKSOURCE_SMCLK [Default]
180 //! - \b WDT_A_CLOCKSOURCE_ACLK
181 //! - \b WDT_A_CLOCKSOURCE_VLOCLK
182 //! - \b WDT_A_CLOCKSOURCE_BCLK
183 //! \param clockIterations is the number of clock iterations for a watchdog
186 //! - \b WDT_A_CLOCKITERATIONS_2G [Default]
187 //! - \b WDT_A_CLOCKITERATIONS_128M
188 //! - \b WDT_A_CLOCKITERATIONS_8192K
189 //! - \b WDT_A_CLOCKITERATIONS_512K
190 //! - \b WDT_A_CLOCKITERATIONS_32K
191 //! - \b WDT_A_CLOCKITERATIONS_8192
192 //! - \b WDT_A_CLOCKITERATIONS_512
193 //! - \b WDT_A_CLOCKITERATIONS_64
195 //! This function sets the watchdog timer as timer interval mode, which will
196 //! assert an interrupt without causing a PUC.
200 //*****************************************************************************
201 extern void WDT_A_initIntervalTimer(uint_fast8_t clockSelect,
202 uint_fast8_t clockDivider);
204 //*****************************************************************************
206 //! Registers an interrupt handler for the watchdog interrupt.
208 //! \param intHandler is a pointer to the function to be called when the
209 //! watchdog interrupt occurs.
213 //*****************************************************************************
214 extern void WDT_A_registerInterrupt(void (*intHandler)(void));
216 //*****************************************************************************
218 //! Unregisters the interrupt handler for the watchdog.
220 //! This function unregisters the handler to be called when a watchdog
221 //! interrupt occurs. This function also masks off the interrupt in the
222 //! interrupt controller so that the interrupt handler no longer is called.
224 //! \sa Interrupt_registerInterrupt() for important information about
225 //! registering interrupt handlers.
229 //*****************************************************************************
230 extern void WDT_A_unregisterInterrupt(void);
232 //*****************************************************************************
234 //! Sets the type of RESET that happens when a watchdog password violation
237 //! \param resetType The type of reset to set
239 //! The \e resetType parameter must be only one of the following values:
240 //! - \b WDT_A_HARD_RESET
241 //! - \b WDT_A_SOFT_RESET
246 //*****************************************************************************
247 extern void WDT_A_setPasswordViolationReset(uint_fast8_t resetType);
249 //*****************************************************************************
251 //! Sets the type of RESET that happens when a watchdog timeout occurs.
253 //! \param resetType The type of reset to set
255 //! The \e resetType parameter must be only one of the following values:
256 //! - \b WDT_A_HARD_RESET
257 //! - \b WDT_A_SOFT_RESET
262 //*****************************************************************************
263 extern void WDT_A_setTimeoutReset(uint_fast8_t resetType);
265 /* Defines for future devices that might have multiple instances */
266 #define WDT_A_holdTimerMultipleTimer(a) WDT_A_holdTimer()
267 #define WDT_A_startTimerMultipleTimer(a) WDT_A_startTimer()
268 #define WDT_A_resetTimerMultipleTimer(a) WDT_A_clearTimer()
269 #define WDT_A_initWatchdogTimerMultipleTimer(a,b,c) WDT_A_initWatchdogTimer(b,c)
270 #define WDT_A_initIntervalTimerMultipleTimer(a,b,c) WDT_A_initIntervalTimer(b,c)
271 #define WDT_A_registerInterruptMultipleTimer(a,b) WDT_A_registerInterrupt(b)
272 #define WDT_A_unregisterInterruptMultipleTimer(a) WDT_A_unregisterInterrupt()
274 /* Backwards compatibility layer */
275 #define WDT_A_hold WDT_A_holdTimerMultipleTimer
276 #define WDT_A_start WDT_A_startTimerMultipleTimer
277 #define WDT_A_resetTimer WDT_A_resetTimerMultipleTimer
278 #define WDT_A_watchdogTimerInit WDT_A_initWatchdogTimerMultipleTimer
279 #define WDT_A_intervalTimerInit WDT_A_initIntervalTimerMultipleTimer
281 //*****************************************************************************
283 // Mark the end of the C bindings section for C++ compilers.
285 //*****************************************************************************
290 //*****************************************************************************
292 // Close the Doxygen group.
295 //*****************************************************************************
297 #endif // __WATCHDOG_H__