2 * @brief Windowed Watchdog Timer Registers and functions
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * All rights reserved.
\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
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
32 #ifndef __WWDT_001_H_
\r
33 #define __WWDT_001_H_
\r
35 #include "sys_config.h"
\r
42 /** @defgroup IP_WWDT_001 IP: WWDT register block and driver
\r
43 * @ingroup IP_Drivers
\r
47 #if !defined(CHIP_LPC175X_6X) && !defined(CHIP_LPC11CXX) && !defined(CHIP_LPC1343)
\r
48 #define WATCHDOG_WINDOW_SUPPORT
\r
51 #if defined(CHIP_LPC11AXX) || defined(CHIP_LPC11EXX) || defined(CHIP_LPC11UXX) || defined(CHIP_LPC175X_6X) \
\r
52 || defined(CHIP_LPC1347)
\r
53 #define WATCHDOG_CLKSEL_SUPPORT
\r
57 * @brief Windowed Watchdog register block structure
\r
59 typedef struct { /*!< WWDT Structure */
\r
60 __IO uint32_t MOD; /*!< Watchdog mode register. This register contains the basic mode and status of the Watchdog Timer. */
\r
61 __IO uint32_t TC; /*!< Watchdog timer constant register. This register determines the time-out value. */
\r
62 __O uint32_t FEED; /*!< Watchdog feed sequence register. Writing 0xAA followed by 0x55 to this register reloads the Watchdog timer with the value contained in WDTC. */
\r
63 __I uint32_t TV; /*!< Watchdog timer value register. This register reads out the current value of the Watchdog timer. */
\r
64 #ifdef WATCHDOG_CLKSEL_SUPPORT
\r
65 __IO uint32_t CLKSEL; /*!< Watchdog clock select register. */
\r
67 __I uint32_t RESERVED0;
\r
69 #ifdef WATCHDOG_WINDOW_SUPPORT
\r
70 __IO uint32_t WARNINT; /*!< Watchdog warning interrupt register. This register contains the Watchdog warning interrupt compare value. */
\r
71 __IO uint32_t WINDOW; /*!< Watchdog timer window register. This register contains the Watchdog window value. */
\r
76 * @brief Watchdog Mode register definitions
\r
78 /** Watchdog Mode Bitmask */
\r
79 #define WWDT_WDMOD_BITMASK ((uint32_t) 0x1F)
\r
80 /** WWDT interrupt enable bit */
\r
81 #define WWDT_WDMOD_WDEN ((uint32_t) (1 << 0))
\r
82 /** WWDT interrupt enable bit */
\r
83 #define WWDT_WDMOD_WDRESET ((uint32_t) (1 << 1))
\r
84 /** WWDT time out flag bit */
\r
85 #define WWDT_WDMOD_WDTOF ((uint32_t) (1 << 2))
\r
86 /** WDT Time Out flag bit */
\r
87 #define WWDT_WDMOD_WDINT ((uint32_t) (1 << 3))
\r
88 #if !defined(CHIP_LPC175X_6X)
\r
89 /** WWDT Protect flag bit */
\r
90 #define WWDT_WDMOD_WDPROTECT ((uint32_t) (1 << 4))
\r
92 #if defined(WATCHDOG_CLKSEL_SUPPORT)
\r
94 * @brief Watchdog Timer Clock Source Selection register definitions
\r
96 /** Clock source select bitmask */
\r
97 #define WWDT_CLKSEL_BITMASK ((uint32_t) 0x10000003)
\r
98 /** Clock source select */
\r
99 #define WWDT_CLKSEL_SOURCE(n) ((uint32_t) (n & 0x03))
\r
100 /** Lock the clock source selection */
\r
101 #define WWDT_CLKSEL_LOCK ((uint32_t) (1 << 31))
\r
102 #endif /* defined(WATCHDOG_CLKSEL_SUPPORT) */
\r
105 * @brief Initialize the Watchdog Timer
\r
106 * @param pWWDT : pointer to WWDT register block
\r
109 void IP_WWDT_Init(IP_WWDT_001_T *pWWDT);
\r
112 * @brief De-initialize the Watchdog Timer
\r
113 * @param pWWDT : pointer to WWDT register block
\r
116 STATIC INLINE void IP_WWDT_DeInit(IP_WWDT_001_T *pWWDT)
\r
120 * @brief Set WDT timeout constant value used for feed
\r
121 * @param pWWDT : pointer to WWDT register block
\r
122 * @param timeout : WDT timeout in ticks
\r
125 STATIC INLINE void IP_WWDT_SetTimeOut(IP_WWDT_001_T *pWWDT, uint32_t timeout)
\r
127 pWWDT->TC = timeout;
\r
130 #if defined(WATCHDOG_CLKSEL_SUPPORT)
\r
132 * @brief Clock selection for Watchdog Timer
\r
133 * @param pWWDT : pointer to WWDT register block
\r
134 * @param src : Clock source selection (Or-ed value of WWDT_CLKSEL_*)
\r
137 STATIC INLINE void IP_WWDT_SelClockSource(IP_WWDT_001_T *pWWDT, uint32_t src)
\r
139 pWWDT->CLKSEL = src & WWDT_CLKSEL_BITMASK;
\r
142 #endif /*WATCHDOG_CLKSEL_SUPPORT*/
\r
145 * @brief Feed watchdog timer
\r
146 * @param pWWDT : pointer to WWDT register block
\r
148 * @note If this function isn't called, a watchdog timer warning will occur.
\r
149 * After the warning, a timeout will occur if a feed has happened.
\r
151 STATIC INLINE void IP_WWDT_Feed(IP_WWDT_001_T *pWWDT)
\r
153 pWWDT->FEED = 0xAA;
\r
154 pWWDT->FEED = 0x55;
\r
157 #if defined(WATCHDOG_WINDOW_SUPPORT)
\r
159 * @brief Set WWDT warning interrupt
\r
160 * @param pWWDT : pointer to WWDT register block
\r
161 * @param timeout : WDT warning in ticks, between 0 and 1023
\r
163 * @note This is the number of ticks after the watchdog interrupt that the
\r
164 * warning interrupt will be generated.
\r
166 STATIC INLINE void IP_WWDT_SetWarning(IP_WWDT_001_T *pWWDT, uint32_t timeout)
\r
168 pWWDT->WARNINT = timeout;
\r
172 * @brief Set WWDT window time
\r
173 * @param pWWDT : pointer to WWDT register block
\r
174 * @param timeout : WDT timeout in ticks
\r
176 * @note The watchdog timer must be fed between the timeout from the IP_WWDT_SetTimeOut()
\r
177 * function and this function, with this function defining the last tick before the
\r
178 * watchdog window interrupt occurs.
\r
180 STATIC INLINE void IP_WWDT_SetWindow(IP_WWDT_001_T *pWWDT, uint32_t timeout)
\r
182 pWWDT->WINDOW = timeout;
\r
185 #endif /* defined(WATCHDOG_WINDOW_SUPPORT) */
\r
188 * @brief Enable watchdog timer options
\r
189 * @param pWWDT : pointer to WWDT register block
\r
190 * @param options : An or'ed set of options of values
\r
191 * WWDT_WDMOD_WDEN, WWDT_WDMOD_WDRESET, and WWDT_WDMOD_WDPROTECT
\r
193 * @note You can enable more than one option at once (ie, WWDT_WDMOD_WDRESET |
\r
194 * WWDT_WDMOD_WDPROTECT), but use the WWDT_WDMOD_WDEN after all other options
\r
195 * are set (or unset) with no other options.
\r
197 STATIC INLINE void IP_WWDT_SetOption(IP_WWDT_001_T *pWWDT, uint32_t options)
\r
199 pWWDT->MOD |= options;
\r
203 * @brief Disable/clear watchdog timer options
\r
204 * @param pWWDT : pointer to WWDT register block
\r
205 * @param options : An or'ed set of options of values
\r
206 * WWDT_WDMOD_WDEN, WWDT_WDMOD_WDRESET, and WWDT_WDMOD_WDPROTECT
\r
208 * @note You can disable more than one option at once (ie, WWDT_WDMOD_WDRESET |
\r
209 * WWDT_WDMOD_WDTOF).
\r
211 STATIC INLINE void IP_WWDT_UnsetOption(IP_WWDT_001_T *pWWDT, uint32_t options)
\r
213 pWWDT->MOD &= (~options) & WWDT_WDMOD_BITMASK;
\r
217 * @brief Enable WWDT activity
\r
218 * @param pWWDT : pointer to WWDT register block
\r
221 STATIC INLINE void IP_WWDT_Start(IP_WWDT_001_T *pWWDT)
\r
223 IP_WWDT_SetOption(pWWDT, WWDT_WDMOD_WDEN);
\r
224 IP_WWDT_Feed(pWWDT);
\r
228 * @brief Read WWDT status flag
\r
229 * @param pWWDT : pointer to WWDT register block
\r
230 * @return Watchdog status, an Or'ed value of WWDT_WDMOD_*
\r
232 STATIC INLINE uint32_t IP_WWDT_GetStatus(IP_WWDT_001_T *pWWDT)
\r
238 * @brief Clear WWDT interrupt status flags
\r
239 * @param pWWDT : pointer to WWDT register block
\r
240 * @param status : Or'ed value of status flag(s) that you want to clear, should be:
\r
241 * - WWDT_WDMOD_WDTOF: Clear watchdog timeout flag
\r
242 * - WWDT_WDMOD_WDINT: Clear watchdog warning flag
\r
245 void IP_WWDT_ClearStatusFlag(IP_WWDT_001_T *pWWDT, uint32_t status);
\r
248 * @brief Get the current value of WDT
\r
249 * @return current value of WDT
\r
251 STATIC INLINE uint32_t IP_WWDT_GetCurrentCount(IP_WWDT_001_T *pWWDT)
\r
264 #endif /* __WWDT_001_H_ */
\r