LPCOpen Platform for LPC112X microcontrollers  112X
LPCOpen Platform for the NXP LPC112X family of Microcontrollers
wwdt_112x.h
Go to the documentation of this file.
1 /*
2  * @brief LPC11xx WWDT chip 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_1125_H_
33 #define __WWDT_1125_H_
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
47 typedef struct {
48  __IO uint32_t MOD;
49  __IO uint32_t TC;
50  __O uint32_t FEED;
51  __I uint32_t TV;
52  __I uint32_t RESERVED0;
53  __IO uint32_t WARNINT;
54  __IO uint32_t WINDOW;
55 } LPC_WWDT_T;
56 
61 #define WWDT_WDMOD_BITMASK ((uint32_t) 0x1F)
62 
63 #define WWDT_WDMOD_WDEN ((uint32_t) (1 << 0))
64 
65 #define WWDT_WDMOD_WDRESET ((uint32_t) (1 << 1))
66 
67 #define WWDT_WDMOD_WDTOF ((uint32_t) (1 << 2))
68 
69 #define WWDT_WDMOD_WDINT ((uint32_t) (1 << 3))
70 
71 #define WWDT_WDMOD_WDPROTECT ((uint32_t) (1 << 4))
72 
78 void Chip_WWDT_Init(LPC_WWDT_T *pWWDT);
79 
85 void Chip_WWDT_DeInit(LPC_WWDT_T *pWWDT);
86 
93 STATIC INLINE void Chip_WWDT_SetTimeOut(LPC_WWDT_T *pWWDT, uint32_t timeout)
94 {
95  pWWDT->TC = timeout;
96 }
97 
106 {
107  pWWDT->FEED = 0xAA;
108  pWWDT->FEED = 0x55;
109 }
110 
119 STATIC INLINE void Chip_WWDT_SetWarning(LPC_WWDT_T *pWWDT, uint32_t timeout)
120 {
121  pWWDT->WARNINT = timeout;
122 }
123 
133 STATIC INLINE void Chip_WWDT_SetWindow(LPC_WWDT_T *pWWDT, uint32_t timeout)
134 {
135  pWWDT->WINDOW = timeout;
136 }
137 
149 STATIC INLINE void Chip_WWDT_SetOption(LPC_WWDT_T *pWWDT, uint32_t options)
150 {
151  pWWDT->MOD |= options;
152 }
153 
163 STATIC INLINE void Chip_WWDT_UnsetOption(LPC_WWDT_T *pWWDT, uint32_t options)
164 {
165  pWWDT->MOD &= (~options) & WWDT_WDMOD_BITMASK;
166 }
167 
174 {
176  Chip_WWDT_Feed(pWWDT);
177 }
178 
185 {
186  return pWWDT->MOD;
187 }
188 
197 void Chip_WWDT_ClearStatusFlag(LPC_WWDT_T *pWWDT, uint32_t status);
198 
205 {
206  return pWWDT->TV;
207 }
208 
213 #ifdef __cplusplus
214 }
215 #endif
216 
217 #endif /* __WWDT_1125_H_ */