feat: 使能硬件看门狗 WWDG, ~558ms 超时, 主循环喂狗
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "cmcng.h"
|
||||
#include "dbn_ble_srv.h"
|
||||
#include "CH59x_pwm.h"
|
||||
#include "CH59x_sys.h" /* WWDG 看门狗 */
|
||||
#include "rs485_700bs.h"
|
||||
#include "rs485_modbus.h"
|
||||
|
||||
@@ -103,6 +104,9 @@ uint8_t g_rs485_id = 0;
|
||||
#define BREATH_OPTO_DUTY_STEP 32 // 步长 4x → 渐亮/渐灭各 4 步 (~0.5s 周期)
|
||||
#define BREATH_OPTO_HOLD_TICKS 1 // 保持 50ms
|
||||
|
||||
/* 看门狗超时: Fsys=60MHz, WDOG_CLK=Fsys/131072≈458Hz, 0xFF≈558ms */
|
||||
#define WDOG_TIMEOUT 0xFF
|
||||
|
||||
static uint8_t g_breath_phase = BREATH_FADE_IN;
|
||||
static uint8_t g_breath_duty = 0;
|
||||
static uint8_t g_breath_tick = 0;
|
||||
@@ -1056,6 +1060,8 @@ void Main_Circulation()
|
||||
g_dbn_ble_state_acs_enable.enable = 0;
|
||||
}
|
||||
}
|
||||
|
||||
WWDG_SetCounter(WDOG_TIMEOUT); // 喂狗
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1099,6 +1105,11 @@ int main(void)
|
||||
HAL_Init();
|
||||
GAPRole_PeripheralInit();
|
||||
Peripheral_Init();
|
||||
|
||||
/* 使能看门狗复位: 超时 ~558ms, 主循环喂狗 */
|
||||
WWDG_ResetCfg(ENABLE);
|
||||
WWDG_SetCounter(WDOG_TIMEOUT);
|
||||
|
||||
Main_Circulation();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user