]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC/ThirdParty/LPCOpen/lpc_core/lpc_chip/chip_18xx_43xx/wwdt_18xx_43xx.h
Update LPC18xx FreeRTOS+UDP demo to use LPCOpen USB and Ethernet drivers.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC / ThirdParty / LPCOpen / lpc_core / lpc_chip / chip_18xx_43xx / wwdt_18xx_43xx.h
1 /*\r
2  * @brief LPC18xx/43xx WWDT chip driver\r
3  *\r
4  * @note\r
5  * Copyright(C) NXP Semiconductors, 2012\r
6  * All rights reserved.\r
7  *\r
8  * @par\r
9  * Software that is described herein is for illustrative purposes only\r
10  * which provides customers with programming information regarding the\r
11  * LPC products.  This software is supplied "AS IS" without any warranties of\r
12  * any kind, and NXP Semiconductors and its licensor disclaim any and\r
13  * all warranties, express or implied, including all implied warranties of\r
14  * merchantability, fitness for a particular purpose and non-infringement of\r
15  * intellectual property rights.  NXP Semiconductors assumes no responsibility\r
16  * or liability for the use of the software, conveys no license or rights under any\r
17  * patent, copyright, mask work right, or any other intellectual property rights in\r
18  * or to any products. NXP Semiconductors reserves the right to make changes\r
19  * in the software without notification. NXP Semiconductors also makes no\r
20  * representation or warranty that such application will be suitable for the\r
21  * specified use without further testing or modification.\r
22  *\r
23  * @par\r
24  * Permission to use, copy, modify, and distribute this software and its\r
25  * documentation is hereby granted, under NXP Semiconductors' and its\r
26  * licensor's relevant copyrights in the software, without fee, provided that it\r
27  * is used in conjunction with NXP Semiconductors microcontrollers.  This\r
28  * copyright, permission, and disclaimer notice must appear in all copies of\r
29  * this code.\r
30  */\r
31 \r
32 #ifndef __WWDT_18XX_43XX_H_\r
33 #define __WWDT_18XX_43XX_H_\r
34 \r
35 #ifdef __cplusplus\r
36 extern "C" {\r
37 #endif\r
38 \r
39 /** @defgroup WWDT_18XX_43XX CHIP: LPC18xx/43xx WWDT driver\r
40  * @ingroup CHIP_18XX_43XX_Drivers\r
41  * @{\r
42  */\r
43 \r
44 /** WDT oscillator frequency value */\r
45 #define WDT_OSC     (CGU_IRC_FREQ)\r
46 \r
47 /** Minimum tick count for timer value and window value */\r
48 #define WWDT_TICKS_MIN 0xFF\r
49 \r
50 /** Maximum tick count for timer value and window value */\r
51 #define WWDT_TICKS_MAX 0xFFFFFF\r
52 \r
53 /**\r
54  * @brief       Initialize the Watchdog timer\r
55  * @param       pWWDT   : The base of WatchDog Timer peripheral on the chip\r
56  * @return      None\r
57  */\r
58 void Chip_WWDT_Init(LPC_WWDT_T *pWWDT);\r
59 \r
60 /**\r
61  * @brief       Shutdown the Watchdog timer\r
62  * @param       pWWDT   : The base of WatchDog Timer peripheral on the chip\r
63  * @return      None\r
64  */\r
65 STATIC INLINE void Chip_WWDT_DeInit(LPC_WWDT_T *pWWDT)\r
66 {\r
67         IP_WWDT_DeInit(pWWDT);\r
68 }\r
69 \r
70 /**\r
71  * @brief       Set WDT timeout constant value used for feed\r
72  * @param       pWWDT   : The base of WatchDog Timer peripheral on the chip\r
73  * @param       timeout : WDT timeout in ticks, between WWDT_TICKS_MIN and WWDT_TICKS_MAX\r
74  * @return      none\r
75  */\r
76 STATIC INLINE void Chip_WWDT_SetTimeOut(LPC_WWDT_T *pWWDT, uint32_t timeout)\r
77 {\r
78         IP_WWDT_SetTimeOut(pWWDT, timeout);\r
79 }\r
80 \r
81 /**\r
82  * @brief       Feed watchdog timer\r
83  * @param       pWWDT   : The base of WatchDog Timer peripheral on the chip\r
84  * @return      None\r
85  * @note        If this function isn't called, a watchdog timer warning will occur.\r
86  * After the warning, a timeout will occur if a feed has happened.\r
87  */\r
88 STATIC INLINE void Chip_WWDT_Feed(LPC_WWDT_T *pWWDT)\r
89 {\r
90         IP_WWDT_Feed(pWWDT);\r
91 }\r
92 \r
93 /**\r
94  * @brief       Set WWDT warning interrupt\r
95  * @param       pWWDT   : The base of WatchDog Timer peripheral on the chip\r
96  * @param       timeout : WDT warning in ticks, between 0 and 1023\r
97  * @return      None\r
98  * @note        This is the number of ticks after the watchdog interrupt that the\r
99  * warning interrupt will be generated.\r
100  */\r
101 STATIC INLINE void Chip_WWDT_SetWarning(LPC_WWDT_T *pWWDT, uint32_t timeout)\r
102 {\r
103         IP_WWDT_SetWarning(pWWDT, timeout);\r
104 }\r
105 \r
106 /**\r
107  * @brief       Set WWDT window time\r
108  * @param       pWWDT   : The base of WatchDog Timer peripheral on the chip\r
109  * @param       timeout : WDT window in ticks, between WWDT_TICKS_MIN and WWDT_TICKS_MAX\r
110  * @return      none\r
111  * @note        The watchdog timer must be fed between the timeout from the Chip_WWDT_SetTimeOut()\r
112  * function and this function, with this function defining the last tick before the\r
113  * watchdog window interrupt occurs.\r
114  */\r
115 STATIC INLINE void Chip_WWDT_SetWindow(LPC_WWDT_T *pWWDT, uint32_t timeout)\r
116 {\r
117         IP_WWDT_SetWindow(pWWDT, timeout);\r
118 }\r
119 \r
120 /**\r
121  * @brief       Enable watchdog timer options\r
122  * @param       pWWDT   : The base of WatchDog Timer peripheral on the chip\r
123  * @param       options : An or'ed set of options of values\r
124  *                                              WWDT_WDMOD_WDEN, WWDT_WDMOD_WDRESET, and WWDT_WDMOD_WDPROTECT\r
125  * @return      None\r
126  * @note        You can enable more than one option at once (ie, WWDT_WDMOD_WDRESET |\r
127  * WWDT_WDMOD_WDPROTECT), but use the WWDT_WDMOD_WDEN after all other options\r
128  * are set (or unset) with no other options.\r
129  */\r
130 STATIC INLINE void Chip_WWDT_SetOption(LPC_WWDT_T *pWWDT, uint32_t options)\r
131 {\r
132         IP_WWDT_SetOption(pWWDT, options);\r
133 }\r
134 \r
135 /**\r
136  * @brief       Disable/clear watchdog timer options\r
137  * @param       pWWDT   : The base of WatchDog Timer peripheral on the chip\r
138  * @param       options : An or'ed set of options of values\r
139  *                                              WWDT_WDMOD_WDEN, WWDT_WDMOD_WDRESET, and WWDT_WDMOD_WDPROTECT\r
140  * @return      None\r
141  * @note        You can disable more than one option at once (ie, WWDT_WDMOD_WDRESET |\r
142  * WWDT_WDMOD_WDTOF).\r
143  */\r
144 STATIC INLINE void Chip_WWDT_UnsetOption(LPC_WWDT_T *pWWDT, uint32_t options)\r
145 {\r
146         IP_WWDT_UnsetOption(pWWDT, options);\r
147 }\r
148 \r
149 /**\r
150  * @brief       Enable WWDT activity\r
151  * @param       pWWDT   : The base of WatchDog Timer peripheral on the chip\r
152  * @return      None\r
153  */\r
154 STATIC INLINE void Chip_WWDT_Start(LPC_WWDT_T *pWWDT)\r
155 {\r
156         IP_WWDT_Start(pWWDT);\r
157 }\r
158 \r
159 /**\r
160  * @brief       Read WWDT status flag\r
161  * @param       pWWDT   : The base of WatchDog Timer peripheral on the chip\r
162  * @return      Watchdog status, an Or'ed value of WWDT_WDMOD_*\r
163  */\r
164 STATIC INLINE uint32_t Chip_WWDT_GetStatus(LPC_WWDT_T *pWWDT)\r
165 {\r
166         return IP_WWDT_GetStatus(pWWDT);\r
167 }\r
168 \r
169 /**\r
170  * @brief       Clear WWDT interrupt status flags\r
171  * @param       pWWDT   : The base of WatchDog Timer peripheral on the chip\r
172  * @param       status  : Or'ed value of status flag(s) that you want to clear, should be:\r
173  *              - WWDT_WDMOD_WDTOF: Clear watchdog timeout flag\r
174  *              - WWDT_WDMOD_WDINT: Clear watchdog warning flag\r
175  * @return      None\r
176  */\r
177 STATIC INLINE void Chip_WWDT_ClearStatusFlag(LPC_WWDT_T *pWWDT, uint32_t status)\r
178 {\r
179         IP_WWDT_ClearStatusFlag(pWWDT, status);\r
180 }\r
181 \r
182 /**\r
183  * @brief       Get the current value of WDT\r
184  * @param       pWWDT   : The base of WatchDog Timer peripheral on the chip\r
185  * @return      current value of WDT\r
186  */\r
187 STATIC INLINE uint32_t Chip_WWDT_GetCurrentCount(LPC_WWDT_T *pWWDT)\r
188 {\r
189         return IP_WWDT_GetCurrentCount(pWWDT);\r
190 }\r
191 \r
192 /**\r
193  * @}\r
194  */\r
195 \r
196 #ifdef __cplusplus\r
197 }\r
198 #endif\r
199 \r
200 #endif /* __WWDT_18XX_43XX_H_ */\r