1 /**
2 ******************************************************************************
3 * @file tae32f53xx_ll_wwdg.c
4 * @author MCD Application Team
5 * @brief WWDG LL module driver.
6 * This file provides firmware functions to manage the following
7 * functionalities of the Window Watchdog (WWDG) peripheral:
8 * + Initialization and de-initialization functions
9 * + Refresh function
10 * + Interrupt and Callback functions
11 *
12 ******************************************************************************
13 * @attention
14 *
15 * <h2><center>© Copyright (c) 2020 Tai-Action.
16 * All rights reserved.</center></h2>
17 *
18 * This software is licensed by Tai-Action under BSD 3-Clause license,
19 * the "License"; You may not use this file except in compliance with the
20 * License. You may obtain a copy of the License at:
21 * opensource.org/licenses/BSD-3-Clause
22 *
23 ******************************************************************************
24 */
25
26 /* Includes ------------------------------------------------------------------*/
27 #include "tae32f53xx_ll.h"
28
29
30 #define DBG_TAG "WWDG LL"
31 #define DBG_LVL DBG_ERROR
32 #include "dbg/tae32f53xx_dbg.h"
33
34
35 /** @addtogroup TAE32F53xx_LL_Driver
36 * @{
37 */
38
39 /** @defgroup WWDG_LL WWDG LL
40 * @brief WWDG LL module driver
41 * @{
42 */
43
44 #ifdef LL_WWDG_MODULE_ENABLED
45
46 /* Private typedef -----------------------------------------------------------*/
47 /* Private define ------------------------------------------------------------*/
48 /* Private macro -------------------------------------------------------------*/
49 /* Private variables ---------------------------------------------------------*/
50 /* Private function prototypes -----------------------------------------------*/
51 /* Exported functions --------------------------------------------------------*/
52 /** @defgroup WWDG_LL_Exported_Functions WWDG LL Exported Functions
53 * @brief WWDG LL Exported Functions
54 * @{
55 */
56
57 /** @defgroup WWDG_LL_Exported_Functions_Group1 Initialization and De-Initialization functions
58 * @brief Initialization and Configuration functions.
59 *
60 @verbatim
61 ==============================================================================
62 ##### Initialization and De-Initialization functions #####
63 ==============================================================================
64 [..] This section provides a set of functions allowing to initialize and
65 deinitialize the WWDG peripheral
66
67 @endverbatim
68 * @{
69 */
70
71 /**
72 * @brief Initialize the WWDG according to the specified.
73 * parameters in the WWDG_InitTypeDef of associated handle.
74 * @param Instance WWDG peripheral
75 * @param Init pointer to a WWDG_HandleTypeDef structure that contains
76 * the configuration information for the specified WWDG module.
77 * @return LL status
78 */
LL_WWDG_Init(WWDG_TypeDef * Instance,WWDG_InitTypeDef * Init)79 LL_StatusETypeDef LL_WWDG_Init(WWDG_TypeDef *Instance, WWDG_InitTypeDef *Init)
80 {
81 /* Check the WWDG handle allocation */
82 if (Init == NULL) {
83 return LL_ERROR;
84 }
85
86 /* Check the parameters */
87 assert_param(IS_WWDG_ALL_INSTANCE(Instance));
88 assert_param(IS_WWDG_PRESCALER(Init->Prescaler));
89 assert_param(IS_WWDG_WINDOW(Init->Window));
90 assert_param(IS_WWDG_COUNTER(Init->Counter));
91
92 /* Handle Something */
93 LL_WWDG_MspInit(Instance);
94
95 /* Set WWDG Counter */
96 WRITE_REG(Instance->CVR, Init->Counter);
97
98 /* Set WWDG Prescaler */
99 WRITE_REG(Instance->PSCR, Init->Prescaler);
100
101 /* Set WWDG Window Val */
102 WRITE_REG(Instance->WVR, Init->Window);
103
104 /* SET Early Interrupt */
105 MODIFY_REG(Instance->CR, WWDG_CR_EWIE, Init->EWIMode);
106
107 /* Start WWDG Counter */
108 __LL_WWDG_ENABLE(Instance);
109
110 /* Return function status */
111 return LL_OK;
112 }
113
114 /**
115 * @brief De-initializes the WWDG peripheral.
116 * @param Instance WWDG peripheral
117 * @return status of the de-initialization
118 */
LL_WWDG_DeInit(WWDG_TypeDef * Instance)119 LL_StatusETypeDef LL_WWDG_DeInit(WWDG_TypeDef *Instance)
120 {
121 /* Check the parameters */
122 assert_param(IS_WWDG_ALL_INSTANCE(Instance));
123
124 /*Disable WWDG*/
125 __LL_WWDG_DISABLE(Instance);
126
127 /* Handle Something */
128 LL_WWDG_MspDeInit(Instance);
129
130 /* Return function status */
131 return LL_OK;
132 }
133
LL_WWDG_MspInit(WWDG_TypeDef * Instance)134 __WEAK void LL_WWDG_MspInit(WWDG_TypeDef *Instance)
135 {
136 /* Prevent unused argument(s) compilation warning */
137 LL_UNUSED(Instance);
138
139 /* NOTE: This function should not be modified, when the callback is needed,
140 the LL_WWDG_MspInit could be implemented in the user file
141 */
142 }
143
LL_WWDG_MspDeInit(WWDG_TypeDef * Instance)144 __WEAK void LL_WWDG_MspDeInit(WWDG_TypeDef *Instance)
145 {
146 /* Prevent unused argument(s) compilation warning */
147 LL_UNUSED(Instance);
148
149 /* NOTE: This function should not be modified, when the callback is needed,
150 the LL_WWDG_MspDeInit could be implemented in the user file
151 */
152 }
153
154 /**
155 * @}
156 */
157
158
159 /** @defgroup WWDG_LL_Exported_Functions_Group2 WWDG Input and Output operation functions
160 * @brief WWDG Input and Output operation functions
161 @verbatim
162 ===============================================================================
163 ##### Input and Output operation functions #####
164 ===============================================================================
165 [..]
166 This section provides functions allowing to:
167 (+) Refresh the WWDG.
168
169 @endverbatim
170 * @{
171 */
172
173 /**
174 * @brief Refresh the WWDG.
175 * @param Instance WWDG peripheral
176 * @param Counter Counter value to refresh with
177 * @return LL status
178 */
LL_WWDG_Refresh(WWDG_TypeDef * Instance,uint16_t Counter)179 LL_StatusETypeDef LL_WWDG_Refresh(WWDG_TypeDef *Instance, uint16_t Counter)
180 {
181 /* Check the parameters */
182 assert_param(IS_WWDG_ALL_INSTANCE(Instance));
183 assert_param(IS_WWDG_COUNTER(Counter));
184
185 /* Write to WWDG CR the WWDG Counter value to refresh with */
186 __LL_WWDG_SET_COUNTER(Instance, Counter);
187
188 /* Return function status */
189 return LL_OK;
190 }
191
192 /**
193 * @}
194 */
195
196
197 /** @defgroup WWDG_LL_Exported_Functions_Interrupt WWDG Interrupt management
198 * @brief WWDG Initerrupt management
199 @verbatim
200 ===============================================================================
201 ##### Initerrupt management #####
202 ===============================================================================
203 [..]
204 This section provides WWDG interrupt handler and callback functions.
205
206 @endverbatim
207 * @{
208 */
209
210 /**
211 * @brief Handle WWDG interrupt request.
212 * @param Instance: WWDG peripheral
213 * @return None
214 */
LL_WWDG_IRQHandler(WWDG_TypeDef * Instance)215 void LL_WWDG_IRQHandler(WWDG_TypeDef *Instance)
216 {
217 /* Check if Early Wakeup Interrupt is enable */
218 if ((__LL_WWDG_CHECK_IT_SOURCE(Instance, WWDG_IT_EWIE) != RESET) && (__LL_WWDG_GET_FLAG(Instance, WWDG_FLAG_EWIF) != RESET)) {
219
220 /* Clear Flag */
221 __LL_WWDG_CLEAR_FLAG(Instance, WWDG_FLAG_EWIF);
222
223 /* Early Wakeup callback */
224 LL_WWDG_EarlyWakeUpCallback(Instance);
225 }
226 }
227
228 /**
229 * @brief WWDG Early Wakeup callback.
230 * @param Instance WWDG peripheral
231 * @return None
232 */
LL_WWDG_EarlyWakeUpCallback(WWDG_TypeDef * Instance)233 __WEAK void LL_WWDG_EarlyWakeUpCallback(WWDG_TypeDef *Instance)
234 {
235 /* Prevent unused argument(s) compilation warning */
236 LL_UNUSED(Instance);
237
238 /* NOTE: This function should not be modified, when the callback is needed,
239 the LL_WWDG_EarlyWakeupCallback could be implemented in the user file
240 */
241 }
242
243 /**
244 * @}
245 */
246
247 /**
248 * @}
249 */
250
251
252 /* Private functions ---------------------------------------------------------*/
253
254
255 #endif /* LL_WWDG_MODULE_ENABLED */
256
257
258 /**
259 * @}
260 */
261
262 /**
263 * @}
264 */
265
266
267 /************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/
268
269