LPCOpen Platform for LPC18XX/43XX microcontrollers  18XX43XX
LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers
wwdt_18xx_43xx.h
Go to the documentation of this file.
1 /*
2  * @brief LPC18xx/43xx WWDT driver
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_18XX_43XX_H_
33 #define __WWDT_18XX_43XX_H_
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
44 #define WATCHDOG_WINDOW_SUPPORT
45 
47 #define WDT_OSC (CGU_IRC_FREQ)
48 
52 typedef struct {
53  __IO uint32_t MOD;
54  __IO uint32_t TC;
55  __O uint32_t FEED;
56  __I uint32_t TV;
57  __I uint32_t RESERVED0;
58 #ifdef WATCHDOG_WINDOW_SUPPORT
59  __IO uint32_t WARNINT;
60  __IO uint32_t WINDOW;
61 #endif
62 } LPC_WWDT_T;
63 
68 #define WWDT_WDMOD_BITMASK ((uint32_t) 0x1F)
69 
70 #define WWDT_WDMOD_WDEN ((uint32_t) (1 << 0))
71 
72 #define WWDT_WDMOD_WDRESET ((uint32_t) (1 << 1))
73 
74 #define WWDT_WDMOD_WDTOF ((uint32_t) (1 << 2))
75 
76 #define WWDT_WDMOD_WDINT ((uint32_t) (1 << 3))
77 
78 #define WWDT_WDMOD_WDPROTECT ((uint32_t) (1 << 4))
79 
85 void Chip_WWDT_Init(LPC_WWDT_T *pWWDT);
86 
92 void Chip_WWDT_DeInit(LPC_WWDT_T *pWWDT);
93 
100 STATIC INLINE void Chip_WWDT_SetTimeOut(LPC_WWDT_T *pWWDT, uint32_t timeout)
101 {
102  pWWDT->TC = timeout;
103 }
104 
113 {
114  pWWDT->FEED = 0xAA;
115  pWWDT->FEED = 0x55;
116 }
117 
118 #if defined(WATCHDOG_WINDOW_SUPPORT)
119 
127 STATIC INLINE void Chip_WWDT_SetWarning(LPC_WWDT_T *pWWDT, uint32_t timeout)
128 {
129  pWWDT->WARNINT = timeout;
130 }
131 
141 STATIC INLINE void Chip_WWDT_SetWindow(LPC_WWDT_T *pWWDT, uint32_t timeout)
142 {
143  pWWDT->WINDOW = timeout;
144 }
145 
146 #endif
147 
159 STATIC INLINE void Chip_WWDT_SetOption(LPC_WWDT_T *pWWDT, uint32_t options)
160 {
161  pWWDT->MOD |= options;
162 }
163 
173 STATIC INLINE void Chip_WWDT_UnsetOption(LPC_WWDT_T *pWWDT, uint32_t options)
174 {
175  pWWDT->MOD &= (~options) & WWDT_WDMOD_BITMASK;
176 }
177 
184 {
186  Chip_WWDT_Feed(pWWDT);
187 }
188 
195 {
196  return pWWDT->MOD;
197 }
198 
207 void Chip_WWDT_ClearStatusFlag(LPC_WWDT_T *pWWDT, uint32_t status);
208 
215 {
216  return pWWDT->TV;
217 }
218 
223 #ifdef __cplusplus
224 }
225 #endif
226 
227 #endif /* __WWDT_18XX_43XX_H_ */