M480 BSP  V3.05.001
The Board Support Package for M480 Series
wdt.h
Go to the documentation of this file.
1 /**************************************************************************/
9 #ifndef __WDT_H__
10 #define __WDT_H__
11 
12 #ifdef __cplusplus
13 extern "C"
14 {
15 #endif
16 
17 
29 /*---------------------------------------------------------------------------------------------------------*/
30 /* WDT Time-out Interval Period Constant Definitions */
31 /*---------------------------------------------------------------------------------------------------------*/
32 #define WDT_TIMEOUT_2POW4 (0UL << WDT_CTL_TOUTSEL_Pos)
33 #define WDT_TIMEOUT_2POW6 (1UL << WDT_CTL_TOUTSEL_Pos)
34 #define WDT_TIMEOUT_2POW8 (2UL << WDT_CTL_TOUTSEL_Pos)
35 #define WDT_TIMEOUT_2POW10 (3UL << WDT_CTL_TOUTSEL_Pos)
36 #define WDT_TIMEOUT_2POW12 (4UL << WDT_CTL_TOUTSEL_Pos)
37 #define WDT_TIMEOUT_2POW14 (5UL << WDT_CTL_TOUTSEL_Pos)
38 #define WDT_TIMEOUT_2POW16 (6UL << WDT_CTL_TOUTSEL_Pos)
39 #define WDT_TIMEOUT_2POW18 (7UL << WDT_CTL_TOUTSEL_Pos)
41 /*---------------------------------------------------------------------------------------------------------*/
42 /* WDT Reset Delay Period Constant Definitions */
43 /*---------------------------------------------------------------------------------------------------------*/
44 #define WDT_RESET_DELAY_1026CLK (0UL << WDT_ALTCTL_RSTDSEL_Pos)
45 #define WDT_RESET_DELAY_130CLK (1UL << WDT_ALTCTL_RSTDSEL_Pos)
46 #define WDT_RESET_DELAY_18CLK (2UL << WDT_ALTCTL_RSTDSEL_Pos)
47 #define WDT_RESET_DELAY_3CLK (3UL << WDT_ALTCTL_RSTDSEL_Pos)
49 /*---------------------------------------------------------------------------------------------------------*/
50 /* WDT Free Reset Counter Keyword Constant Definitions */
51 /*---------------------------------------------------------------------------------------------------------*/
52 #define WDT_RESET_COUNTER_KEYWORD (0x00005AA5UL)
54  /* end of group WDT_EXPORTED_CONSTANTS */
55 
56 
71 #define WDT_CLEAR_RESET_FLAG() (WDT->CTL = (WDT->CTL & ~(WDT_CTL_IF_Msk | WDT_CTL_WKF_Msk)) | WDT_CTL_RSTF_Msk)
72 
83 #define WDT_CLEAR_TIMEOUT_INT_FLAG() (WDT->CTL = (WDT->CTL & ~(WDT_CTL_RSTF_Msk | WDT_CTL_WKF_Msk)) | WDT_CTL_IF_Msk)
84 
95 #define WDT_CLEAR_TIMEOUT_WAKEUP_FLAG() (WDT->CTL = (WDT->CTL & ~(WDT_CTL_RSTF_Msk | WDT_CTL_IF_Msk)) | WDT_CTL_WKF_Msk)
96 
108 #define WDT_GET_RESET_FLAG() ((WDT->CTL & WDT_CTL_RSTF_Msk)? 1UL : 0UL)
109 
121 #define WDT_GET_TIMEOUT_INT_FLAG() ((WDT->CTL & WDT_CTL_IF_Msk)? 1UL : 0UL)
122 
134 #define WDT_GET_TIMEOUT_WAKEUP_FLAG() ((WDT->CTL & WDT_CTL_WKF_Msk)? 1UL : 0UL)
135 
149 #define WDT_RESET_COUNTER() (WDT->RSTCNT = WDT_RESET_COUNTER_KEYWORD)
150 
151 /* Declare these inline functions here to avoid MISRA C 2004 rule 8.1 error */
152 __STATIC_INLINE void WDT_Close(void);
153 __STATIC_INLINE void WDT_EnableInt(void);
154 __STATIC_INLINE void WDT_DisableInt(void);
155 
165 __STATIC_INLINE void WDT_Close(void)
166 {
167  WDT->CTL = 0UL;
168  return;
169 }
170 
180 __STATIC_INLINE void WDT_EnableInt(void)
181 {
182  WDT->CTL |= WDT_CTL_INTEN_Msk;
183  return;
184 }
185 
195 __STATIC_INLINE void WDT_DisableInt(void)
196 {
197  /* Do not touch another write 1 clear bits */
199  return;
200 }
201 
202 void WDT_Open(uint32_t u32TimeoutInterval, uint32_t u32ResetDelay, uint32_t u32EnableReset, uint32_t u32EnableWakeup);
203  /* end of group WDT_EXPORTED_FUNCTIONS */
205  /* end of group WDT_Driver */
207  /* end of group Standard_Driver */
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #endif /* __WDT_H__ */
215 
216 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
#define WDT_CTL_INTEN_Msk
Definition: wdt_reg.h:271
__STATIC_INLINE void WDT_Close(void)
Stop WDT Counting.
Definition: wdt.h:165
__STATIC_INLINE void WDT_EnableInt(void)
Enable WDT Time-out Interrupt.
Definition: wdt.h:180
#define WDT_CTL_RSTF_Msk
Definition: wdt_reg.h:259
#define WDT_CTL_IF_Msk
Definition: wdt_reg.h:262
void WDT_Open(uint32_t u32TimeoutInterval, uint32_t u32ResetDelay, uint32_t u32EnableReset, uint32_t u32EnableWakeup)
Initialize WDT and start counting.
Definition: wdt.c:50
#define WDT
Definition: M480.h:398
__STATIC_INLINE void WDT_DisableInt(void)
Disable WDT Time-out Interrupt.
Definition: wdt.h:195
#define WDT_CTL_WKF_Msk
Definition: wdt_reg.h:268