STM32F4xx HAL Documentation
Hardware Abstraction Layer for STM32F4 familiy
Loading...
Searching...
No Matches
stm32f4xx_hal_wwdg.c
Go to the documentation of this file.
1
128/* Includes ------------------------------------------------------------------*/
129#include "stm32f4xx_hal.h"
130
135#ifdef HAL_WWDG_MODULE_ENABLED
141/* Private typedef -----------------------------------------------------------*/
142/* Private define ------------------------------------------------------------*/
143/* Private macro -------------------------------------------------------------*/
144/* Private variables ---------------------------------------------------------*/
145/* Private function prototypes -----------------------------------------------*/
146/* Exported functions --------------------------------------------------------*/
147
177{
178 /* Check the WWDG handle allocation */
179 if (hwwdg == NULL)
180 {
181 return HAL_ERROR;
182 }
183
184 /* Check the parameters */
185 assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance));
190
191#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
192 /* Reset Callback pointers */
193 if (hwwdg->EwiCallback == NULL)
194 {
195 hwwdg->EwiCallback = HAL_WWDG_EarlyWakeupCallback;
196 }
197
198 if (hwwdg->MspInitCallback == NULL)
199 {
200 hwwdg->MspInitCallback = HAL_WWDG_MspInit;
201 }
202
203 /* Init the low level hardware */
204 hwwdg->MspInitCallback(hwwdg);
205#else
206 /* Init the low level hardware */
207 HAL_WWDG_MspInit(hwwdg);
208#endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
209
210 /* Set WWDG Counter */
211 WRITE_REG(hwwdg->Instance->CR, (WWDG_CR_WDGA | hwwdg->Init.Counter));
212
213 /* Set WWDG Prescaler and Window */
214 WRITE_REG(hwwdg->Instance->CFR, (hwwdg->Init.EWIMode | hwwdg->Init.Prescaler | hwwdg->Init.Window));
215
216 /* Return function status */
217 return HAL_OK;
218}
219
220
231{
232 /* Prevent unused argument(s) compilation warning */
233 UNUSED(hwwdg);
234
235 /* NOTE: This function should not be modified, when the callback is needed,
236 the HAL_WWDG_MspInit could be implemented in the user file
237 */
238}
239
240
241#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
253HAL_StatusTypeDef HAL_WWDG_RegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID,
254 pWWDG_CallbackTypeDef pCallback)
255{
256 HAL_StatusTypeDef status = HAL_OK;
257
258 if (pCallback == NULL)
259 {
260 status = HAL_ERROR;
261 }
262 else
263 {
264 switch (CallbackID)
265 {
266 case HAL_WWDG_EWI_CB_ID:
267 hwwdg->EwiCallback = pCallback;
268 break;
269
270 case HAL_WWDG_MSPINIT_CB_ID:
271 hwwdg->MspInitCallback = pCallback;
272 break;
273
274 default:
275 status = HAL_ERROR;
276 break;
277 }
278 }
279
280 return status;
281}
282
283
294HAL_StatusTypeDef HAL_WWDG_UnRegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID)
295{
296 HAL_StatusTypeDef status = HAL_OK;
297
298 switch (CallbackID)
299 {
300 case HAL_WWDG_EWI_CB_ID:
301 hwwdg->EwiCallback = HAL_WWDG_EarlyWakeupCallback;
302 break;
303
304 case HAL_WWDG_MSPINIT_CB_ID:
305 hwwdg->MspInitCallback = HAL_WWDG_MspInit;
306 break;
307
308 default:
309 status = HAL_ERROR;
310 break;
311 }
312
313 return status;
314}
315#endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
316
344{
345 /* Write to WWDG CR the WWDG Counter value to refresh with */
346 WRITE_REG(hwwdg->Instance->CR, (hwwdg->Init.Counter));
347
348 /* Return function status */
349 return HAL_OK;
350}
351
367{
368 /* Check if Early Wakeup Interrupt is enable */
369 if (__HAL_WWDG_GET_IT_SOURCE(hwwdg, WWDG_IT_EWI) != RESET)
370 {
371 /* Check if WWDG Early Wakeup Interrupt occurred */
372 if (__HAL_WWDG_GET_FLAG(hwwdg, WWDG_FLAG_EWIF) != RESET)
373 {
374 /* Clear the WWDG Early Wakeup flag */
376
377#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
378 /* Early Wakeup registered callback */
379 hwwdg->EwiCallback(hwwdg);
380#else
381 /* Early Wakeup callback */
383#endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
384 }
385 }
386}
387
388
396{
397 /* Prevent unused argument(s) compilation warning */
398 UNUSED(hwwdg);
399
400 /* NOTE: This function should not be modified, when the callback is needed,
401 the HAL_WWDG_EarlyWakeupCallback could be implemented in the user file
402 */
403}
404
413#endif /* HAL_WWDG_MODULE_ENABLED */
void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg)
Initialize the WWDG MSP.
HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg)
Initialize the WWDG according to the specified. parameters in the WWDG_InitTypeDef of associated hand...
void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg)
Handle WWDG interrupt request.
void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef *hwwdg)
WWDG Early Wakeup callback.
HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg)
Refresh the WWDG.
#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
#define UNUSED(X)
WWDG handle Structure definition.
WWDG_InitTypeDef Init
WWDG_TypeDef * Instance