2026-05-30 00:24:31 +08:00
|
|
|
/**
|
|
|
|
|
* @file watchdog.cpp
|
|
|
|
|
* @brief APP 独立看门狗(FWDGT)实现。
|
|
|
|
|
*
|
|
|
|
|
* 时钟源: IRC40K (~40 KHz)
|
|
|
|
|
* 预分频: CONFIG_FWDGT_PSC, 重载值: CONFIG_FWDGT_RLD
|
|
|
|
|
* 超时 = (PSC / 40000) * (RLD + 1) 秒
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "device/watchdog.h"
|
|
|
|
|
#include "sys/config.h"
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
|
|
void Watchdog::init()
|
|
|
|
|
{
|
|
|
|
|
fwdgt_write_enable();
|
2026-05-30 20:03:31 +08:00
|
|
|
fwdgt_prescaler_value_config(CONFIG_FWDGT_PSC);
|
|
|
|
|
fwdgt_reload_value_config(CONFIG_FWDGT_RLD);
|
2026-05-30 00:24:31 +08:00
|
|
|
fwdgt_write_disable();
|
|
|
|
|
fwdgt_enable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Watchdog::feed()
|
|
|
|
|
{
|
|
|
|
|
fwdgt_counter_reload();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Watchdog::abandon()
|
|
|
|
|
{
|
|
|
|
|
/* 不喂狗即可,FWDGT 超时后硬件自动复位。 */
|
|
|
|
|
}
|