From 9a7892e1055a89909685ad98fb4a9c8ef536f9e8 Mon Sep 17 00:00:00 2001 From: wrh Date: Wed, 9 Sep 2026 10:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E7=9F=AD=E8=B7=AF=E6=A8=A1=E5=BC=8F=E4=B8=AD=E6=8C=81=E7=BB=AD?= =?UTF-8?q?=E4=B8=8B=E5=8F=91=E5=BC=80=E6=9C=BA=E7=9A=84=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E7=9F=AD=E8=B7=AF=E5=B0=B1=E6=8C=89=E6=8C=81?= =?UTF-8?q?=E7=BB=AD=E4=BF=9D=E6=8C=81=E8=BF=9B=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 在chrg_sink.h中新增chrg_sink_short_keepalive_process函数声明 2. 在chrg_sink.c中实现短路测试保活相关宏定义、全局变量和处理函数 3. 在短路测试工作流程中添加保活指令下发逻辑 4. 在south卷线程中周期性调用短路测试保活处理函数 5. 在非短路测试模式下重置保活计时变量 --- apps/chrg/applications/thread/chrg_roll_sou.c | 2 ++ apps/chrg/applications/utils/chrg_sink.c | 21 +++++++++++++++++++ apps/chrg/applications/utils/chrg_sink.h | 1 + 3 files changed, 24 insertions(+) diff --git a/apps/chrg/applications/thread/chrg_roll_sou.c b/apps/chrg/applications/thread/chrg_roll_sou.c index 4c91f93..3612cd7 100644 --- a/apps/chrg/applications/thread/chrg_roll_sou.c +++ b/apps/chrg/applications/thread/chrg_roll_sou.c @@ -16,6 +16,7 @@ #include "chrg_thread.h" #include "chrg_roll_sou.h" #include "chrg_north.h" +#include "chrg_sink.h" #include "chrg_eload.h" #include "chrg_utils.h" @@ -782,6 +783,7 @@ void chrg_roll_sou_thread_entry (void *data) struct chrg_thread_t *pTS = &chrgthr[IDX_THR_SOUTH]; struct mb_msg_t *pMB_R = RT_NULL; while (1) { + chrg_sink_short_keepalive_process(); rt_mutex_take(pTHR->mutex, RT_WAITING_FOREVER); run = pROLL->run; single_ch = pROLL->ch; diff --git a/apps/chrg/applications/utils/chrg_sink.c b/apps/chrg/applications/utils/chrg_sink.c index f8ddb60..9ee9355 100644 --- a/apps/chrg/applications/utils/chrg_sink.c +++ b/apps/chrg/applications/utils/chrg_sink.c @@ -23,6 +23,7 @@ #define SINK_UNLOAD_QUERY_INTERVAL_MS 20U // 卸载期间两次优先量测请求的最小间隔 #define SINK_UNLOAD_CURRENT_MAX_MA 200U // 判定负载已安全卸载的最大实际电流 #define SINK_UNLOAD_CONFIRM_COUNT 2U // 连续满足低电流条件的量测帧数 +#define SINK_SHORT_KEEPALIVE_MS 30U // 短路测试WORK_START保活下发周期 /* 主继电器闭合跟踪:1=已提交ALL_REL_ON(主继电器应已闭合) 0=未闭合/已断开。 * 用于0V硬保护区分"首次开载/握手恢复"(主继电器未闭合,Now_voltage=0属正常) @@ -958,6 +959,23 @@ int chrg_sink_volt_judge(eIDX_SOU_CH idx, struct chrg_switch_t *pSW) return chrg_sink_work(idx, pSW); } +void chrg_sink_short_keepalive_process(void) +{ + eIDX_SOU_CH idx; + struct chrg_switch_t *pSW; + + for (idx = IDX_SOU_CH1; idx < TOTAL_SOU_CHS; idx++) { + pSW = &chrgnorth.sw[idx]; + if ((pSW->id != ID_SINK) || + (pSW->sink.work_mode != SINK_WORK_ON_TEST_SHORT) || + (pSW->sink.test.test_mode != SINK_TEST_SHORT)) { + g_sink_short_start_tick[idx] = 0U; + continue; + } + (void)chrg_sink_TEST_SHORT_KEEPALIVE(idx); + } +} + /***************************************************************** 函数名称: chrg_sink_TEST_OCP_ON 函数描述: 配置并启动负载OCP过流保护测试 @@ -1021,6 +1039,9 @@ int chrg_sink_work(eIDX_SOU_CH idx, struct chrg_switch_t *pSW) (work_mode != SINK_WORK_UNLOAD_WAIT) && (work_mode != SINK_WORK_LOW_AUX_WAIT) && (work_mode != SINK_WORK_HANDSHAKE_WAIT)) { + if (work_mode == SINK_WORK_ON_TEST_SHORT) { + return chrg_sink_TEST_SHORT_KEEPALIVE(idx); + } return 0; } switch(work_mode){ diff --git a/apps/chrg/applications/utils/chrg_sink.h b/apps/chrg/applications/utils/chrg_sink.h index 504ce31..92a185a 100644 --- a/apps/chrg/applications/utils/chrg_sink.h +++ b/apps/chrg/applications/utils/chrg_sink.h @@ -418,6 +418,7 @@ extern void chrg_nor_sink_test_run(rt_uint8_t ch, struct chrg_switch_t *pSW); extern rt_bool_t chrg_sink_load_should_start(const struct chrg_switch_t *pSW); extern int chrg_sink_work(eIDX_SOU_CH idx, struct chrg_switch_t *pSW); extern int chrg_sink_volt_judge(eIDX_SOU_CH idx, struct chrg_switch_t *pSW); +extern void chrg_sink_short_keepalive_process(void); #endif