chore: 更新修改日志到V1.1.7并完成低电流待机与并行握手优化
1. 关闭南向寄存器写命令调试日志 2. 新增SINK_LOAD_ENABLE_MIN_MA宏限制最低带载电流为100mA 3. 新增SINK_WORK_LOAD_STANDBY等4种低电流待机工作状态 4. 重构协议电压/电流变化处理逻辑,改为软卸载不切继电器 5. 实现南北向握手并行执行,降低0x20查询频率 6. 新增chrg_sink_load_should_start和chrg_sink_handshake_north_ready接口 7. 优化RUNING状态命令顺序,避免主继电器重复断开 8. 更新编译日志,修正代码尺寸数据
This commit is contained in:
@@ -100,6 +100,9 @@ static void chrg_mb_write_src(rt_uint8_t ch, rt_uint16_t reg_offset, rt_uint16_t
|
||||
static eMBException chrg_mb_write_sys(rt_uint8_t ch, rt_uint16_t reg_offset, rt_uint16_t sou_value, struct chrg_switch_t *pSW, struct chrg_north_t *pNOR, struct chrg_south_t *pSOU);
|
||||
static int chrg_sink_diff_send_reg(eIDX_SOU_CH ch,
|
||||
const chrg_param_diff_t *pDiff, struct chrg_switch_t *pReal);
|
||||
static rt_bool_t chrg_comm_handle_sink_load_current(
|
||||
const chrg_param_diff_t *pDiff, rt_uint8_t old_work_mode,
|
||||
struct chrg_switch_t *pReal);
|
||||
|
||||
/*! \brief Function to set bits in a byte buffer.
|
||||
*
|
||||
@@ -2338,23 +2341,31 @@ static eMBException chrg_comm_apply_sink_effect(rt_uint8_t ch,
|
||||
{
|
||||
rt_bool_t full_handshake_change;
|
||||
rt_bool_t protocol_voltage_only;
|
||||
rt_bool_t protocol_current_change;
|
||||
rt_bool_t protocol_data_changed;
|
||||
rt_uint8_t curr_test;
|
||||
rt_uint8_t curr_test_old;
|
||||
rt_uint8_t old_cv_mode = pReal->CV_mode;
|
||||
rt_uint16_t old_loadv = pReal->sink.loadv;
|
||||
rt_uint16_t old_loadc = pReal->sink.loadc;
|
||||
rt_uint8_t old_work_mode = pReal->sink.work_mode;
|
||||
rt_uint16_t sink_work = pShadow->sink.Now_State;
|
||||
chrg_param_diff_t diff_info;
|
||||
|
||||
chrg_comm_get_param_diff(ID_SINK, pReal, pShadow, &diff_info);
|
||||
/*
|
||||
* 协议类型、CC、协议组号或协议电流变化都按完整重握手处理。
|
||||
* 只有单独修改协议电压时才允许仅掉载而不切换南向继电器。
|
||||
* 协议类型、CC和协议组号变化需要完整握手;协议电压和协议电流
|
||||
* 变化只需要软卸载后重发协议,不关闭南向继电器。
|
||||
*/
|
||||
full_handshake_change = diff_info.protocol_changed || diff_info.cc_changed ||
|
||||
diff_info.group_changed || diff_info.pro_current_changed;
|
||||
protocol_voltage_only = diff_info.pro_voltage_changed &&
|
||||
diff_info.group_changed;
|
||||
protocol_data_changed = diff_info.protocol_changed ||
|
||||
diff_info.group_changed || diff_info.pro_voltage_changed ||
|
||||
diff_info.pro_current_changed;
|
||||
protocol_current_change = diff_info.pro_current_changed &&
|
||||
!full_handshake_change;
|
||||
protocol_voltage_only = diff_info.pro_voltage_changed &&
|
||||
!full_handshake_change && !protocol_current_change;
|
||||
rt_memcpy(pReal, pShadow, sizeof(struct chrg_switch_t));
|
||||
|
||||
if (sink_work == 0x01) {
|
||||
@@ -2380,14 +2391,38 @@ static eMBException chrg_comm_apply_sink_effect(rt_uint8_t ch,
|
||||
pReal->sub = IDX_SET_SINK_PD;
|
||||
pReal->sink.work_mode = SINK_WORK_INIT;
|
||||
} else if (full_handshake_change) {
|
||||
/* 协议类型或CC变化需要重发协议和CC;仅组号/协议电流变化只重发协议。 */
|
||||
pReal->sub = (diff_info.protocol_changed || diff_info.cc_changed) ?
|
||||
IDX_SET_SINK_PD : IDX_SET_SINK_PD_ONLY;
|
||||
/*
|
||||
* 只有CC实际变化时才发送目标CC命令并等待;协议类型或组号
|
||||
* 单独变化时直接重发PD帧,不重复设置未变化的CC。
|
||||
* 协议与CC同时变化时先发送协议,协议应答后再设置目标CC;
|
||||
* 仅协议变化时不重复设置未变化的CC。
|
||||
*/
|
||||
if (diff_info.cc_changed && protocol_data_changed) {
|
||||
pReal->sub = IDX_SET_SINK_PD;
|
||||
} else if (diff_info.cc_changed) {
|
||||
pReal->sub = IDX_SET_SINK_CCLINE;
|
||||
} else {
|
||||
pReal->sub = IDX_SET_SINK_PD_ONLY;
|
||||
}
|
||||
pReal->sink.work_mode = SINK_WORK_HANDSHAKE_PREPARE;
|
||||
} else if (protocol_voltage_only) {
|
||||
/* 仅协议电压变化时保持主副继电器状态,只停止负载并清零电流。 */
|
||||
} else if (protocol_voltage_only || protocol_current_change) {
|
||||
/*
|
||||
* 协议电压、协议电流变化都只执行软卸载,不关闭南向继电器。
|
||||
* 低电流待机本身已经WORK_STOP,无需重复提交卸载命令;运行中
|
||||
* 则等待实际电流降到安全范围后再重发协议。
|
||||
*/
|
||||
pReal->sub = IDX_SET_SINK_PD_ONLY;
|
||||
pReal->sink.work_mode = SINK_WORK_PROTOCOL_UNLOAD;
|
||||
if (old_work_mode == SINK_WORK_LOAD_STANDBY) {
|
||||
pReal->sink.work_mode = SINK_WORK_WAIT;
|
||||
} else if (old_work_mode == SINK_WORK_LOAD_SOFT_STANDBY) {
|
||||
pReal->sink.work_mode = SINK_WORK_SOFT_RESUME_WAIT;
|
||||
} else {
|
||||
/* 运行状态修改协议参数时保持继电器,只停止电子负载。 */
|
||||
pReal->sink.work_mode = SINK_WORK_PROTOCOL_UNLOAD;
|
||||
}
|
||||
} else if (chrg_comm_handle_sink_load_current(&diff_info,
|
||||
old_work_mode, pReal)) {
|
||||
/* 电流跨门限的停止或恢复已转换为独立Sink状态,由统一入口下发。 */
|
||||
} else if (chrg_sink_diff_send_reg((eIDX_SOU_CH)ch,
|
||||
&diff_info, pReal) != 0) {
|
||||
pReal->CV_mode = old_cv_mode;
|
||||
@@ -2404,6 +2439,59 @@ static eMBException chrg_comm_apply_sink_effect(rt_uint8_t ch,
|
||||
MB_EX_NONE : MB_EX_SLAVE_BUSY;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
函数名称: chrg_comm_handle_sink_load_current
|
||||
函数描述: 处理普通负载电流跨越最低带载门限时的状态转换
|
||||
输入参数: pDiff:本次参数差异 old_work_mode:生效前工作状态
|
||||
pReal:已复制新参数的运行结构体
|
||||
输出参数: 必要时更新sink.work_mode
|
||||
返回说明: RT_TRUE:本次电流变化已处理,禁止再直接写电流寄存器
|
||||
RT_FALSE:未跨门限,继续执行普通差异下发
|
||||
其它说明: 北向协议、CC和协议电流变化在调用本函数前处理;本函数只管理
|
||||
南向电子负载的WORK_STOP/CURRENT=0及无握手快速恢复
|
||||
*****************************************************************/
|
||||
static rt_bool_t chrg_comm_handle_sink_load_current(
|
||||
const chrg_param_diff_t *pDiff, rt_uint8_t old_work_mode,
|
||||
struct chrg_switch_t *pReal)
|
||||
{
|
||||
rt_bool_t should_start;
|
||||
|
||||
if ((pDiff == RT_NULL) || (pReal == RT_NULL) ||
|
||||
!pDiff->current_changed ||
|
||||
(pReal->CV_mode != MODE_CONSTANT_CURRENT)) {
|
||||
return RT_FALSE;
|
||||
}
|
||||
should_start = chrg_sink_load_should_start(pReal);
|
||||
|
||||
if ((old_work_mode == SINK_WORK_RUNING) ||
|
||||
(old_work_mode == SINK_WORK_SOFT_RUNNING)) {
|
||||
if (!should_start) {
|
||||
pReal->sink.work_mode = SINK_WORK_LOAD_STOP;
|
||||
return RT_TRUE;
|
||||
}
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
if (old_work_mode == SINK_WORK_LOAD_STANDBY) {
|
||||
if (should_start) {
|
||||
/* 独立入口可避开RUNING相同状态去重,并执行完整继电器启动。 */
|
||||
pReal->sink.work_mode = SINK_WORK_LOAD_START;
|
||||
}
|
||||
return RT_TRUE;
|
||||
}
|
||||
|
||||
if (old_work_mode == SINK_WORK_LOAD_SOFT_STANDBY) {
|
||||
if (should_start) {
|
||||
/* 继电器和协议保持不变,只恢复目标电流和WORK_START。 */
|
||||
pReal->sink.work_mode = SINK_WORK_LOAD_RESUME;
|
||||
}
|
||||
return RT_TRUE;
|
||||
}
|
||||
|
||||
/* 协议握手期间禁止把低于门限的小电流提前写入南向功率板。 */
|
||||
return should_start ? RT_FALSE : RT_TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
函数名称: chrg_comm_apply_source_effect
|
||||
函数描述: 处理COM参数生效后的同角色电源启停和参数差异更新
|
||||
|
||||
Reference in New Issue
Block a user