STM32F4xx HAL Driver master
STM32CubeF4 HAL / LL Drivers API Reference
Loading...
Searching...
No Matches
stm32f4xx_hal_wwdg.c
Go to the documentation of this file.
1
126
127/* Includes ------------------------------------------------------------------*/
128#include "stm32f4xx_hal.h"
129
133
134#ifdef HAL_WWDG_MODULE_ENABLED
139
140/* Private typedef -----------------------------------------------------------*/
141/* Private define ------------------------------------------------------------*/
142/* Private macro -------------------------------------------------------------*/
143/* Private variables ---------------------------------------------------------*/
144/* Private function prototypes -----------------------------------------------*/
145/* Exported functions --------------------------------------------------------*/
146
150
167
176{
177 /* Check the WWDG handle allocation */
178 if (hwwdg == NULL)
179 {
180 return HAL_ERROR;
181 }
182
183 /* Check the parameters */
184 assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance));
189
190#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
191 /* Reset Callback pointers */
192 if (hwwdg->EwiCallback == NULL)
193 {
194 hwwdg->EwiCallback = HAL_WWDG_EarlyWakeupCallback;
195 }
196
197 if (hwwdg->MspInitCallback == NULL)
198 {
199 hwwdg->MspInitCallback = HAL_WWDG_MspInit;
200 }
201
202 /* Init the low level hardware */
203 hwwdg->MspInitCallback(hwwdg);
204#else
205 /* Init the low level hardware */
206 HAL_WWDG_MspInit(hwwdg);
207#endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
208
209 /* Set WWDG Counter */
210 WRITE_REG(hwwdg->Instance->CR, (WWDG_CR_WDGA | hwwdg->Init.Counter));
211
212 /* Set WWDG Prescaler and Window */
213 WRITE_REG(hwwdg->Instance->CFR, (hwwdg->Init.EWIMode | hwwdg->Init.Prescaler | hwwdg->Init.Window));
214
215 /* Return function status */
216 return HAL_OK;
217}
218
219
229__weak void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg)
230{
231 /* Prevent unused argument(s) compilation warning */
232 UNUSED(hwwdg);
233
234 /* NOTE: This function should not be modified, when the callback is needed,
235 the HAL_WWDG_MspInit could be implemented in the user file
236 */
237}
238
239
240#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
252HAL_StatusTypeDef HAL_WWDG_RegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID,
253 pWWDG_CallbackTypeDef pCallback)
254{
255 HAL_StatusTypeDef status = HAL_OK;
256
257 if (pCallback == NULL)
258 {
259 status = HAL_ERROR;
260 }
261 else
262 {
263 switch (CallbackID)
264 {
265 case HAL_WWDG_EWI_CB_ID:
266 hwwdg->EwiCallback = pCallback;
267 break;
268
269 case HAL_WWDG_MSPINIT_CB_ID:
270 hwwdg->MspInitCallback = pCallback;
271 break;
272
273 default:
274 status = HAL_ERROR;
275 break;
276 }
277 }
278
279 return status;
280}
281
282
293HAL_StatusTypeDef HAL_WWDG_UnRegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID)
294{
295 HAL_StatusTypeDef status = HAL_OK;
296
297 switch (CallbackID)
298 {
299 case HAL_WWDG_EWI_CB_ID:
300 hwwdg->EwiCallback = HAL_WWDG_EarlyWakeupCallback;
301 break;
302
303 case HAL_WWDG_MSPINIT_CB_ID:
304 hwwdg->MspInitCallback = HAL_WWDG_MspInit;
305 break;
306
307 default:
308 status = HAL_ERROR;
309 break;
310 }
311
312 return status;
313}
314#endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
315
319
335
343{
344 /* Write to WWDG CR the WWDG Counter value to refresh with */
345 WRITE_REG(hwwdg->Instance->CR, (hwwdg->Init.Counter));
346
347 /* Return function status */
348 return HAL_OK;
349}
350
366{
367 /* Check if Early Wakeup Interrupt is enable */
368 if (__HAL_WWDG_GET_IT_SOURCE(hwwdg, WWDG_IT_EWI) != RESET)
369 {
370 /* Check if WWDG Early Wakeup Interrupt occurred */
371 if (__HAL_WWDG_GET_FLAG(hwwdg, WWDG_FLAG_EWIF) != RESET)
372 {
373 /* Clear the WWDG Early Wakeup flag */
375
376#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
377 /* Early Wakeup registered callback */
378 hwwdg->EwiCallback(hwwdg);
379#else
380 /* Early Wakeup callback */
382#endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
383 }
384 }
385}
386
387
395{
396 /* Prevent unused argument(s) compilation warning */
397 UNUSED(hwwdg);
398
399 /* NOTE: This function should not be modified, when the callback is needed,
400 the HAL_WWDG_EarlyWakeupCallback could be implemented in the user file
401 */
402}
403
407
411
412#endif /* HAL_WWDG_MODULE_ENABLED */
416
420
HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg)
void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg)
void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg)
void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef *hwwdg)
HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg)
#define __HAL_WWDG_GET_FLAG(__HANDLE__, __FLAG__)
Check whether the specified WWDG flag is set or not.
#define __HAL_WWDG_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)
Check whether the specified WWDG interrupt source is enabled or not.
#define __HAL_WWDG_CLEAR_FLAG(__HANDLE__, __FLAG__)
Clear the WWDG's pending flags.
#define WWDG_FLAG_EWIF
#define WWDG_IT_EWI
#define IS_WWDG_COUNTER(__COUNTER__)
#define IS_WWDG_WINDOW(__WINDOW__)
#define IS_WWDG_PRESCALER(__PRESCALER__)
#define IS_WWDG_EWI_MODE(__MODE__)
#define assert_param(expr)
This file contains all the functions prototypes for the HAL module driver.
HAL_StatusTypeDef
HAL Status structures definition.
@ HAL_ERROR
@ HAL_OK
WWDG handle Structure definition.
WWDG_InitTypeDef Init
WWDG_TypeDef * Instance