|
|
@ -3,8 +3,10 @@ |
|
|
|
#include "comp_protocol_manager.h" |
|
|
|
#include "comp_powerout.h" |
|
|
|
#include "customized.h" |
|
|
|
#include "comp_cable_compensation.h" |
|
|
|
#include "dpdm_run.h" |
|
|
|
|
|
|
|
ufcs_port_s g_ufcs_port; |
|
|
|
// ufcs_port_s g_ufcs_port;
|
|
|
|
|
|
|
|
|
|
|
|
static void ufcs_handshake_ping_callback_patch(ufcs_param_s *ufcs_param); |
|
|
@ -54,6 +56,127 @@ static const ufcs_phy_callback_s mtp_ufcs_phy_callback_func = |
|
|
|
.send_ufcs_pkt = mtp_send_ufcs_pkt |
|
|
|
}; |
|
|
|
|
|
|
|
#if UFCS_SUPPORT |
|
|
|
/*********************UFCS************************************/ |
|
|
|
|
|
|
|
#define SCP_RS82 0x00 |
|
|
|
#define SCP_RS83 0xc3 |
|
|
|
|
|
|
|
|
|
|
|
const ufcs_out_mode_info_s UFCS_OUT_MODE_INFO[] = |
|
|
|
{ |
|
|
|
|
|
|
|
// {
|
|
|
|
// .out_mode_cnt = 5,
|
|
|
|
|
|
|
|
// .mode1_l = UFCS_SRC_PDO_L(CURRENT_0P3A, CURRENT_5A, VOLTAGE_3P4V, VOLTAGE_5P5V, UFCS_VOL_STEP_20MV, UFCS_CUR_STEP_50MA, 1),
|
|
|
|
// .mode1_h = UFCS_SRC_PDO_H(CURRENT_0P3A, CURRENT_5A, VOLTAGE_3P4V, VOLTAGE_5P5V, UFCS_VOL_STEP_20MV, UFCS_CUR_STEP_50MA, 1),
|
|
|
|
|
|
|
|
// .mode2_l = UFCS_SRC_PDO_L(CURRENT_0P3A, CURRENT_6P6A, VOLTAGE_5P5V, VOLTAGE_10V, UFCS_VOL_STEP_20MV, UFCS_CUR_STEP_50MA, 2),
|
|
|
|
// .mode2_h = UFCS_SRC_PDO_H(CURRENT_0P3A, CURRENT_6P6A, VOLTAGE_5P5V, VOLTAGE_10V, UFCS_VOL_STEP_20MV, UFCS_CUR_STEP_50MA, 2),
|
|
|
|
|
|
|
|
// .mode3_l = UFCS_SRC_PDO_L(CURRENT_0P3A, CURRENT_6A, VOLTAGE_10V, VOLTAGE_11V, UFCS_VOL_STEP_20MV, UFCS_CUR_STEP_50MA, 3),
|
|
|
|
// .mode3_h = UFCS_SRC_PDO_H(CURRENT_0P3A, CURRENT_6A, VOLTAGE_10V, VOLTAGE_11V, UFCS_VOL_STEP_20MV, UFCS_CUR_STEP_50MA, 3),
|
|
|
|
|
|
|
|
// .mode4_l = UFCS_SRC_PDO_L(CURRENT_0P3A, CURRENT_3P25A, VOLTAGE_11V, VOLTAGE_20V, UFCS_VOL_STEP_20MV, UFCS_CUR_STEP_50MA, 4),
|
|
|
|
// .mode4_h = UFCS_SRC_PDO_H(CURRENT_0P3A, CURRENT_3P25A, VOLTAGE_11V, VOLTAGE_20V, UFCS_VOL_STEP_20MV, UFCS_CUR_STEP_50MA, 4),
|
|
|
|
|
|
|
|
// .mode5_l = UFCS_SRC_PDO_L(CURRENT_0P3A, CURRENT_3P1A, VOLTAGE_20V, VOLTAGE_21V, UFCS_VOL_STEP_20MV, UFCS_CUR_STEP_50MA, 5),
|
|
|
|
// .mode5_h = UFCS_SRC_PDO_H(CURRENT_0P3A, CURRENT_3P1A, VOLTAGE_20V, VOLTAGE_21V, UFCS_VOL_STEP_20MV, UFCS_CUR_STEP_50MA, 5),
|
|
|
|
|
|
|
|
// .mode6_l = 0,
|
|
|
|
// .mode6_h = 0,
|
|
|
|
|
|
|
|
// .mode7_l = 0,
|
|
|
|
// .mode7_h = 0
|
|
|
|
// }
|
|
|
|
|
|
|
|
{ |
|
|
|
.out_mode_cnt = 1, |
|
|
|
|
|
|
|
.mode1_l = UFCS_SRC_PDO_L(CURRENT_0P3A, CURRENT_3A, VOLTAGE_3P4V, VOLTAGE_11V, UFCS_VOL_STEP_20MV, UFCS_CUR_STEP_50MA, 1), |
|
|
|
.mode1_h = UFCS_SRC_PDO_H(CURRENT_0P3A, CURRENT_3A, VOLTAGE_3P4V, VOLTAGE_11V, UFCS_VOL_STEP_20MV, UFCS_CUR_STEP_50MA, 1), |
|
|
|
|
|
|
|
.mode2_l = 0, |
|
|
|
.mode2_h = 0, |
|
|
|
|
|
|
|
.mode3_l = 0, |
|
|
|
.mode3_h = 0, |
|
|
|
|
|
|
|
.mode4_l = 0, |
|
|
|
.mode4_h = 0, |
|
|
|
|
|
|
|
.mode5_l = 0, |
|
|
|
.mode5_h = 0, |
|
|
|
|
|
|
|
.mode6_l = 0, |
|
|
|
.mode6_h = 0, |
|
|
|
|
|
|
|
.mode7_l = 0, |
|
|
|
.mode7_h = 0 |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const device_information_u DEVICE_INFO[] = |
|
|
|
{ |
|
|
|
{ |
|
|
|
.bits.vdmid_h = (HUAWEI_UFCS_VDM_ID >> 8), |
|
|
|
.bits.vdmid_l = (HUAWEI_UFCS_VDM_ID & 0xff), |
|
|
|
.bits.chipid_h = SCP_RS82, |
|
|
|
.bits.chipid_l = SCP_RS83, |
|
|
|
.bits.hard_ware_h = 0x00, |
|
|
|
.bits.hard_ware_l = 0x00, |
|
|
|
.bits.soft_ware_h = SOFT_WARE_VERISION_H, |
|
|
|
.bits.soft_ware_l = SOFT_WARE_VERISION_L |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
#if UFCS_DERATE_SUPPORT |
|
|
|
|
|
|
|
const ufcs_power_change_capabilities_u DEF_POWER_CHANGE_PDO[] = |
|
|
|
{ |
|
|
|
// 30W
|
|
|
|
{ |
|
|
|
.bits.index = 1, |
|
|
|
.bits.resverd0 = 0, |
|
|
|
.bits.max_output_cur_L = UFCS_POWER_CHANGE_L(CURRENT_3A), |
|
|
|
.bits.max_output_cur_H = UFCS_POWER_CHANGE_H(CURRENT_3A), |
|
|
|
}, |
|
|
|
|
|
|
|
// 20W
|
|
|
|
{ |
|
|
|
.bits.index = 1, |
|
|
|
.bits.resverd0 = 0, |
|
|
|
.bits.max_output_cur_L = UFCS_POWER_CHANGE_L(CURRENT_2A), |
|
|
|
.bits.max_output_cur_H = UFCS_POWER_CHANGE_H(CURRENT_2A), |
|
|
|
}, |
|
|
|
}; |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
const ufcs_config_init_s UFCS_INIT_CONFIG[PORT_TYPE_DUAL_PORT] = |
|
|
|
{ |
|
|
|
{ |
|
|
|
.prl_supported = true, |
|
|
|
|
|
|
|
.ufcs_out_mode_info = UFCS_OUT_MODE_INFO, |
|
|
|
|
|
|
|
.device_information = DEVICE_INFO, |
|
|
|
|
|
|
|
#if UFCS_DERATE_SUPPORT |
|
|
|
.def_power_change_pdo = &DEF_POWER_CHANGE_PDO[0], |
|
|
|
#endif |
|
|
|
// .prl_common_ops = &PRL_COMMON_OPS
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
extern uint8_t g_ufcs_curr_tx_len; |
|
|
|
|
|
|
@ -107,13 +230,15 @@ static uint8_t ptach_ufcs_src_hw_scpb_power_packet(ufcs_param_s *ufcs_param) |
|
|
|
*/ |
|
|
|
void ufcs_handshake_ping_callback_patch(ufcs_param_s *ufcs_param) |
|
|
|
{ |
|
|
|
if((get_adp_prl_mgr_cur_prl() == PROTOCOL_PD_FIX) || |
|
|
|
(get_adp_prl_mgr_cur_prl() == PROTOCOL_PD_PPS)) |
|
|
|
if((dpdm_power_get_next_protocol() == PROTOCOL_PD_FIX) || |
|
|
|
(dpdm_power_get_next_protocol() == PROTOCOL_PD_PPS)) |
|
|
|
{ |
|
|
|
prl_mgr_set_curr_volt(VOLTAGE_5V); |
|
|
|
// prl_mgr_set_curr_volt(VOLTAGE_5V);
|
|
|
|
comp_powerout_prl_set_volt(VOLTAGE_5V); |
|
|
|
} |
|
|
|
|
|
|
|
prl_mgr_set_cur_prl(PROTOCOL_UFCS); |
|
|
|
// prl_mgr_set_cur_prl(PROTOCOL_UFCS);
|
|
|
|
dpdm_power_set_next_protocol(PROTOCOL_UFCS); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -134,8 +259,13 @@ static void app_src_power_set(ufcs_param_s *ufcs_param) |
|
|
|
iset = (ufcs_param->ufcs_flags.ufcs_process_flag.bits.test_mode == true) ? \ |
|
|
|
((iset * 1126) >> 10) : iset; |
|
|
|
|
|
|
|
prl_mgr_set_curr_volt(vset); |
|
|
|
prl_mgr_set_curr_cur(iset); |
|
|
|
// prl_mgr_set_curr_volt(vset);
|
|
|
|
// prl_mgr_set_curr_cur(iset);
|
|
|
|
|
|
|
|
// ufcs关闭线补
|
|
|
|
set_cable_comp_enable(false); |
|
|
|
// dpdm_power_set_next_protocol(PROTOCOL_UFCS); // 在ping成功里置了
|
|
|
|
dpdm_power_set(vset, iset); |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
@ -181,7 +311,9 @@ static void ufcs_src_volt_test_func(u_test_req *test_req) |
|
|
|
|
|
|
|
volt_test_mode = test_req->bits.volt_test_mode; |
|
|
|
|
|
|
|
if(g_ufcs_port.ufcs_prl_param.ufcs_flags.ufcs_process_flag.bits.test_mode == volt_test_mode) |
|
|
|
ufcs_port_s *ufcs_port = dpdm_get_ufcs_port(); |
|
|
|
|
|
|
|
if(ufcs_port->ufcs_prl_param.ufcs_flags.ufcs_process_flag.bits.test_mode == volt_test_mode) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
@ -192,10 +324,10 @@ static void ufcs_src_volt_test_func(u_test_req *test_req) |
|
|
|
((iset * 1126) >> 10) : ((iset << 10) / 1126); |
|
|
|
|
|
|
|
|
|
|
|
g_ufcs_port.ufcs_prl_param.ufcs_flags.ufcs_process_flag.bits.test_mode = volt_test_mode; |
|
|
|
|
|
|
|
prl_mgr_set_curr_cur(iset); |
|
|
|
ufcs_port->ufcs_prl_param.ufcs_flags.ufcs_process_flag.bits.test_mode = volt_test_mode; |
|
|
|
|
|
|
|
// prl_mgr_set_curr_cur(iset);
|
|
|
|
comp_powerout_prl_set_cur(iset); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
@ -213,16 +345,15 @@ static uint8_t ufcs_src_power_change_msg_assemble(ufcs_param_s *ufcs_param) |
|
|
|
uint8_t power_change_len; |
|
|
|
uint8_t ufcs_cap_cnt; |
|
|
|
|
|
|
|
ufcs_port_s *ufcs_port = dpdm_get_ufcs_port(); |
|
|
|
|
|
|
|
ufcs_cap_cnt = ufcs_param->ufcs_assist.out_cap_cnt; |
|
|
|
|
|
|
|
power_change_len = ufcs_cap_cnt * 3; |
|
|
|
|
|
|
|
ufcs_param->ufcs_assist.ufcs_sent_pkt.ufcs_sent_buf[4] = power_change_len; |
|
|
|
|
|
|
|
|
|
|
|
memcpy(&ufcs_param->ufcs_assist.power_change_cap[0].byte, &g_ufcs_port.ufcs_new_power_change_cur->byte, power_change_len); |
|
|
|
|
|
|
|
|
|
|
|
memcpy(&ufcs_param->ufcs_assist.power_change_cap[0].byte, &ufcs_port->ufcs_new_power_change_cur->byte, power_change_len); |
|
|
|
memcpy(&ufcs_param->ufcs_assist.ufcs_sent_pkt.ufcs_sent_buf[5], ufcs_param->ufcs_assist.power_change_cap[0].byte, power_change_len); |
|
|
|
|
|
|
|
power_change_len += 5; |
|
|
@ -255,6 +386,14 @@ void ufcs_port_init(ufcs_port_s *ufcs_port) |
|
|
|
ufcs_port_prl_hook_register(ufcs_port); |
|
|
|
ufcs_prl_init(ufcs_port); |
|
|
|
ufcs_port->ufcs_prl_param.ufcs_phy_callback = &mtp_ufcs_phy_callback_func; |
|
|
|
|
|
|
|
dpdn_mgr_enable_dpdn_prl(true); |
|
|
|
#if UFCS_DERATE_SUPPORT |
|
|
|
ufcs_port->current_cap_gear = UFCS_CAP_30W; |
|
|
|
#endif |
|
|
|
|
|
|
|
// 清除结构体等
|
|
|
|
ufcs_protocol_reset(&ufcs_port->ufcs_prl_param); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -266,28 +405,22 @@ void ufcs_port_deinit(ufcs_port_s *ufcs_port) |
|
|
|
|
|
|
|
void ufcs_port_dpdn_port_num_config(uint8_t dpdn_num) |
|
|
|
{ |
|
|
|
g_ufcs_port.dpdn_port = dpdn_num; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ufcs_port_trans_port_type_config(uint8_t port_num, uint8_t port_type) |
|
|
|
{ |
|
|
|
ufcs_port_s *ufcs_port = ufcs_get_ufcs_port(port_num); |
|
|
|
|
|
|
|
ufcs_port->ufcs_curr_config = GET_ADP_INIT_CONFIG_ADR(port_num, port_type, UFCS); |
|
|
|
ufcs_port_s *ufcs_port = dpdm_get_ufcs_port(); |
|
|
|
ufcs_port->dpdn_port = dpdn_num; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ufcs_port_s *ufcs_get_ufcs_port(uint8_t port_num) |
|
|
|
{ |
|
|
|
return &g_ufcs_port; |
|
|
|
} |
|
|
|
// ufcs_port_s *ufcs_get_ufcs_port(uint8_t port_num)
|
|
|
|
// {
|
|
|
|
// return &g_ufcs_port;
|
|
|
|
// }
|
|
|
|
|
|
|
|
const ufcs_config_init_s * ufcs_get_ufcs_cur_config(uint8_t port_num) |
|
|
|
{ |
|
|
|
const ufcs_config_init_s *config; |
|
|
|
ufcs_port_s *ufcs_port = dpdm_get_ufcs_port(); |
|
|
|
|
|
|
|
config = g_ufcs_port.ufcs_curr_config; |
|
|
|
config = ufcs_port->ufcs_curr_config; |
|
|
|
|
|
|
|
return config; |
|
|
|
} |
|
|
@ -296,18 +429,14 @@ const ufcs_config_init_s * ufcs_get_ufcs_cur_config(uint8_t port_num) |
|
|
|
|
|
|
|
void ufcs_port_send_power_change(ufcs_port_s *ufcs_port, const ufcs_power_change_capabilities_u *new_power_change) |
|
|
|
{ |
|
|
|
ufcs_port->ufcs_new_power_change_cur = new_power_change; |
|
|
|
ufcs_port->ufcs_send_power_change_en = !ufcs_port->ufcs_send_power_change_en; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void dpdm_mgr_ufcs_send_power_change(const ufcs_power_change_capabilities_u *new_power_change) |
|
|
|
{ |
|
|
|
ufcs_port_s *ufcs_port = dpdm_get_ufcs_port(); |
|
|
|
|
|
|
|
// ufcs_port_send_power_change(ufcs_port, new_power_change);
|
|
|
|
ufcs_port->ufcs_new_power_change_cur = new_power_change; |
|
|
|
ufcs_port->ufcs_send_power_change_en = !ufcs_port->ufcs_send_power_change_en; |
|
|
|
} |
|
|
|