1 /**********************************************************************
\r
2 * $Id$ lpc18xx_wwdt.h 2011-06-02
\r
4 * @file lpc18xx_wwdt.h
\r
5 * @brief Contains all macro definitions and function prototypes
\r
6 * support for WWDT firmware library on LPC18xx
\r
8 * @date 02. June. 2011
\r
9 * @author NXP MCU SW Application Team
\r
11 * Copyright(C) 2011, NXP Semiconductor
\r
12 * All rights reserved.
\r
14 ***********************************************************************
\r
15 * Software that is described herein is for illustrative purposes only
\r
16 * which provides customers with programming information regarding the
\r
17 * products. This software is supplied "AS IS" without any warranties.
\r
18 * NXP Semiconductors assumes no responsibility or liability for the
\r
19 * use of the software, conveys no license or title under any patent,
\r
20 * copyright, or mask work right to the product. NXP Semiconductors
\r
21 * reserves the right to make changes in the software without
\r
22 * notification. NXP Semiconductors also make no representation or
\r
23 * warranty that such application will be suitable for the specified
\r
24 * use without further testing or modification.
\r
25 **********************************************************************/
\r
27 /* Peripheral group ----------------------------------------------------------- */
\r
28 /** @defgroup WWDT WWDT (Windowed WatchDog Timer)
\r
29 * @ingroup LPC1800CMSIS_FwLib_Drivers
\r
34 #ifndef LPC18XX_WWDT_H_
\r
35 #define LPC18XX_WWDT_H_
\r
37 /* Includes ------------------------------------------------------------------- */
\r
38 #include "LPC18xx.h"
\r
39 #include "lpc_types.h"
\r
47 /* Public Macros -------------------------------------------------------------- */
\r
48 /** @defgroup WWDT_Public_Macros WWDT Public Macros
\r
51 /** WDT oscillator frequency value */
\r
52 #define WDT_OSC (12000000UL) /* WWDT uses IRC clock */
\r
59 /* Private Macros ------------------------------------------------------------- */
\r
60 /** @defgroup WWDT_Private_Macros WWDT Private Macros
\r
63 // time is calculated by usec
\r
64 #define WDT_GET_FROM_USEC(time) ((time*10)/((WWDT_US_INDEX *10 * 4)/WDT_OSC))
\r
65 #define WDT_GET_USEC(counter) ((counter * ((WWDT_US_INDEX *10 * 4)/WDT_OSC))/10)
\r
68 /* --------------------- BIT DEFINITIONS -------------------------------------- */
\r
69 /** WWDT interrupt enable bit */
\r
70 #define WWDT_WDMOD_WDEN ((uint32_t)(1<<0))
\r
71 /** WWDT interrupt enable bit */
\r
72 #define WWDT_WDMOD_WDRESET ((uint32_t)(1<<1))
\r
73 /** WWDT time out flag bit */
\r
74 #define WWDT_WDMOD_WDTOF ((uint32_t)(1<<2))
\r
75 /** WDT Time Out flag bit */
\r
76 #define WWDT_WDMOD_WDINT ((uint32_t)(1<<3))
\r
77 /** WWDT Protect flag bit */
\r
78 #define WWDT_WDMOD_WDPROTECT ((uint32_t)(1<<4))
\r
80 /** Define divider index for microsecond ( us ) */
\r
81 #define WWDT_US_INDEX ((uint32_t)(1000000))
\r
83 /** WWDT Time out minimum value */
\r
84 #define WWDT_TIMEOUT_MIN ((uint32_t)(0xFF))
\r
85 /** WWDT Time out maximum value */
\r
86 #define WWDT_TIMEOUT_MAX ((uint32_t)(0x00FFFFFF))
\r
88 /** WWDT Warning minimum value */
\r
89 #define WWDT_WARNINT_MIN ((uint32_t)(0xFF))
\r
90 /** WWDT Warning maximum value */
\r
91 #define WWDT_WARNINT_MAX ((uint32_t)(0x000003FF))
\r
93 /** WWDT Windowed minimum value */
\r
94 #define WWDT_WINDOW_MIN ((uint32_t)(0xFF))
\r
95 /** WWDT Windowed minimum value */
\r
96 #define WWDT_WINDOW_MAX ((uint32_t)(0x00FFFFFF))
\r
98 /** WWDT timer constant register mask */
\r
99 #define WWDT_WDTC_MASK ((uint32_t)(0x00FFFFFF))
\r
100 /** WWDT warning value register mask */
\r
101 #define WWDT_WDWARNINT_MASK ((uint32_t)(0x000003FF))
\r
102 /** WWDT feed sequence register mask */
\r
103 #define WWDT_WDFEED_MASK ((uint32_t)(0x000000FF))
\r
106 #define WWDT_WARNINT_FLAG ((uint8_t)(0))
\r
107 #define WWDT_TIMEOUT_FLAG ((uint8_t)(1))
\r
109 /** WWDT mode definitions */
\r
110 #define WWDT_PROTECT_MODE ((uint8_t)(0))
\r
111 #define WWDT_RESET_MODE ((uint8_t)(1))
\r
114 /* WWDT Timer value definition (us) */
\r
115 #define WWDT_TIMEOUT_USEC_MIN ((uint32_t)(WDT_GET_USEC(WWDT_TIMEOUT_MIN)))//microseconds
\r
116 #define WWDT_TIMEOUT_USEC_MAX ((uint32_t)(WDT_GET_USEC(WWDT_TIMEOUT_MAX)))
\r
118 #define WWDT_TIMEWARN_USEC_MIN ((uint32_t)(WDT_GET_USEC(WWDT_WARNINT_MIN)))
\r
119 #define WWDT_TIMEWARN_USEC_MAX ((uint32_t)(WDT_GET_USEC(WWDT_WARNINT_MAX)))
\r
121 #define WWDT_TIMEWINDOWED_USEC_MIN ((uint32_t)(WDT_GET_USEC(WWDT_WINDOW_MIN)))
\r
122 #define WWDT_TIMEWINDOWED_USEC_MAX ((uint32_t)(WDT_GET_USEC(WWDT_WINDOW_MAX)))
\r
129 /* Public Types --------------------------------------------------------------- */
\r
130 /** @defgroup WWDT_Public_Types WWDT Public Types
\r
133 /********************************************************************//**
\r
134 * @brief WWDT structure definitions
\r
135 **********************************************************************/
\r
136 typedef struct Wdt_Config
\r
138 uint8_t wdtReset; /**< if ENABLE -> the Reset bit is enabled */
\r
139 uint8_t wdtProtect; /**< if ENABLE -> the Protect bit is enabled */
\r
140 uint32_t wdtTmrConst; /**< Set the constant value to timeout the WDT (us) */
\r
141 uint32_t wdtWarningVal; /**< Set the value to warn the WDT with interrupt (us) */
\r
142 uint32_t wdtWindowVal; /**< Set a window vaule for WDT (us) */
\r
149 /* Public Functions ----------------------------------------------------------- */
\r
150 /** @defgroup WWDT_Public_Functions WWDT Public Functions
\r
154 void WWDT_Init(void);
\r
155 void WWDT_UpdateTimeOut(uint32_t TimeOut);
\r
156 void WWDT_Feed (void);
\r
157 void WWDT_SetWarning(uint32_t WarnTime);
\r
158 void WWDT_SetWindow(uint32_t WindowedTime);
\r
159 void WWDT_Configure(st_Wdt_Config wdtCfg);
\r
160 void WWDT_Start(void);
\r
161 FlagStatus WWDT_GetStatus (uint8_t Status);
\r
162 void WWDT_ClearStatusFlag (uint8_t flag);
\r
163 uint32_t WWDT_GetCurrentCount(void);
\r
172 #endif /* LPC18XX_WWDT_H_ */
\r
177 /* --------------------------------- End Of File ------------------------------ */
\r