添加普冉 PY32F040 OTA 双工程代码生成模板

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-18 18:59:56 +08:00
co-authored by Cursor
commit 331864dc64
496 changed files with 329040 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
/******************************************************************************
* @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);
}