From 1da7b984f192a87a1129587e4239c295fc2c8792 Mon Sep 17 00:00:00 2001 From: wangfq Date: Fri, 31 Jul 2026 11:58:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BD=BF=E8=83=BD=E7=A1=AC=E4=BB=B6?= =?UTF-8?q?=E7=9C=8B=E9=97=A8=E7=8B=97=20WWDG,=20~558ms=20=E8=B6=85?= =?UTF-8?q?=E6=97=B6,=20=E4=B8=BB=E5=BE=AA=E7=8E=AF=E5=96=82=E7=8B=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c b/BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c index e42409f..eb18c3d 100644 --- a/BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c +++ b/BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c @@ -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(); }