1 /**
2   ******************************************************************************
3   * @file    tae32f53xx_ll_wwdg.h
4   * @author  MCD Application Team
5   * @brief   Header file of WWDG LL module.
6   *
7   ******************************************************************************
8   * @attention
9   *
10   * <h2><center>&copy; Copyright (c) 2020 Tai-Action.
11   * All rights reserved.</center></h2>
12   *
13   * This software is licensed by Tai-Action under BSD 3-Clause license,
14   * the "License"; You may not use this file except in compliance with the
15   * License. You may obtain a copy of the License at:
16   *                        opensource.org/licenses/BSD-3-Clause
17   *
18   ******************************************************************************
19   */
20 
21 /* Define to prevent recursive inclusion -------------------------------------*/
22 #ifndef _TAE32F53XX_LL_WWDG_H_
23 #define _TAE32F53XX_LL_WWDG_H_
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28 
29 /* Includes ------------------------------------------------------------------*/
30 #include "tae32f53xx_ll_def.h"
31 
32 
33 /** @addtogroup TAE32F53xx_LL_Driver
34   * @{
35   */
36 
37 /** @addtogroup WWDG_LL
38   * @{
39   */
40 
41 
42 /* Exported types ------------------------------------------------------------*/
43 /** @defgroup WWDG_LL_Exported_Types WWDG LL Exported Types
44   * @brief    WWDG LL Exported Types
45   * @{
46   */
47 
48 /**
49     @brief WWDG Early Wakeup Interrupt Mode
50   */
51 typedef enum {
52     WWDG_EWI_DISABLE    = 0x00000000U,         /*!< Rsest                          */
53     WWDG_EWI_ENABLE     = WWDG_CR_EWIE,        /*!< Early Wakeup Interrupt         */
54 } WWDG_EWIETypeDef;
55 
56 /**
57   * @brief WWDG Init structure definition
58   */
59 typedef struct __WWDG_InitTypeDef {
60     uint32_t Prescaler;         /*!< Specifies the prescaler value of the WWDG.
61                                      This parameter must be a number Min_Data = 0x00 and Max_Data = 0xFFFF          */
62 
63     uint32_t Window;            /*!< Specifies the WWDG window value to be compared to the downcounter.
64                                      This parameter must be a number Min_Data = 0x40 and Max_Data = 0xFFFF          */
65 
66     uint32_t Counter;           /*!< Specifies the WWDG free-running downcounter value.
67                                      This parameter must be a number between Min_Data = 0x40 and Max_Data = 0xFFFF  */
68 
69     WWDG_EWIETypeDef EWIMode;   /*!< Specifies if WWDG Early Wakeup Interupt is enable or not.                      */
70 } WWDG_InitTypeDef;
71 
72 /**
73   * @}
74   */
75 
76 
77 /* Exported constants --------------------------------------------------------*/
78 /** @defgroup WWDG_LL_Exported_Constants WWDG LL Exported Constants
79   * @brief    WWDG LL Exported Constants
80   * @{
81   */
82 
83 /** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition
84   * @{
85   */
86 #define WWDG_IT_EWIE                        WWDG_CR_EWIE        /*!< Early wakeup interrupt         */
87 /**
88   * @}
89   */
90 
91 /** @defgroup WWDG_Flag_definition WWDG Flag definition
92   * @brief WWDG Flag definition
93   * @{
94   */
95 #define WWDG_FLAG_EWIF                      WWDG_ISR_EWIF       /*!< Early wakeup interrupt flag    */
96 /**
97   * @}
98   */
99 
100 /**
101   * @}
102   */
103 
104 
105 /* Exported macro ------------------------------------------------------------*/
106 /** @defgroup WWDG_LL_Exported_Macros WWDG LL Exported Macros
107   * @brief    WWDG LL Exported Macros
108   * @{
109   */
110 
111 /**
112   * @brief  Enable the WWDG peripheral.
113   * @param  __INSTANCE__ WWDG peripheral
114   * @retval None
115   */
116 #define __LL_WWDG_ENABLE(__INSTANCE__)                              SET_BIT((__INSTANCE__)->CR, WWDG_CR_WEN)
117 
118 /**
119   * @brief  Disable the WWDG peripheral.
120   * @param  __INSTANCE__ WWDG peripheral
121   * @retval None
122   */
123 #define __LL_WWDG_DISABLE(__INSTANCE__)                             CLEAR_BIT((__INSTANCE__)->CR, WWDG_CR_WEN)
124 
125 /**
126   * @brief  Enable the specified WWDG interrupt.
127   * @param  __INSTANCE__ WWDG peripheral
128   * @param  __INTERRUPT__ specifies the interrupt to enable.
129   *         This parameter can be one of the following values:
130   *             @arg WWDG_IT_EWIE: Early wakeup interrupt
131   * @retval None
132   */
133 #define __LL_WWDG_IT_ENABLE(__INSTANCE__, __INTERRUPT__)            SET_BIT((__INSTANCE__)->CR, (__INTERRUPT__))
134 
135 /**
136   * @brief  Disable the specified WWDG interrupt.
137   * @param  __INSTANCE__ WWDG peripheral
138   * @param  __INTERRUPT__ specifies the interrupt to enable.
139   *         This parameter can be one of the following values:
140   *             @arg WWDG_IT_EWIE: Early wakeup interrupt
141   * @retval None
142   */
143 #define __LL_WWDG_IT_DISABLE(__INSTANCE__, __INTERRUPT__)           CLEAR_BIT((__INSTANCE__)->CR, (__INTERRUPT__))
144 
145 /**
146   * @brief  Check whether the specified WWDG flag is set or not.
147   * @param  __INSTANCE__ WWDG peripheral
148   * @param  __FLAG__  specifies the flag to check.
149   *         This parameter can be one of the following values:
150   *             @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
151   * @retval The new state of WWDG_FLAG (SET or RESET).
152   */
153 
154 #define __LL_WWDG_GET_FLAG(__INSTANCE__, __FLAG__)  ((READ_BIT((__INSTANCE__)->ISR, (__FLAG__)) == (__FLAG__)) ? SET : RESET)
155 /**
156   * @brief  Clears the WWDG's pending flags.
157   * @param  __INSTANCE__ WWDG peripheral
158   * @param  __FLAG__ specifies the flag to clear.
159   *         This parameter can be one of the following values:
160   *             @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
161   * @retval None
162   */
163 
164 #define __LL_WWDG_CLEAR_FLAG(__INSTANCE__, __FLAG__)                WRITE_REG((__INSTANCE__)->ISR, (__FLAG__))
165 
166 /**
167   * @brief  Checks if the specified WWDG interrupt source is enabled or disabled.
168   * @param  __INSTANCE__ WWDG peripheral
169   * @param  __INTERRUPT__ specifies the WWDG interrupt source to check.
170   *         This parameter can be one of the following values:
171   *             @arg WWDG_IT_EWIE: Early Wakeup Interrupt
172   * @retval state of __INTERRUPT__ (SET or RESET).
173   */
174 #define __LL_WWDG_CHECK_IT_SOURCE(__INSTANCE__, __INTERRUPT__)      \
175         ((READ_BIT((__INSTANCE__)->CR, (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
176 
177 /**
178   * @brief  Get the WWDG Counter Register value on runtime.
179   * @param  __INSTANCE__ WWDG peripheral
180   * @retval 16-bit value of the WWDG counter register (WWDG_CVR)
181   */
182 #define __LL_WWDG_GET_COUNTER(__INSTANCE__)                         (READ_REG((__INSTANCE__)->CVR))
183 
184 /**
185   * @brief  Set the WWDG Counter Register value to refresh WWDG.
186   * @param  __INSTANCE__ WWDG peripheral
187   * @param  __COUNTER__ specifies WWDG counter value to refresh with
188   * @retval None
189   */
190 #define __LL_WWDG_SET_COUNTER(__INSTANCE__, __COUNTER__)            WRITE_REG((__INSTANCE__)->CVR, __COUNTER__)
191 
192 /**
193   * @}
194   */
195 
196 
197 /* Exported functions --------------------------------------------------------*/
198 /** @addtogroup WWDG_LL_Exported_Functions
199   * @{
200   */
201 
202 /** @addtogroup WWDG_LL_Exported_Functions_Group1
203   * @{
204   */
205 LL_StatusETypeDef LL_WWDG_Init(WWDG_TypeDef *Instance, WWDG_InitTypeDef *Init);
206 LL_StatusETypeDef LL_WWDG_DeInit(WWDG_TypeDef *Instance);
207 void LL_WWDG_MspInit(WWDG_TypeDef *Instance);
208 void LL_WWDG_MspDeInit(WWDG_TypeDef *Instance);
209 /**
210   * @}
211   */
212 
213 
214 /** @addtogroup WWDG_LL_Exported_Functions_Group2
215   * @{
216   */
217 LL_StatusETypeDef LL_WWDG_Refresh(WWDG_TypeDef *Instance, uint16_t Counter);
218 /**
219   * @}
220   */
221 
222 
223 /** @addtogroup WWDG_LL_Exported_Functions_Interrupt
224   * @{
225   */
226 void LL_WWDG_IRQHandler(WWDG_TypeDef *Instance);
227 void LL_WWDG_EarlyWakeUpCallback(WWDG_TypeDef *Instance);
228 /**
229   * @}
230   */
231 
232 /**
233   * @}
234   */
235 
236 
237 /* Private types -------------------------------------------------------------*/
238 /* Private variables ---------------------------------------------------------*/
239 /* Private constants ---------------------------------------------------------*/
240 /* Private macros ------------------------------------------------------------*/
241 /** @defgroup WWDG_LL_Private_Macros WWDG LL Private Macros
242   * @brief    WWDG LL Private Macros
243   * @{
244   */
245 
246 /**
247   * @brief  Judge is WWDG prescaler or not
248   * @param  __PRESCALER__ prescaler to judge
249   * @retval 0 isn't WWDG prescaler
250   * @retval 1 is WWDG prescaler
251   */
252 #define IS_WWDG_PRESCALER(__PRESCALER__)            ((__PRESCALER__) <= 0xFFFFUL)
253 
254 /**
255   * @brief  Judge is WWDG window or not
256   * @param  __WINDOW__ window to judge
257   * @retval 0 isn't WWDG window
258   * @retval 1 is WWDG window
259   */
260 #define IS_WWDG_WINDOW(__WINDOW__)                  ((__WINDOW__) <= 0xFFFFUL)
261 
262 /**
263   * @brief  Judge is WWDG counter or not
264   * @param  __COUNTER__ counter to judge
265   * @retval 0 isn't WWDG counter
266   * @retval 1 is WWDG counter
267   */
268 #define IS_WWDG_COUNTER(__COUNTER__)                ((__COUNTER__) <= 0xFFFFUL)
269 
270 /**
271   * @}
272   */
273 
274 
275 /* Private functions ---------------------------------------------------------*/
276 
277 
278 /**
279   * @}
280   */
281 
282 /**
283   * @}
284   */
285 
286 
287 #ifdef __cplusplus
288 }
289 #endif /* __cplusplus */
290 
291 
292 #endif /* _TAE32F53XX_LL_WWDG_H_ */
293 
294 
295 /************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/
296 
297