refactor: 重构南向充电控制与参数管理逻辑

1.  apps/chrg/applications/thread/chrg_south.c: 新增支持YM_CAN应答类型处理
2.  apps/chrg/applications/utils/chrg_source.h: 移除冗余的max_vol、protective_curr字段
3.  apps/chrg/applications/utils/chrg_sink.h: 新增OCP测试状态枚举与注释
4.  apps/chrg/applications/thread/chrg_comm.h: 移除废弃的sink_proto_diff_t结构体及相关声明
5.  apps/chrg/applications/thread/chrg_roll_sou.h/.c: 重构南向升级逻辑,新增帧缓存与安全发送机制
6.  apps/chrg/applications/utils/chrg_eload.c: 重构Ymodem应答队列,优化并发访问处理
7.  apps/chrg/applications/utils/chrg_sink.c: 新增OCP测试功能实现与状态切换逻辑
8.  apps/chrg/applications/utils/chrg_source.c: 替换protective_curr为vc.set_current,移除冗余enable标志
9.  apps/chrg/applications/thread/chrg_north.c: 重构电源电压控制逻辑,简化快充输出流程
10. apps/chrg/applications/thread/chrg_comm.c: 全面重构Ymodem升级协议与参数差异处理逻辑
This commit is contained in:
wrh
2026-07-25 10:16:45 +08:00
parent 1fc998f168
commit 4beeb02382
11 changed files with 927 additions and 426 deletions
+45 -11
View File
@@ -32,10 +32,31 @@ static rt_uint8_t g_eload_ymodem_ready = 0; // 应答就绪标志(1=有新应
函数描述: 存储南向板返回的ymodem应答字节(由chrg_roll_sou在RUN_UPDATA调用)
输入参数: resp: 南向ymodem应答 (ACK=0x06 / NAK=0x15 / 'C'=0x43)
*****************************************************************/
#define ELOAD_YMODEM_RESP_DEPTH 8
static rt_uint8_t g_ymodem_resp_queue[ELOAD_YMODEM_RESP_DEPTH];
static rt_uint8_t g_ymodem_resp_read = 0;
static rt_uint8_t g_ymodem_resp_write = 0;
static rt_uint8_t g_ymodem_resp_count = 0;
void chrg_eload_set_ymodem_resp(rt_uint8_t resp)
{
g_eload_ymodem_resp = resp;
g_eload_ymodem_ready = 1;
rt_base_t level = rt_hw_interrupt_disable();
/* 队列已满时丢弃周期性的C,保留更关键的ACK/NAK/CAN。 */
if (g_ymodem_resp_count >= ELOAD_YMODEM_RESP_DEPTH) {
if (resp == ACK_C) {
rt_hw_interrupt_enable(level);
return;
}
g_ymodem_resp_read = (g_ymodem_resp_read + 1) % ELOAD_YMODEM_RESP_DEPTH;
g_ymodem_resp_count--;
}
g_ymodem_resp_queue[g_ymodem_resp_write] = resp;
g_ymodem_resp_write = (g_ymodem_resp_write + 1) % ELOAD_YMODEM_RESP_DEPTH;
g_ymodem_resp_count++;
g_eload_ymodem_resp = resp;
g_eload_ymodem_ready = 1;
rt_hw_interrupt_enable(level);
}
/*****************************************************************
@@ -45,13 +66,19 @@ void chrg_eload_set_ymodem_resp(rt_uint8_t resp)
*****************************************************************/
rt_uint8_t chrg_eload_get_ymodem_resp(void)
{
rt_uint8_t resp = 0;
if (g_eload_ymodem_ready) {
resp = g_eload_ymodem_resp;
g_eload_ymodem_ready = 0;
g_eload_ymodem_resp = 0;
}
return resp;
rt_uint8_t resp = 0;
rt_base_t level = rt_hw_interrupt_disable();
if (g_ymodem_resp_count > 0) {
resp = g_ymodem_resp_queue[g_ymodem_resp_read];
g_ymodem_resp_read = (g_ymodem_resp_read + 1) % ELOAD_YMODEM_RESP_DEPTH;
g_ymodem_resp_count--;
}
g_eload_ymodem_ready = (g_ymodem_resp_count > 0);
g_eload_ymodem_resp = g_eload_ymodem_ready ?
g_ymodem_resp_queue[g_ymodem_resp_read] : 0;
rt_hw_interrupt_enable(level);
return resp;
}
/*****************************************************************
@@ -60,8 +87,15 @@ rt_uint8_t chrg_eload_get_ymodem_resp(void)
*****************************************************************/
void chrg_eload_clear_ymodem_resp(void)
{
g_eload_ymodem_resp = 0;
g_eload_ymodem_ready = 0;
rt_base_t level = rt_hw_interrupt_disable();
g_ymodem_resp_read = 0;
g_ymodem_resp_write = 0;
g_ymodem_resp_count = 0;
g_eload_ymodem_resp = 0;
g_eload_ymodem_ready = 0;
rt_memset(g_ymodem_resp_queue, 0, sizeof(g_ymodem_resp_queue));
rt_hw_interrupt_enable(level);
}
static int memcmp_8bytes(const rt_uint8_t *buf1, const rt_uint8_t *buf2)