Files

40 lines
1.0 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/******************************************************************************
* @file iwdg.c
* @brief 独立看门狗(HAL 封装)
* @author cyWu <1917507415@qq.com>
* @date 2026.08.18
* @version V1.1.0
* @history
* - V1.1.0, 2026.08.18, cyWu, 改用 HAL_IWDG,参数见 Shared/iwdg_config.h
* - V1.0.0, 2026.08.18, cyWu, 首次发布(寄存器版)
******************************************************************************/
#include "iwdg.h"
#include "main.h"
#include "iwdg_config.h"
static IWDG_HandleTypeDef s_hiwdg;
/**
* @brief 初始化/接管 IWDGBootloader 可能已启动,HAL 调用幂等)
*/
void iwdg_init(void)
{
s_hiwdg.Instance = IWDG;
s_hiwdg.Init.Prescaler = IWDG_PRESCALER_16;
s_hiwdg.Init.Reload = IWDG_RELOAD_VALUE;
if (HAL_IWDG_Init(&s_hiwdg) != HAL_OK)
{
Error_Handler(__FILE__, __LINE__);
}
}
/**
* @brief 喂狗,主循环周期调用(间隔须小于超时时间)
*/
void iwdg_feed(void)
{
(void)HAL_IWDG_Refresh(&s_hiwdg);
}