| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
wwdt_001.h
Go to the documentation of this file.
1 /*
2 * @brief Windowed Watchdog Timer Registers and functions
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
6 * All rights reserved.
7 *
8 * @par
9 * Software that is described herein is for illustrative purposes only
10 * which provides customers with programming information regarding the
11 * LPC products. This software is supplied "AS IS" without any warranties of
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
13 * all warranties, express or implied, including all implied warranties of
14 * merchantability, fitness for a particular purpose and non-infringement of
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
16 * or liability for the use of the software, conveys no license or rights under any
17 * patent, copyright, mask work right, or any other intellectual property rights in
18 * or to any products. NXP Semiconductors reserves the right to make changes
19 * in the software without notification. NXP Semiconductors also makes no
20 * representation or warranty that such application will be suitable for the
21 * specified use without further testing or modification.
22 *
23 * @par
24 * Permission to use, copy, modify, and distribute this software and its
25 * documentation is hereby granted, under NXP Semiconductors' and its
26 * licensor's relevant copyrights in the software, without fee, provided that it
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
28 * copyright, permission, and disclaimer notice must appear in all copies of
29 * this code.
30 */
31
32 #ifndef __WWDT_001_H_
33 #define __WWDT_001_H_
34
35 #include "sys_config.h"
36 #include "cmsis.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
47 #if !defined(CHIP_LPC175X_6X) && !defined(CHIP_LPC11CXX) && !defined(CHIP_LPC1343)
48 #define WATCHDOG_WINDOW_SUPPORT
49 #endif
50
51 #if defined(CHIP_LPC11AXX) || defined(CHIP_LPC11EXX) || defined(CHIP_LPC11UXX) || defined(CHIP_LPC175X_6X) \
52 || defined(CHIP_LPC1347)
53 #define WATCHDOG_CLKSEL_SUPPORT
54 #endif
55
59 typedef struct {
60 __IO uint32_t MOD;
61 __IO uint32_t TC;
62 __O uint32_t FEED;
63 __I uint32_t TV;
64 #ifdef WATCHDOG_CLKSEL_SUPPORT
65 __IO uint32_t CLKSEL;
66 #else
67 __I uint32_t RESERVED0;
68 #endif
69 #ifdef WATCHDOG_WINDOW_SUPPORT
70 __IO uint32_t WARNINT;
71 __IO uint32_t WINDOW;
72 #endif
73 } IP_WWDT_001_T;
74
79 #define WWDT_WDMOD_BITMASK ((uint32_t) 0x1F)
80
81 #define WWDT_WDMOD_WDEN ((uint32_t) (1 << 0))
82
83 #define WWDT_WDMOD_WDRESET ((uint32_t) (1 << 1))
84
85 #define WWDT_WDMOD_WDTOF ((uint32_t) (1 << 2))
86
87 #define WWDT_WDMOD_WDINT ((uint32_t) (1 << 3))
88 #if !defined(CHIP_LPC175X_6X)
89
90 #define WWDT_WDMOD_WDPROTECT ((uint32_t) (1 << 4))
91 #endif
92 #if defined(WATCHDOG_CLKSEL_SUPPORT)
93
97 #define WWDT_CLKSEL_BITMASK ((uint32_t) 0x10000003)
98
99 #define WWDT_CLKSEL_SOURCE(n) ((uint32_t) (n & 0x03))
100
101 #define WWDT_CLKSEL_LOCK ((uint32_t) (1 << 31))
102 #endif /* defined(WATCHDOG_CLKSEL_SUPPORT) */
103
109 void IP_WWDT_Init(IP_WWDT_001_T *pWWDT);
110
116 STATIC INLINE void IP_WWDT_DeInit(IP_WWDT_001_T *pWWDT)
117 {}
118
125 STATIC INLINE void IP_WWDT_SetTimeOut(IP_WWDT_001_T *pWWDT, uint32_t timeout)
126 {
127 pWWDT->TC = timeout;
128 }
129
130 #if defined(WATCHDOG_CLKSEL_SUPPORT)
131
137 STATIC INLINE void IP_WWDT_SelClockSource(IP_WWDT_001_T *pWWDT, uint32_t src)
138 {
139 pWWDT->CLKSEL = src & WWDT_CLKSEL_BITMASK;
140 }
141
142 #endif /*WATCHDOG_CLKSEL_SUPPORT*/
143
151 STATIC INLINE void IP_WWDT_Feed(IP_WWDT_001_T *pWWDT)
152 {
153 pWWDT->FEED = 0xAA;
154 pWWDT->FEED = 0x55;
155 }
156
157 #if defined(WATCHDOG_WINDOW_SUPPORT)
158
166 STATIC INLINE void IP_WWDT_SetWarning(IP_WWDT_001_T *pWWDT, uint32_t timeout)
167 {
168 pWWDT->WARNINT = timeout;
169 }
170
180 STATIC INLINE void IP_WWDT_SetWindow(IP_WWDT_001_T *pWWDT, uint32_t timeout)
181 {
182 pWWDT->WINDOW = timeout;
183 }
184
185 #endif /* defined(WATCHDOG_WINDOW_SUPPORT) */
186
197 STATIC INLINE void IP_WWDT_SetOption(IP_WWDT_001_T *pWWDT, uint32_t options)
198 {
199 pWWDT->MOD |= options;
200 }
201
211 STATIC INLINE void IP_WWDT_UnsetOption(IP_WWDT_001_T *pWWDT, uint32_t options)
212 {
213 pWWDT->MOD &= (~options) & WWDT_WDMOD_BITMASK;
214 }
215
221 STATIC INLINE void IP_WWDT_Start(IP_WWDT_001_T *pWWDT)
222 {
223 IP_WWDT_SetOption(pWWDT, WWDT_WDMOD_WDEN);
224 IP_WWDT_Feed(pWWDT);
225 }
226
232 STATIC INLINE uint32_t IP_WWDT_GetStatus(IP_WWDT_001_T *pWWDT)
233 {
234 return pWWDT->MOD;
235 }
236
245 void IP_WWDT_ClearStatusFlag(IP_WWDT_001_T *pWWDT, uint32_t status);
246
251 STATIC INLINE uint32_t IP_WWDT_GetCurrentCount(IP_WWDT_001_T *pWWDT)
252 {
253 return pWWDT->TV;
254 }
255
260 #ifdef __cplusplus
261 }
262 #endif
263
264 #endif /* __WWDT_001_H_ */