|
|
@ -29,47 +29,50 @@ void ufcs_power_change_patch(uint16_t src_cap_idx) |
|
|
|
// 参数1: 需要更新多少到多少W的src_cap 参数2: 是否需要重新发送src_cap
|
|
|
|
void updata_diff_protocol_cap(uint16_t src_cap_idx, bool send_src_cap) |
|
|
|
{ |
|
|
|
// 根据当前走的协议是什么,去更新对应的src_cap
|
|
|
|
if(dpdm_power_get_next_protocol() == PROTOCOL_UNKNOWN |
|
|
|
|| dpdm_power_get_next_protocol() == PROTOCOL_APPLE |
|
|
|
|| dpdm_power_get_next_protocol() == PROTOCOL_DCP |
|
|
|
|| dpdm_power_get_next_protocol() == PROTOCOL_QC_PRE |
|
|
|
) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
log_info("%d %d %d\n", |
|
|
|
user_app.current_src_cap_idx, |
|
|
|
src_cap_idx, |
|
|
|
dpdm_power_get_next_protocol()); |
|
|
|
|
|
|
|
user_app.current_src_cap_idx = src_cap_idx; |
|
|
|
|
|
|
|
switch(dpdm_power_get_next_protocol()) |
|
|
|
{ |
|
|
|
case PROTOCOL_PD_FIX: |
|
|
|
case PROTOCOL_PD_PPS: |
|
|
|
pd_dpm_update_source_cap(&g_pd_port, &g_pd_port.pd_curr_config->src_cap_info[src_cap_idx], src_cap_idx); |
|
|
|
pd_restart_send_src_cap(&g_pd_port, src_cap_idx); |
|
|
|
/*
|
|
|
|
// 根据当前走的协议是什么,去更新对应的src_cap
|
|
|
|
if(dpdm_power_get_next_protocol() == PROTOCOL_UNKNOWN |
|
|
|
|| dpdm_power_get_next_protocol() == PROTOCOL_APPLE |
|
|
|
|| dpdm_power_get_next_protocol() == PROTOCOL_DCP |
|
|
|
|| dpdm_power_get_next_protocol() == PROTOCOL_QC_PRE |
|
|
|
) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// log_info("%d %d %d\n",
|
|
|
|
// user_app.current_src_cap_idx,
|
|
|
|
// src_cap_idx,
|
|
|
|
// dpdm_power_get_next_protocol());
|
|
|
|
|
|
|
|
switch(dpdm_power_get_next_protocol()) |
|
|
|
{ |
|
|
|
case PROTOCOL_PD_FIX: |
|
|
|
case PROTOCOL_PD_PPS: |
|
|
|
log_info("%s %d\n", __func__, __LINE__); |
|
|
|
|
|
|
|
// pd_dpm_update_source_cap(&g_pd_port, &g_pd_port.pd_curr_config->src_cap_info[src_cap_idx], src_cap_idx);
|
|
|
|
|
|
|
|
if(send_src_cap) |
|
|
|
{ |
|
|
|
pd_restart_send_src_cap(&g_pd_port, src_cap_idx); |
|
|
|
} |
|
|
|
|
|
|
|
if(send_src_cap) |
|
|
|
{ |
|
|
|
pd_restart_send_src_cap(&g_pd_port); |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
break; |
|
|
|
case PROTOCOL_SCP: |
|
|
|
break; |
|
|
|
|
|
|
|
case PROTOCOL_SCP: |
|
|
|
break; |
|
|
|
#if UFCS_DERATE_SUPPORT |
|
|
|
|
|
|
|
#if UFCS_DERATE_SUPPORT |
|
|
|
|
|
|
|
case PROTOCOL_UFCS: |
|
|
|
// 为了避免撞包问题, 按协议规定12ms内没收到包才发power_change
|
|
|
|
user_app.ufcs_need_send_power_change = true; |
|
|
|
break; |
|
|
|
#endif |
|
|
|
} |
|
|
|
case PROTOCOL_UFCS: |
|
|
|
// 为了避免撞包问题, 按协议规定12ms内没收到包才发power_change
|
|
|
|
user_app.ufcs_need_send_power_change = true; |
|
|
|
break; |
|
|
|
#endif |
|
|
|
} |
|
|
|
*/ |
|
|
|
} |
|
|
|
|
|
|
|
// 端口状态机
|
|
|
@ -116,20 +119,20 @@ void port_status_run(void) |
|
|
|
|
|
|
|
if(user_app.ntc_triggered_dera) |
|
|
|
{ |
|
|
|
user_app.current_src_cap_idx = SRC_CAP_7W; |
|
|
|
pd_restart_send_src_cap(&g_pd_port, SRC_CAP_7W); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
user_app.current_src_cap_idx = SRC_CAP_30W; |
|
|
|
pd_restart_send_src_cap(&g_pd_port, SRC_CAP_30W); |
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
user_app.current_src_cap_idx = SRC_CAP_30W; |
|
|
|
pd_restart_send_src_cap(&g_pd_port, SRC_CAP_30W); |
|
|
|
#endif |
|
|
|
|
|
|
|
// 什么都没接时, 也是用buck给A口供电来检查A口是否插入
|
|
|
|
buck_control(true); |
|
|
|
drv_delay_ms(5); |
|
|
|
drv_delay_ms(4); |
|
|
|
dpdm_power_a1_gate_enable(false); |
|
|
|
} |
|
|
|
else |
|
|
@ -145,7 +148,7 @@ void port_status_run(void) |
|
|
|
port_process_status = port_exit_status; |
|
|
|
// 单C口时, 常开buck, 关闭gateA, 等A口有拉电流才反过来
|
|
|
|
buck_control(true); |
|
|
|
drv_delay_ms(5); |
|
|
|
drv_delay_ms(4); |
|
|
|
dpdm_power_a1_gate_enable(false); |
|
|
|
} |
|
|
|
else |
|
|
@ -157,20 +160,15 @@ void port_status_run(void) |
|
|
|
|
|
|
|
if(user_app.ntc_triggered_dera && user_app.current_src_cap_idx != SRC_CAP_7W) |
|
|
|
{ |
|
|
|
updata_diff_protocol_cap(SRC_CAP_7W, true); |
|
|
|
pd_restart_send_src_cap(&g_pd_port, SRC_CAP_7W); |
|
|
|
} |
|
|
|
else if(!user_app.ntc_triggered_dera && user_app.current_src_cap_idx != SRC_CAP_30W) |
|
|
|
{ |
|
|
|
updata_diff_protocol_cap(SRC_CAP_30W, true); |
|
|
|
pd_restart_send_src_cap(&g_pd_port, SRC_CAP_30W); |
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
if(user_app.current_src_cap_idx != SRC_CAP_30W) |
|
|
|
{ |
|
|
|
updata_diff_protocol_cap(SRC_CAP_30W, true); |
|
|
|
} |
|
|
|
|
|
|
|
pd_restart_send_src_cap(&g_pd_port, SRC_CAP_30W); |
|
|
|
#endif |
|
|
|
|
|
|
|
break; |
|
|
@ -182,7 +180,7 @@ void port_status_run(void) |
|
|
|
|
|
|
|
// 单A口
|
|
|
|
dpdm_power_a1_gate_enable(true); |
|
|
|
drv_delay_ms(5); |
|
|
|
drv_delay_ms(4); |
|
|
|
buck_control(false); |
|
|
|
} |
|
|
|
else |
|
|
@ -193,6 +191,21 @@ void port_status_run(void) |
|
|
|
break; |
|
|
|
|
|
|
|
case TYPEC_USBA_INSER: |
|
|
|
#if NTC_ENABLE |
|
|
|
|
|
|
|
if(user_app.ntc_triggered_dera && user_app.current_src_cap_idx != SRC_CAP_7W) |
|
|
|
{ |
|
|
|
pd_restart_send_src_cap(&g_pd_port, SRC_CAP_7W); |
|
|
|
} |
|
|
|
else if(!user_app.ntc_triggered_dera && user_app.current_src_cap_idx != SRC_CAP_20W) |
|
|
|
{ |
|
|
|
pd_restart_send_src_cap(&g_pd_port, SRC_CAP_20W); |
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
pd_restart_send_src_cap(&g_pd_port, SRC_CAP_20W); |
|
|
|
#endif |
|
|
|
|
|
|
|
if(port_process_status == port_enter_status) |
|
|
|
{ |
|
|
|
port_process_status = port_exit_status; |
|
|
@ -204,13 +217,13 @@ void port_status_run(void) |
|
|
|
comp_set_current(&g_powerout_info, CURRENT_5P5A); // 需要立刻设置
|
|
|
|
// 是否有可能电流环设置的没那么快, 一打开gateA就被拉挂了? 需要加个延迟等电流环设置完再开A?
|
|
|
|
dpdm_power_a1_gate_enable(true); |
|
|
|
drv_delay_ms(5); |
|
|
|
drv_delay_ms(4); |
|
|
|
buck_control(false); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
buck_control(true); |
|
|
|
drv_delay_ms(5); |
|
|
|
drv_delay_ms(4); |
|
|
|
dpdm_power_a1_gate_enable(false); |
|
|
|
} |
|
|
|
} |
|
|
@ -222,7 +235,7 @@ void port_status_run(void) |
|
|
|
{ |
|
|
|
// todo: 看看是否需要延迟个1ms等待buck完全开启再关gateA
|
|
|
|
buck_control(true); |
|
|
|
drv_delay_ms(5); |
|
|
|
drv_delay_ms(4); |
|
|
|
dpdm_power_a1_gate_enable(false); |
|
|
|
} |
|
|
|
else if(g_powerout_info.set_vol < VOLTAGE_5P5V |
|
|
@ -231,31 +244,11 @@ void port_status_run(void) |
|
|
|
{ |
|
|
|
comp_set_current(&g_powerout_info, CURRENT_5P5A); // 需要立刻设置
|
|
|
|
dpdm_power_a1_gate_enable(true); |
|
|
|
drv_delay_ms(5); |
|
|
|
drv_delay_ms(4); |
|
|
|
buck_control(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#if NTC_ENABLE |
|
|
|
|
|
|
|
if(user_app.ntc_triggered_dera && user_app.current_src_cap_idx != SRC_CAP_7W) |
|
|
|
{ |
|
|
|
updata_diff_protocol_cap(SRC_CAP_7W, true); |
|
|
|
} |
|
|
|
else if(!user_app.ntc_triggered_dera && user_app.current_src_cap_idx != SRC_CAP_20W) |
|
|
|
{ |
|
|
|
updata_diff_protocol_cap(SRC_CAP_20W, true); |
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
if(user_app.current_src_cap_idx != SRC_CAP_20W) |
|
|
|
{ |
|
|
|
updata_diff_protocol_cap(SRC_CAP_20W, true); |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|