wwdt_11xx.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_11XX_H_
33 #define __WWDT_11XX_H_
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
44 #if !defined(CHIP_LPC11CXX) || defined(CHIP_LPC1125)
45 #define WATCHDOG_WINDOW_SUPPORT
46 #endif
47 
48 #if defined(CHIP_LPC11AXX) || defined(CHIP_LPC11EXX) || defined(CHIP_LPC11UXX)
49 #define WATCHDOG_CLKSEL_SUPPORT
50 #endif
51 
55 typedef struct {
60 #ifdef WATCHDOG_CLKSEL_SUPPORT
61  __IO uint32_t CLKSEL;
62 #else
64 #endif
65 #ifdef WATCHDOG_WINDOW_SUPPORT
68 #endif
69 } LPC_WWDT_T;
70 
75 #define WWDT_WDMOD_BITMASK ((uint32_t) 0x1F)
76 
77 #define WWDT_WDMOD_WDEN ((uint32_t) (1 << 0))
78 
79 #define WWDT_WDMOD_WDRESET ((uint32_t) (1 << 1))
80 
81 #define WWDT_WDMOD_WDTOF ((uint32_t) (1 << 2))
82 
83 #define WWDT_WDMOD_WDINT ((uint32_t) (1 << 3))
84 
85 #define WWDT_WDMOD_WDPROTECT ((uint32_t) (1 << 4))
86 
92 void Chip_WWDT_Init(LPC_WWDT_T *pWWDT);
93 
99 void Chip_WWDT_DeInit(LPC_WWDT_T *pWWDT);
100 
108 {
109  pWWDT->TC = timeout;
110 }
111 
120 {
121  pWWDT->FEED = 0xAA;
122  pWWDT->FEED = 0x55;
123 }
124 
125 #if defined(WATCHDOG_WINDOW_SUPPORT)
126 
135 {
136  pWWDT->WARNINT = timeout;
137 }
138 
149 {
150  pWWDT->WINDOW = timeout;
151 }
152 
153 #endif
154 
167 {
168  pWWDT->MOD |= options;
169 }
170 
181 {
182  pWWDT->MOD &= (~options) & WWDT_WDMOD_BITMASK;
183 }
184 
191 {
193  Chip_WWDT_Feed(pWWDT);
194 }
195 
202 {
203  return pWWDT->MOD;
204 }
205 
214 void Chip_WWDT_ClearStatusFlag(LPC_WWDT_T *pWWDT, uint32_t status);
215 
222 {
223  return pWWDT->TV;
224 }
225 
226 #if defined(WATCHDOG_CLKSEL_SUPPORT)
227 
231 #define WWDT_CLKSEL_BITMASK ((uint32_t) 0x10000003)
232 
233 #define WWDT_CLKSEL_SOURCE(n) ((uint32_t) (n & 0x03))
234 
235 #define WWDT_CLKSEL_LOCK ((uint32_t) (1 << 31))
236 
240 typedef enum {
241  WWDT_CLKSRC_IRC = WWDT_CLKSEL_SOURCE(0),
242  WWDT_CLKSRC_WATCHDOG_WDOSC = WWDT_CLKSEL_SOURCE(1),
243 } CHIP_WWDT_CLK_SRC_T;
244 
251 STATIC INLINE void Chip_WWDT_SelClockSource(LPC_WWDT_T *pWWDT, CHIP_WWDT_CLK_SRC_T wdtClkSrc)
252 {
253  pWWDT->CLKSEL = wdtClkSrc & WWDT_CLKSEL_BITMASK;
254 }
255 
256 #endif
257 
262 #ifdef __cplusplus
263 }
264 #endif
265 
266 #endif /* __WWDT_11XX_H_ */
Chip_WWDT_GetCurrentCount
STATIC INLINE uint32_t Chip_WWDT_GetCurrentCount(LPC_WWDT_T *pWWDT)
Get the current value of WDT.
Definition: wwdt_11xx.h:221
uavcan::uint32_t
std::uint32_t uint32_t
Definition: std.hpp:26
LPC_WWDT_T::MOD
__IO uint32_t MOD
Definition: wwdt_11xx.h:56
Chip_WWDT_Start
STATIC INLINE void Chip_WWDT_Start(LPC_WWDT_T *pWWDT)
Enable WWDT activity.
Definition: wwdt_11xx.h:190
__IO
#define __IO
Definition: core_cm0.h:154
WWDT_WDMOD_WDEN
#define WWDT_WDMOD_WDEN
Definition: wwdt_11xx.h:77
WWDT_WDMOD_BITMASK
#define WWDT_WDMOD_BITMASK
Watchdog Mode register definitions.
Definition: wwdt_11xx.h:75
__I
#define __I
Definition: core_cm0.h:151
Chip_WWDT_SetOption
STATIC INLINE void Chip_WWDT_SetOption(LPC_WWDT_T *pWWDT, uint32_t options)
Enable watchdog timer options.
Definition: wwdt_11xx.h:166
Chip_WWDT_SetTimeOut
STATIC INLINE void Chip_WWDT_SetTimeOut(LPC_WWDT_T *pWWDT, uint32_t timeout)
Set WDT timeout constant value used for feed.
Definition: wwdt_11xx.h:107
Chip_WWDT_Feed
STATIC INLINE void Chip_WWDT_Feed(LPC_WWDT_T *pWWDT)
Feed watchdog timer.
Definition: wwdt_11xx.h:119
INLINE
#define INLINE
Definition: lpc_types.h:205
Chip_WWDT_ClearStatusFlag
void Chip_WWDT_ClearStatusFlag(LPC_WWDT_T *pWWDT, uint32_t status)
Clear WWDT interrupt status flags.
Definition: wwdt_11xx.c:77
Chip_WWDT_SetWarning
STATIC INLINE void Chip_WWDT_SetWarning(LPC_WWDT_T *pWWDT, uint32_t timeout)
Set WWDT warning interrupt.
Definition: wwdt_11xx.h:134
Chip_WWDT_Init
void Chip_WWDT_Init(LPC_WWDT_T *pWWDT)
Initialize the Watchdog timer.
Definition: wwdt_11xx.c:56
LPC_WWDT_T::WARNINT
__IO uint32_t WARNINT
Definition: wwdt_11xx.h:66
Chip_WWDT_DeInit
void Chip_WWDT_DeInit(LPC_WWDT_T *pWWDT)
Shutdown the Watchdog timer.
Definition: wwdt_11xx.c:70
LPC_WWDT_T::FEED
__O uint32_t FEED
Definition: wwdt_11xx.h:58
__O
#define __O
Definition: core_cm0.h:153
LPC_WWDT_T::WINDOW
__IO uint32_t WINDOW
Definition: wwdt_11xx.h:67
LPC_WWDT_T::TV
__I uint32_t TV
Definition: wwdt_11xx.h:59
Chip_WWDT_UnsetOption
STATIC INLINE void Chip_WWDT_UnsetOption(LPC_WWDT_T *pWWDT, uint32_t options)
Disable/clear watchdog timer options.
Definition: wwdt_11xx.h:180
LPC_WWDT_T::RESERVED0
__I uint32_t RESERVED0
Definition: wwdt_11xx.h:63
Chip_WWDT_GetStatus
STATIC INLINE uint32_t Chip_WWDT_GetStatus(LPC_WWDT_T *pWWDT)
Read WWDT status flag.
Definition: wwdt_11xx.h:201
LPC_WWDT_T::TC
__IO uint32_t TC
Definition: wwdt_11xx.h:57
Chip_WWDT_SetWindow
STATIC INLINE void Chip_WWDT_SetWindow(LPC_WWDT_T *pWWDT, uint32_t timeout)
Set WWDT window time.
Definition: wwdt_11xx.h:148
STATIC
#define STATIC
Definition: lpc_types.h:140
LPC_WWDT_T
Windowed Watchdog register block structure.
Definition: wwdt_11xx.h:55


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:03