diff --git a/ql-application/threadx/interface/custom_app/custom_app.c b/ql-application/threadx/interface/custom_app/custom_app.c index 1291ee9..c3554da 100644 --- a/ql-application/threadx/interface/custom_app/custom_app.c +++ b/ql-application/threadx/interface/custom_app/custom_app.c @@ -30,6 +30,8 @@ #include "hal_api.h" #include "nfc.h" +#define WATCHDOG_STALL_TEST_ENABLE + #define APP_ENABLE_SLEEP @@ -39,6 +41,21 @@ static unsigned char app_operation = 0; extern int fota_start; int fisrt_net_start = 1; +#ifdef WATCHDOG_STALL_TEST_ENABLE +static volatile unsigned char g_watchdog_stall_test; + +static void watchdog_stall_test_task(void *argv) +{ + (void)argv; + ql_rtos_task_sleep_s(30); + printf("WATCHDOG TEST: stop feeding and enter dead loop\r\n"); + g_watchdog_stall_test = 1; + while (1) { + /* Deliberately block this task until the hardware watchdog resets us. */ + } +} +#endif + // 安全修复:添加互斥锁保护全局共享变量 static ql_mutex_t g_app_op_mutex = NULL; #define APP_OP_LOCK() do{ if(g_app_op_mutex) ql_rtos_mutex_lock(g_app_op_mutex, QL_WAIT_FOREVER); }while(0) @@ -245,6 +262,11 @@ jump_not_sleep: battery_check(); // printf("custom_app_task running\n"); ql_rtos_task_sleep_s(5); + #ifdef WATCHDOG_STALL_TEST_ENABLE + if (g_watchdog_stall_test) { + continue; + } + #endif ql_wtd_feed(); } } @@ -252,4 +274,8 @@ jump_not_sleep: application_init(custom_app_task, "custom_app", 10, 0); +#ifdef WATCHDOG_STALL_TEST_ENABLE +application_init(watchdog_stall_test_task, "wdt_stall_test", 2, 1); +#endif +