diff --git a/apps/chrg/applications/thread/chrg_north.c b/apps/chrg/applications/thread/chrg_north.c index 7f65fee..ee0350c 100644 --- a/apps/chrg/applications/thread/chrg_north.c +++ b/apps/chrg/applications/thread/chrg_north.c @@ -160,48 +160,6 @@ void chrg_source_setting(rt_uint8_t *frame_data, eIDX_SOU_CH idx, pSW->sub = IDX_SET_SOURCE_STOP_STATE; } } -////解析负载返回数据 -//void chrg_sink_parse(rt_uint8_t *frame_data, eIDX_SOU_CH idx, -// struct chrg_switch_t *pSW, struct chrg_north_t *pNOR) -//{ -// rt_uint16_t volt_mv = ((frame_data[4] << 8) | frame_data[5])*10; -// static uint8_t volt_low[TOTAL_SOU_CHS] = {0}; -// static uint8_t no_curr[TOTAL_SOU_CHS] = {0}; -// pSW->VZ = ((frame_data[14] << 8) | frame_data[15]); -// pSW->VF = ((frame_data[16] << 8) | frame_data[17]); - -//#if DEBUG_NORTH -// LOG_D("Sink[%d] real volt: %d mV", idx, volt_mv); -//#endif -// -// if(pSW->sink.On_work == 1) { -// if(pSW->sink.test.test_mode == 0){ -// if (volt_mv <= WORK_MIN_VOLT) { // 电压过低,禁止进入工作状态机 -// volt_low[idx]++; -// //if(volt_low[idx]>=5) pSW->sink.work_mode = SINK_WORK_LOW; // 复位工作状态机 -// } -// else{ // 电压稳定时执行工作状态机(继电器/工作模式切换) -// volt_low[idx] = 0; -// pSW->change_flag = 0; -// if((pSW->sink.pro_loadv - volt_mv) <= 2000){ -// pSW->sink.work_mode = SINK_WORK_RUNING; -// if(pSW->Now_current<=200){ -// if(no_curr[idx]++>=5){ -// pSW->sink.work_mode = SINK_WORK_WAIT; -// no_curr[idx] = 0; -// } -// } -// else no_curr[idx] = 0; -// } -// } -// } -// } -// else{ -// volt_low[idx] = 0; -//// pSW->sink.work_mode = SINK_WORK_STOP; -// } -// chrg_sink_work(idx,pSW); -//} //解析负载返回数据 void chrg_sink_parse(rt_uint8_t *frame_data, eIDX_SOU_CH idx, diff --git a/apps/chrg/applications/thread/chrg_roll_nor.c b/apps/chrg/applications/thread/chrg_roll_nor.c index 7bfcb09..736cebb 100644 --- a/apps/chrg/applications/thread/chrg_roll_nor.c +++ b/apps/chrg/applications/thread/chrg_roll_nor.c @@ -355,7 +355,10 @@ void chrg_roll_nor_set(rt_uint8_t ch, struct chrg_switch_t *pSW,rt_uint8_t *enab break; case IDX_SET_SOURCE_PD: chrg_roll_nor_source_pro_set(pSW); - pSW->source.On_Flag = 1; + if (pSW->sub == IDX_GET_SOURCE_VC && + chrg_source_init_submit((eIDX_SOU_CH)ch, pSW) == 0) { + pSW->source.On_Flag = 1; + } break; case IDX_GET_SOURCE_VC: source_get_vc(pSW->source.vc.set_voltage, pSW->source.vc.set_current); diff --git a/apps/chrg/applications/utils/chrg_source.c b/apps/chrg/applications/utils/chrg_source.c index 76ebabf..62e09dd 100644 --- a/apps/chrg/applications/utils/chrg_source.c +++ b/apps/chrg/applications/utils/chrg_source.c @@ -13,6 +13,31 @@ #include "chrg_utils.h" #include "chrg_roll_nor.h" #include "chrg_source.h" +#include "chrg_eload.h" +#include "chrg_roll_sou.h" + +int chrg_source_init_submit(rt_uint8_t idx, struct chrg_switch_t *pSW) +{ + rt_uint16_t regs[5] = { + REG_ELOAD, + REG_MODE, + REG_VOLTAGE_OUT + 1, + REG_CURRENT_OUT + 1, + REG_WORK + }; + rt_uint16_t vals[5] = { + ELOAD_SOURCE, + pSW->CV_mode, + pSW->source.max_vol, + pSW->source.protective_curr, + WORK_STOP + }; + + if ((idx >= TOTAL_SOU_CHS) || (pSW == RT_NULL)) { + return -1; + } + return chrg_sou_com_batch_submit(idx, regs, vals, 5); +} rt_uint8_t Pro_Group_VCMM[11][8] = { {0} // 11个挡位,8个参数(src, pps, vmin_H,vmin_L, vmax_H,vmax_L,cur_set_H,cur_set_L) }; diff --git a/apps/chrg/applications/utils/chrg_source.h b/apps/chrg/applications/utils/chrg_source.h index b4bc84c..8ed2c4f 100644 --- a/apps/chrg/applications/utils/chrg_source.h +++ b/apps/chrg/applications/utils/chrg_source.h @@ -249,6 +249,9 @@ extern void parse_power_pdo_gear(rt_uint8_t protoCmd, rt_uint8_t *pData, rt_uint extern void parse_multi_gear_more(rt_uint8_t protoCmd, rt_uint8_t *pData, rt_uint16_t reqLen,uint8_t *pro_gear_idx,uint8_t *pro,rt_uint16_t *protect_ma); extern void parse_power_ufcs(rt_uint8_t *pData, rt_uint16_t reqLen, uint8_t *pro_gear_idx, uint8_t *pro,rt_uint16_t *protect_ma); extern int source_set_pd_new_com(rt_uint8_t pro, struct chrg_switch_t *pSW); + +/* 提交 Source 功率板初始化参数;北向协议设置完成后调用。 */ +extern int chrg_source_init_submit(rt_uint8_t idx, struct chrg_switch_t *pSW); #endif