]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil/driverlib/wdt_a.h
Final V8.2.1 release ready for tagging:
[freertos] / FreeRTOS / Demo / CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil / driverlib / wdt_a.h
1 /*
2  * -------------------------------------------
3  *    MSP432 DriverLib - v01_04_00_18 
4  * -------------------------------------------
5  *
6  * --COPYRIGHT--,BSD,BSD
7  * Copyright (c) 2015, Texas Instruments Incorporated
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * *  Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  *
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.
20  *
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.
24  *
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.
36  * --/COPYRIGHT--*/
37 #ifndef __WATCHDOG_H__
38 #define __WATCHDOG_H__
39
40 //*****************************************************************************
41 //
42 //! \addtogroup wdt_api
43 //! @{
44 //
45 //*****************************************************************************
46
47 //*****************************************************************************
48 //
49 // If building with a C++ compiler, make all of the definitions in this header
50 // have a C binding.
51 //
52 //*****************************************************************************
53 #ifdef __cplusplus
54 extern "C"
55 {
56 #endif
57
58 #include <msp.h>
59 #include <stdint.h>
60 #include "sysctl.h"
61
62 #define WDT_A_HARD_RESET SYSCTL_HARD_RESET
63 #define WDT_A_SOFT_RESET SYSCTL_SOFT_RESET
64
65 //*****************************************************************************
66 //
67 // The following are values that can be passed to the clockSelect parameter for
68 // functions: WDT_A_watchdogTimerInit(), and WDT_A_intervalTimerInit().
69 //
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)
75
76 //*****************************************************************************
77 //
78 // The following are values that can be passed to the clockDivider parameter
79 // for functions: WDT_A_watchdogTimerInit(), and WDT_A_intervalTimerInit().
80 //
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
98
99 //*****************************************************************************
100 //
101 // Prototypes for the APIs.
102 //
103 //*****************************************************************************
104
105 //*****************************************************************************
106 //
107 //! Holds the Watchdog Timer.
108 //!
109 //! This function stops the watchdog timer from running. This way no interrupt
110 //! or PUC is asserted.
111 //!
112 //! \return None
113 //
114 //*****************************************************************************
115 extern void WDT_A_holdTimer(void);
116
117 //*****************************************************************************
118 //
119 //! Starts the Watchdog Timer.
120 //!
121 //! This function starts the watchdog timer functionality to start counting.
122 //!
123 //! \return None
124 //
125 //*****************************************************************************
126 extern void WDT_A_startTimer(void);
127
128 //*****************************************************************************
129 //
130 //! Clears the timer counter of the Watchdog Timer.
131 //!
132 //! This function clears the watchdog timer count to 0x0000h. This function
133 //! is used to "service the dog" when operating in watchdog mode.
134 //!
135 //! \return None
136 //
137 //*****************************************************************************
138 extern void WDT_A_clearTimer(void);
139
140 //*****************************************************************************
141 //
142 //! Sets the clock source for the Watchdog Timer in watchdog mode.
143 //!
144 //! \param clockSelect is the clock source that the watchdog timer will use.
145 //!        Valid values are
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
151 //!         timeout.
152 //!        Valid values are
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
161 //!
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.
165 //!
166 //! \return None
167 //
168 //*****************************************************************************
169 extern void WDT_A_initWatchdogTimer(uint_fast8_t clockSelect,
170         uint_fast8_t clockDivider);
171
172 //*****************************************************************************
173 //
174 //! Sets the clock source for the Watchdog Timer in timer interval mode.
175 //!
176 //! \param clockSelect is the clock source that the watchdog timer will use.
177 //!        Valid values are
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
183 //!         interval.
184 //!        Valid values are
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
193 //!
194 //! This function sets the watchdog timer as timer interval mode, which will
195 //! assert an interrupt without causing a PUC.
196 //!
197 //! \return None
198 //
199 //*****************************************************************************
200 extern void WDT_A_initIntervalTimer(uint_fast8_t clockSelect,
201         uint_fast8_t clockDivider);
202
203 //*****************************************************************************
204 //
205 //! Registers an interrupt handler for the watchdog interrupt.
206 //!
207 //! \param intHandler is a pointer to the function to be called when the
208 //! watchdog interrupt occurs.
209 //!
210 //! \return None.
211 //
212 //*****************************************************************************
213 extern void WDT_A_registerInterrupt(void (*intHandler)(void));
214
215 //*****************************************************************************
216 //
217 //! Unregisters the interrupt handler for the watchdog.
218 //!
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.
222 //!
223 //! \sa Interrupt_registerInterrupt() for important information about
224 //! registering interrupt handlers.
225 //!
226 //! \return None.
227 //
228 //*****************************************************************************
229 extern void WDT_A_unregisterInterrupt(void);
230
231 //*****************************************************************************
232 //
233 //! Sets the type of RESET that happens when a watchdog password violation
234 //! occurs.
235 //!
236 //! \param resetType The type of reset to set
237 //!
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
241 //!
242 //! \return None.
243 //
244 //
245 //*****************************************************************************
246 extern void WDT_A_setPasswordViolationReset(uint_fast8_t resetType);
247
248 //*****************************************************************************
249 //
250 //! Sets the type of RESET that happens when a watchdog timeout occurs.
251 //!
252 //! \param resetType The type of reset to set
253 //!
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
257 //!
258 //! \return None.
259 //
260 //
261 //*****************************************************************************
262 extern void WDT_A_setTimeoutReset(uint_fast8_t resetType);
263
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()
272
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
279
280 //*****************************************************************************
281 //
282 // Mark the end of the C bindings section for C++ compilers.
283 //
284 //*****************************************************************************
285 #ifdef __cplusplus
286 }
287 #endif
288
289 //*****************************************************************************
290 //
291 // Close the Doxygen group.
292 //! @}
293 //
294 //*****************************************************************************
295
296 #endif // __WATCHDOG_H__