1 /**************************************************************************//**
2  * @file     ewwdt.h
3  * @version  V3.00
4  * @brief    Extra Window Watchdog Timer(EWWDT) driver header file
5  *
6  * @copyright SPDX-License-Identifier: Apache-2.0
7  * @copyright Copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
8  *****************************************************************************/
9 #ifndef __EWWDT_H__
10 #define __EWWDT_H__
11 
12 #ifdef __cplusplus
13 extern "C"
14 {
15 #endif
16 
17 
18 /** @addtogroup Standard_Driver Standard Driver
19   @{
20 */
21 
22 /** @addtogroup EWWDT_Driver EWWDT Driver
23   @{
24 */
25 
26 /** @addtogroup EWWDT_EXPORTED_CONSTANTS EWWDT Exported Constants
27   @{
28 */
29 /*---------------------------------------------------------------------------------------------------------*/
30 /*  EWWDT Prescale Period Constant Definitions                                                             */
31 /*---------------------------------------------------------------------------------------------------------*/
32 #define EWWDT_PRESCALER_1        (0 << EWWDT_CTL_PSCSEL_Pos)  /*!< Select max time-out period to 1 * (64*EWWDT_CLK) \hideinitializer */
33 #define EWWDT_PRESCALER_2        (1 << EWWDT_CTL_PSCSEL_Pos)  /*!< Select max time-out period to 2 * (64*EWWDT_CLK) \hideinitializer */
34 #define EWWDT_PRESCALER_4        (2 << EWWDT_CTL_PSCSEL_Pos)  /*!< Select max time-out period to 4 * (64*EWWDT_CLK) \hideinitializer */
35 #define EWWDT_PRESCALER_8        (3 << EWWDT_CTL_PSCSEL_Pos)  /*!< Select max time-out period to 8 * (64*EWWDT_CLK) \hideinitializer */
36 #define EWWDT_PRESCALER_16       (4 << EWWDT_CTL_PSCSEL_Pos)  /*!< Select max time-out period to 16 * (64*EWWDT_CLK) \hideinitializer */
37 #define EWWDT_PRESCALER_32       (5 << EWWDT_CTL_PSCSEL_Pos)  /*!< Select max time-out period to 32 * (64*EWWDT_CLK) \hideinitializer */
38 #define EWWDT_PRESCALER_64       (6 << EWWDT_CTL_PSCSEL_Pos)  /*!< Select max time-out period to 64 * (64*EWWDT_CLK) \hideinitializer */
39 #define EWWDT_PRESCALER_128      (7 << EWWDT_CTL_PSCSEL_Pos)  /*!< Select max time-out period to 128 * (64*EWWDT_CLK) \hideinitializer */
40 #define EWWDT_PRESCALER_192      (8 << EWWDT_CTL_PSCSEL_Pos)  /*!< Select max time-out period to 192 * (64*EWWDT_CLK) \hideinitializer */
41 #define EWWDT_PRESCALER_256      (9 << EWWDT_CTL_PSCSEL_Pos)  /*!< Select max time-out period to 256 * (64*EWWDT_CLK) \hideinitializer */
42 #define EWWDT_PRESCALER_384      (10 << EWWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 384 * (64*EWWDT_CLK) \hideinitializer */
43 #define EWWDT_PRESCALER_512      (11 << EWWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 512 * (64*EWWDT_CLK) \hideinitializer */
44 #define EWWDT_PRESCALER_768      (12 << EWWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 768 * (64*EWWDT_CLK) \hideinitializer */
45 #define EWWDT_PRESCALER_1024     (13 << EWWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 1024 * (64*EWWDT_CLK) \hideinitializer */
46 #define EWWDT_PRESCALER_1536     (14 << EWWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 1536 * (64*EWWDT_CLK) \hideinitializer */
47 #define EWWDT_PRESCALER_2048     (15 << EWWDT_CTL_PSCSEL_Pos) /*!< Select max time-out period to 2048 * (64*EWWDT_CLK) \hideinitializer */
48 
49 /*---------------------------------------------------------------------------------------------------------*/
50 /*  EWWDT Reload Counter Keyword Constant Definitions                                                      */
51 /*---------------------------------------------------------------------------------------------------------*/
52 #define EWWDT_RELOAD_WORD        (0x00005AA5UL)         /*!< Fill this value to EWWDT_RLDCNT register to reload EWWDT counter \hideinitializer */
53 
54 /**@}*/ /* end of group EWWDT_EXPORTED_CONSTANTS */
55 
56 
57 /** @addtogroup EWWDT_EXPORTED_FUNCTIONS EWWDT Exported Functions
58   @{
59 */
60 
61 /**
62   * @brief      Clear EWWDT Reset System Flag
63   *
64   * @param      None
65   *
66   * @return     None
67   *
68   * @details    This macro is used to clear EWWDT time-out reset system flag.
69   * \hideinitializer
70   */
71 #define EWWDT_CLEAR_RESET_FLAG()     (EWWDT->STATUS = EWWDT_STATUS_WWDTRF_Msk)
72 
73 /**
74   * @brief      Clear EWWDT Compared Match Interrupt Flag
75   *
76   * @param      None
77   *
78   * @return     None
79   *
80   * @details    This macro is used to clear EWWDT compared match interrupt flag.
81   * \hideinitializer
82   */
83 #define EWWDT_CLEAR_INT_FLAG()       (EWWDT->STATUS = EWWDT_STATUS_WWDTIF_Msk)
84 
85 /**
86   * @brief      Get EWWDT Reset System Flag
87   *
88   * @param      None
89   *
90   * @retval     0   EWWDT time-out reset system did not occur
91   * @retval     1   EWWDT time-out reset system occurred
92   *
93   * @details    This macro is used to indicate system has been reset by EWWDT time-out reset or not.
94   * \hideinitializer
95   */
96 #define EWWDT_GET_RESET_FLAG()       ((EWWDT->STATUS & EWWDT_STATUS_WWDTRF_Msk)? 1 : 0)
97 
98 /**
99   * @brief      Get EWWDT Compared Match Interrupt Flag
100   *
101   * @param      None
102   *
103   * @retval     0   EWWDT compare match interrupt did not occur
104   * @retval     1   EWWDT compare match interrupt occurred
105   *
106   * @details    This macro is used to indicate EWWDT counter value matches CMPDAT value or not.
107   * \hideinitializer
108   */
109 #define EWWDT_GET_INT_FLAG()         ((EWWDT->STATUS & EWWDT_STATUS_WWDTIF_Msk)? 1 : 0)
110 
111 /**
112   * @brief      Get EWWDT Counter
113   *
114   * @param      None
115   *
116   * @return     EWWDT Counter Value
117   *
118   * @details    This macro reflects the current EWWDT counter value.
119   * \hideinitializer
120   */
121 #define EWWDT_GET_COUNTER()          (EWWDT->CNT)
122 
123 /**
124   * @brief      Reload EWWDT Counter
125   *
126   * @param      None
127   *
128   * @return     None
129   *
130   * @details    This macro is used to reload the EWWDT counter value to 0x3F.
131   * @note       User can only write EWWDT_RLDCNT register to reload EWWDT counter value when current EWWDT counter value \n
132   *             between 0 and CMPDAT value. If user writes EWWDT_RLDCNT when current EWWDT counter value is larger than CMPDAT, \n
133   *             EWWDT reset signal will generate immediately to reset system.
134   * \hideinitializer
135   */
136 #define EWWDT_RELOAD_COUNTER()       (EWWDT->RLDCNT = EWWDT_RELOAD_WORD)
137 
138 void EWWDT_Open(uint32_t u32PreScale, uint32_t u32CmpValue, uint32_t u32EnableInt);
139 
140 /**@}*/ /* end of group EWWDT_EXPORTED_FUNCTIONS */
141 
142 /**@}*/ /* end of group EWWDT_Driver */
143 
144 /**@}*/ /* end of group Standard_Driver */
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif /* __EWWDT_H__ */
151