Browse Source

1.更新PD协议

2.不要FCP协议
master
Jipeng.tang 1 month ago
parent
commit
412e332bdc
  1. 5
      .vscode/settings.json
  2. BIN
      104RT-3950.xlsx
  3. BIN
      2331项目功率分配软件逻辑图 .docx
  4. BIN
      A2331 33W 1C1A PRD 外发版 (1).pdf
  5. BIN
      NTC温度逻辑.eddx
  6. 3
      PD_CPS8841H_33W/code/app/inc/comm_event.h
  7. 48
      PD_CPS8841H_33W/code/app/inc/config.h
  8. 11
      PD_CPS8841H_33W/code/app/inc/ntc.h
  9. 5
      PD_CPS8841H_33W/code/app/src/app_periodic_schedule.c
  10. 2
      PD_CPS8841H_33W/code/app/src/app_porta.c
  11. 15
      PD_CPS8841H_33W/code/app/src/app_spec.c
  12. 148
      PD_CPS8841H_33W/code/app/src/comm_event.c
  13. 2
      PD_CPS8841H_33W/code/app/src/cps8841h_it.c
  14. 28
      PD_CPS8841H_33W/code/app/src/dpdm_run.c
  15. 40
      PD_CPS8841H_33W/code/app/src/main.c
  16. 92
      PD_CPS8841H_33W/code/app/src/ntc.c
  17. 2
      PD_CPS8841H_33W/code/app/src/porta_detect.c
  18. 1
      PD_CPS8841H_33W/code/component/inc/comp_powerout.h
  19. 5
      PD_CPS8841H_33W/code/component/inc/comp_protection.h
  20. 1
      PD_CPS8841H_33W/code/component/inc/comp_protocol_manager.h
  21. 2
      PD_CPS8841H_33W/code/component/src/comp_dac.c
  22. 17
      PD_CPS8841H_33W/code/component/src/comp_pd_manager.c
  23. 48
      PD_CPS8841H_33W/code/component/src/comp_powerout.c
  24. 40
      PD_CPS8841H_33W/code/component/src/comp_protection.c
  25. 1
      PD_CPS8841H_33W/code/platform/protocol/pd_protocol/inc/pd_send_new_src_cap.h
  26. 41
      PD_CPS8841H_33W/code/platform/protocol/qc_protocol/src/qc_protocol.c
  27. 3
      PD_CPS8841H_33W/code/platform/protocol/scp_protocol/src/scp_protocol.c
  28. 2
      PD_CPS8841H_33W/code/platform/protocol/ufcs_protocol/inc/ufcs_protocol.h
  29. 3
      PD_CPS8841H_33W/code/platform/protocol/ufcs_protocol/src/ufcs_protocol.c
  30. 1
      PD_CPS8841H_33W/code/platform/rom_inc/comp/comp_config.h
  31. 1
      PD_CPS8841H_33W/code/prl_portable/inc/ufcs.h
  32. 9
      PD_CPS8841H_33W/code/prl_portable/src/pd.c
  33. 21
      PD_CPS8841H_33W/code/prl_portable/src/scp.c
  34. 17
      PD_CPS8841H_33W/code/prl_portable/src/ufcs.c
  35. BIN
      功率分配逻辑.eddx

5
.vscode/settings.json

@ -19,6 +19,9 @@
"atomic": "c", "atomic": "c",
"ios": "c", "ios": "c",
"locale": "c", "locale": "c",
"type_traits": "c" "type_traits": "c",
"pd.h": "c",
"comp_gp_mux_pucur.h": "c",
"config.h": "c"
} }
} }

BIN
104RT-3950.xlsx

Binary file not shown.

BIN
2331项目功率分配软件逻辑图 .docx

Binary file not shown.

BIN
A2331 33W 1C1A PRD 外发版 (1).pdf

Binary file not shown.

BIN
NTC温度逻辑.eddx

Binary file not shown.

3
PD_CPS8841H_33W/code/app/inc/comm_event.h

@ -1,6 +1,8 @@
#ifndef __COMM_EVENT_H__ #ifndef __COMM_EVENT_H__
#define __COMM_EVENT_H__ #define __COMM_EVENT_H__
#include "config.h"
typedef enum typedef enum
{ {
PORT_IS_NULL = 0, PORT_IS_NULL = 0,
@ -16,5 +18,6 @@ typedef enum
} e_port_process_status; } e_port_process_status;
void port_status_run(void); void port_status_run(void);
void updata_diff_protocol_cap(uint16_t src_cap_idx, bool send_src_cap);
#endif #endif

48
PD_CPS8841H_33W/code/app/inc/config.h

@ -24,18 +24,6 @@
#define BUCK_FOLLOW_TYPEC_VOLTAGE 1 #define BUCK_FOLLOW_TYPEC_VOLTAGE 1
typedef struct user_app_s
{
uint16_t interrupt_event_1;
uint16_t interrupt_event_2;
bool buck_state;
uint16_t usba_high_current_vol;
uint16_t test_c_ocp_current;
} user_app_s;
extern user_app_s user_app;
/******************log debug***************************/ /******************log debug***************************/
#define UART_DEUG 0 #define UART_DEUG 0
@ -55,6 +43,10 @@ extern user_app_s user_app;
#define FB_FUNC_ENABLE 0 #define FB_FUNC_ENABLE 0
#if !UART_DEUG
#define NTC_ENABLE 0
#endif
#if FB_FUNC_ENABLE #if FB_FUNC_ENABLE
//1:100 0:50 //1:100 0:50
#define FB_CV_GAIN_CHOICE 1 #define FB_CV_GAIN_CHOICE 1
@ -65,7 +57,7 @@ extern user_app_s user_app;
/****************CPS8841H MTP project info*******************/ /****************CPS8841H MTP project info*******************/
#define SOFT_WARE_VERISION_H 0x00 #define SOFT_WARE_VERISION_H 0x00
#define SOFT_WARE_VERISION_L 0x02 #define SOFT_WARE_VERISION_L 0x04
#define CUSTOM_ID 0xc0 #define CUSTOM_ID 0xc0
#define PROJECT_ID 0x41 #define PROJECT_ID 0x41
/**********************param************************************/ /**********************param************************************/
@ -114,13 +106,13 @@ extern user_app_s user_app;
#define QC_SUPPORT 1 #define QC_SUPPORT 1
#if QC_SUPPORT #if QC_SUPPORT
#define QC3P0_SUPPORT 0 #define QC3P0_SUPPORT 1
#endif/**QC_SUPPORT**/ #endif/**QC_SUPPORT**/
#endif/**QC_SCP_SUPPORT**/ #endif/**QC_SCP_SUPPORT**/
#define UFCS_SUPPORT 1 #define UFCS_SUPPORT 0
#if UFCS_SUPPORT #if UFCS_SUPPORT
#define UFCS_DERATE_SUPPORT 1 #define UFCS_DERATE_SUPPORT 1
@ -128,7 +120,7 @@ extern user_app_s user_app;
#define APPLE_MODE_SUPPORT 0 #define APPLE_MODE_SUPPORT 0
#define TFCP_SUPPORT 0 #define TFCP_SUPPORT 0
#define AFC_SUPPORT 1 #define AFC_SUPPORT 0
#define VFCP_SUPPORT 0 #define VFCP_SUPPORT 0
#define PROTECTION_SUPPORT 1 #define PROTECTION_SUPPORT 1
@ -253,7 +245,31 @@ typedef enum
} adp_port_num_e; } adp_port_num_e;
typedef struct user_app_s
{
// uint16_t interrupt_event_1;
// uint16_t interrupt_event_2;
bool buck_state;
// uint16_t test_c_ocp_current;
uint16_t usba_high_current_vol;
uint16_t current_src_cap_idx; // 当前的src_cap档位
#if UFCS_SUPPORT
// rx收到包时间计数, 用于做发power_change间隔, 协议规定收到其他包12ms后才发power_change
volatile uint16_t ufcs_rx_package_cnt;
uint16_t ufcs_need_send_power_change;
#endif
#if NTC_ENABLE
bool ntc_triggered_dera;
bool last_ntc_triggered_dera;
#endif
// 上电后, 需要隔一段时间才能把5.5A电流设回去3.3A, 直接设3.3A的话,满载起机不行
volatile uint16_t first_power_cnt;
} user_app_s;
extern user_app_s user_app;

11
PD_CPS8841H_33W/code/app/inc/ntc.h

@ -1,5 +1,16 @@
#ifndef __NTC_H__ #ifndef __NTC_H__
#define __NTC_H__ #define __NTC_H__
/*
50°: 48.81 * 20uA = 976
100°: 6.744 * 20uA = 135
105°: 5.853 * 20uA = 117
*/
#define NTC_50 976
#define NTC_100 135
#define NTC_105 117
void ntc_init(void); void ntc_init(void);
void ntc_run(void); void ntc_run(void);
#endif #endif

5
PD_CPS8841H_33W/code/app/src/app_periodic_schedule.c

@ -22,6 +22,11 @@ void periodic_work(void)
return; return;
} }
if(user_app.first_power_cnt)
{
user_app.first_power_cnt--;
}
periodic_cnt++; periodic_cnt++;
g_systick_cnt++; g_systick_cnt++;
#if PD_SUPPORT #if PD_SUPPORT

2
PD_CPS8841H_33W/code/app/src/app_porta.c

@ -140,7 +140,7 @@ void usba_ocp_detect(void)
// A + C 同在时 // A + C 同在时
if(typec_is_attched() if(typec_is_attched()
&& !drv_analog_get_usba_detach_sta() && port_a1_is_attached()
) )
{ {
if(trigger_check(usba_adc_sample, if(trigger_check(usba_adc_sample,

15
PD_CPS8841H_33W/code/app/src/app_spec.c

@ -104,16 +104,18 @@ uint8_t system_init(void)
#if ADC_ENABLE #if ADC_ENABLE
comp_adc_init(); comp_adc_init();
// ntc_init(); // RT1当NTC #if NTC_ENABLE
ntc_init(); // RT1当NTC
#endif
log_info("adc_init_pass\n"); // log_info("adc_init_pass\n");
#endif #endif
drv_delay_ms(DELAY_50MS); drv_delay_ms(DELAY_50MS);
#if WATCHDOG_ENABLE #if WATCHDOG_ENABLE
drv_watchdog_init(DELAY_1P5S); drv_watchdog_init(DELAY_1P5S);
log_info("wdt_init_pass\n"); // log_info("wdt_init_pass\n");
#endif #endif
@ -136,7 +138,7 @@ uint8_t system_init(void)
#if PD_SUPPORT #if PD_SUPPORT
pd_mgr_prl_init(ADP_PORT0); pd_mgr_prl_init(ADP_PORT0);
log_info("pd_init_pass\n"); // log_info("pd_init_pass\n");
#endif #endif
#if !FB_FUNC_ENABLE #if !FB_FUNC_ENABLE
@ -150,10 +152,13 @@ uint8_t system_init(void)
#if PROTECTION_SUPPORT #if PROTECTION_SUPPORT
comp_protection_init(); comp_protection_init();
log_info("pro_init_pass\n"); // log_info("pro_init_pass\n");
#endif #endif
drv_delay_ms(DELAY_5MS); drv_delay_ms(DELAY_5MS);
user_app.current_src_cap_idx = SRC_CAP_30W;
user_app.first_power_cnt = DELAY_10S;
return true; return true;
} }

148
PD_CPS8841H_33W/code/app/src/comm_event.c

@ -6,6 +6,71 @@
#include "comp_protocol_manager.h" #include "comp_protocol_manager.h"
#include "comp_sample_volt_cur_report.h" #include "comp_sample_volt_cur_report.h"
#include "pd.h" #include "pd.h"
#include "ufcs.h"
#include "app_porta.h"
#if UFCS_DERATE_SUPPORT
void ufcs_power_change_patch(uint16_t src_cap_idx)
{
const ufcs_power_change_capabilities_u *power_change;
// 为了避免撞包问题, 按协议规定12ms内没收到包才发power_change
if(user_app.ufcs_need_send_power_change
&& user_app.ufcs_rx_package_cnt == 0)
{
log_info("ufcs_derate_idx:%d\n", src_cap_idx);
user_app.ufcs_need_send_power_change = false;
power_change = &DEF_POWER_CHANGE_PDO[src_cap_idx];
dpdm_mgr_ufcs_send_power_change(power_change);
}
}
#endif
// 参数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);
if(send_src_cap)
{
pd_restart_send_src_cap(&g_pd_port);
}
break;
case PROTOCOL_SCP:
break;
#if UFCS_DERATE_SUPPORT
case PROTOCOL_UFCS:
// 为了避免撞包问题, 按协议规定12ms内没收到包才发power_change
user_app.ufcs_need_send_power_change = true;
break;
#endif
}
}
// 端口状态机 // 端口状态机
void port_status_run(void) void port_status_run(void)
@ -15,8 +80,6 @@ void port_status_run(void)
static e_port_status port_status = PORT_IS_NULL; static e_port_status port_status = PORT_IS_NULL;
static e_port_status last_port_status = PORT_IS_NULL; static e_port_status last_port_status = PORT_IS_NULL;
static e_port_process_status port_process_status = port_enter_status; static e_port_process_status port_process_status = port_enter_status;
uint16_t set_current = CURRENT_5A;
typec_status = typec_is_attched(); typec_status = typec_is_attched();
usba_status = port_a1_is_attached(); usba_status = port_a1_is_attached();
@ -49,6 +112,20 @@ void port_status_run(void)
if(port_process_status == port_enter_status) if(port_process_status == port_enter_status)
{ {
port_process_status = port_exit_status; port_process_status = port_exit_status;
#if NTC_ENABLE
if(user_app.ntc_triggered_dera)
{
user_app.current_src_cap_idx = SRC_CAP_7W;
}
else
{
user_app.current_src_cap_idx = SRC_CAP_30W;
}
#else
user_app.current_src_cap_idx = SRC_CAP_30W;
#endif
// 什么都没接时, 也是用buck给A口供电来检查A口是否插入 // 什么都没接时, 也是用buck给A口供电来检查A口是否插入
buck_control(true); buck_control(true);
@ -65,13 +142,6 @@ void port_status_run(void)
if(port_process_status == port_enter_status) if(port_process_status == port_enter_status)
{ {
port_process_status = port_exit_status; port_process_status = port_exit_status;
if(g_pd_port.pd_new_src_pdo != SRC_CAP_30W)
{
pd_dpm_update_source_cap(&g_pd_port, &g_pd_port.pd_curr_config->src_cap_info[SRC_CAP_30W], SRC_CAP_30W);
pd_restart_send_src_cap(&g_pd_port);
}
// 单C口时, 常开buck, 关闭gateA, 等A口有拉电流才反过来 // 单C口时, 常开buck, 关闭gateA, 等A口有拉电流才反过来
buck_control(true); buck_control(true);
dpdm_power_a1_gate_enable(false); dpdm_power_a1_gate_enable(false);
@ -81,6 +151,26 @@ void port_status_run(void)
} }
#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_30W)
{
updata_diff_protocol_cap(SRC_CAP_30W, true);
}
#else
if(user_app.current_src_cap_idx != SRC_CAP_30W)
{
updata_diff_protocol_cap(SRC_CAP_30W, true);
}
#endif
break; break;
case SINGLE_USBA_INSER: case SINGLE_USBA_INSER:
@ -104,23 +194,14 @@ void port_status_run(void)
{ {
port_process_status = port_exit_status; port_process_status = port_exit_status;
if(g_pd_port.pd_new_src_pdo != SRC_CAP_20W)
{
pd_dpm_update_source_cap(&g_pd_port, &g_pd_port.pd_curr_config->src_cap_info[SRC_CAP_20W], SRC_CAP_20W);
pd_restart_send_src_cap(&g_pd_port);
}
if(g_powerout_info.set_vol < VOLTAGE_5P5V if(g_powerout_info.set_vol < VOLTAGE_5P5V
&& (get_adp_curr_sample_volt() < VOLTAGE_5P5V)) && (get_adp_curr_sample_volt() < VOLTAGE_5P5V))
{ {
// 加大电流--->开gateA--->关buck // 加大电流--->开gateA--->关buck
// comp_powerout_prl_set_cur(CURRENT_5A);
comp_set_current(&g_powerout_info, CURRENT_5P5A); // 需要立刻设置 comp_set_current(&g_powerout_info, CURRENT_5P5A); // 需要立刻设置
// 是否有可能电流环设置的没那么快, 一打开gateA就被拉挂了? 需要加个延迟等电流环设置完再开A? // 是否有可能电流环设置的没那么快, 一打开gateA就被拉挂了? 需要加个延迟等电流环设置完再开A?
// drv_delay_us(500); // drv_delay_us(500);
// drv_delay_ms(5);
dpdm_power_a1_gate_enable(true); dpdm_power_a1_gate_enable(true);
// drv_delay_ms(2);
buck_control(false); buck_control(false);
} }
else else
@ -143,22 +224,39 @@ void port_status_run(void)
&& (get_adp_curr_sample_volt() < VOLTAGE_5P5V) && (get_adp_curr_sample_volt() < VOLTAGE_5P5V)
&& !REG_ANALOG_GATEA->bf.en) && !REG_ANALOG_GATEA->bf.en)
{ {
// set_current = CURRENT_5A + user_app.usba_high_current_vol;
// if(set_current > CURRENT_6A)
// {
// set_current = CURRENT_6A;
// }
// comp_powerout_prl_set_cur(set_current);
comp_set_current(&g_powerout_info, CURRENT_5P5A); // 需要立刻设置 comp_set_current(&g_powerout_info, CURRENT_5P5A); // 需要立刻设置
dpdm_power_a1_gate_enable(true); dpdm_power_a1_gate_enable(true);
buck_control(false); 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; break;
} }
#if UFCS_DERATE_SUPPORT
ufcs_power_change_patch(user_app.current_src_cap_idx);
#endif
last_port_status = port_status; last_port_status = port_status;
} }

2
PD_CPS8841H_33W/code/app/src/cps8841h_it.c

@ -118,6 +118,8 @@ void PWD_Handler(void)
void UFCS_RX_Handler(void) void UFCS_RX_Handler(void)
{ {
dpdm_mgr_ufcs_rx_handler(0); dpdm_mgr_ufcs_rx_handler(0);
user_app.ufcs_rx_package_cnt = DELAY_12MS;
} }

28
PD_CPS8841H_33W/code/app/src/dpdm_run.c

@ -151,6 +151,12 @@ void dpdm_time_run(void)
scp_prl_timer(&p->scp_port); scp_prl_timer(&p->scp_port);
#if UFCS_SUPPORT #if UFCS_SUPPORT
ufcs_prl_timer(&p->ufcs_port); ufcs_prl_timer(&p->ufcs_port);
if(user_app.ufcs_rx_package_cnt)
{
user_app.ufcs_rx_package_cnt--;
}
#endif #endif
p->time_p++; p->time_p++;
@ -183,7 +189,20 @@ const static sm_state_t *Dpdm_Src_Idle_Run(const sm_state_t *self, void *data)
log_info("dpdm_port:%d\n", p->dpdm_port); log_info("dpdm_port:%d\n", p->dpdm_port);
dpdm_power_set_port(p->dpdm_port); dpdm_power_set_port(p->dpdm_port);
hvdcp_prl_init(&p->bc_port, p->dpdm_port); hvdcp_prl_init(&p->bc_port, p->dpdm_port);
return &g_dpdm_state[DPDM_SRC_STATE_APPLE];
#if NTC_ENABLE
// 若是触发了NTC, 则不走DPDN协议
if(user_app.ntc_triggered_dera)
{
return &g_dpdm_state[DPDM_SRC_STATE_IDLE];
}
else
#endif
{
return &g_dpdm_state[DPDM_SRC_STATE_APPLE];
}
} }
static void Dpdm_Src_Apple_Entry(void *data) static void Dpdm_Src_Apple_Entry(void *data)
@ -281,7 +300,12 @@ const static sm_state_t *Dpdm_Src_Qc_Pre_Run(const sm_state_t *self, void *data)
dpdm_src_state_e dpdm_state = DPDM_SRC_STATE_QC_PRE; dpdm_src_state_e dpdm_state = DPDM_SRC_STATE_QC_PRE;
qc_prl_stack_run(&p->qc_port); qc_prl_stack_run(&p->qc_port);
scp_prl_stack_run(&p->scp_port);
// 客户要求单C时, 不走SCP
if(!typec_is_attched())
{
scp_prl_stack_run(&p->scp_port);
}
#if UFCS_SUPPORT #if UFCS_SUPPORT

40
PD_CPS8841H_33W/code/app/src/main.c

@ -29,7 +29,7 @@
#include "customized.h" #include "customized.h"
#include "comm_event.h" #include "comm_event.h"
user_app_s user_app; user_app_s user_app = {0};
void protocol_pd_work(void) void protocol_pd_work(void)
{ {
@ -50,25 +50,29 @@ void log_output(void)
typec_is_attched(), typec_is_attched(),
COMP_ADC_GET_VIN()); COMP_ADC_GET_VIN());
log_info("src_cap_idx:%d\n", user_app.current_src_cap_idx);
// log_info("power_change:%d package_cnt:%d\n",
// user_app.ufcs_need_send_power_change,
// user_app.ufcs_rx_package_cnt);
// log_info("RT4_DP:%d RT2_VBUS:%d\n", // log_info("RT4_DP:%d RT2_VBUS:%d\n",
// COMP_ADC_GET_RT4_VOL(), // COMP_ADC_GET_RT4_VOL(),
// COMP_ADC_GET_RT2_VOL()); // COMP_ADC_GET_RT2_VOL());
// log_info("RT2_CUR:0x%x\n", REG_ANALOG_PUCUR->bf.io2); // log_info("RT2_CUR:0x%x\n", REG_ANALOG_PUCUR->bf.io2);
log_info("a_cur:%d detached_from_hw:%d\n", // log_info("a_cur:%d detached_from_hw:%d\n",
COMP_ADC_GET_GP1_VOL(), // COMP_ADC_GET_GP1_VOL(),
drv_analog_get_usba_detach_sta()); // drv_analog_get_usba_detach_sta());
// log_info("a_cur:%d GP1:%d\n", // log_info("a_cur:%d GP1:%d\n",
// COMP_ADC_GET_LS_CUR(), // COMP_ADC_GET_LS_CUR(),
// COMP_ADC_GET_GP1_VOL()); // COMP_ADC_GET_GP1_VOL());
// log_info("chip_temp:%d\n", COMP_ADC_GET_CHIP_TEMP_FILTER()); // log_info("c_ocp_set:%d c_cur:%d\n",
// user_app.test_c_ocp_current,
log_info("c_ocp_set:%d c_cur:%d\n", // COMP_ADC_GET_CUR());
user_app.test_c_ocp_current,
COMP_ADC_GET_CUR());
} }
// A口高端检流 // A口高端检流
@ -93,27 +97,15 @@ void comm_event(void)
#endif #endif
port_status_run(); port_status_run();
// // A + C 且 电压 <5.5V时 电流要固定为4A
// if(typec_is_attched()
// && !drv_analog_get_usba_detach_sta()
// && g_powerout_info.set_vol <= VOLTAGE_5P5V
// )
// {
// set_current = CURRENT_4A + user_app.usba_high_current_vol;
// if(set_current > CURRENT_6A)
// {
// set_current = CURRENT_6A;
// }
// comp_powerout_prl_set_cur(set_current);
// }
} }
static const periodic_work_entry_s app_works[] = static const periodic_work_entry_s app_works[] =
{ {
PERIODIC_WORK_ENTRY(1, 0, protocol_pd_work), PERIODIC_WORK_ENTRY(1, 0, protocol_pd_work),
PERIODIC_WORK_ENTRY(1, 0, dpdm_run), PERIODIC_WORK_ENTRY(1, 0, dpdm_run),
// PERIODIC_WORK_ENTRY(1, 0, ntc_run), #if NTC_ENABLE
PERIODIC_WORK_ENTRY(1, 0, ntc_run),
#endif
PERIODIC_WORK_ENTRY(1, 0, comm_event), PERIODIC_WORK_ENTRY(1, 0, comm_event),
PERIODIC_WORK_ENTRY(4, 3, app_port_a1_work), PERIODIC_WORK_ENTRY(4, 3, app_port_a1_work),
PERIODIC_WORK_ENTRY(1024, 0, log_output), PERIODIC_WORK_ENTRY(1024, 0, log_output),

92
PD_CPS8841H_33W/code/app/src/ntc.c

@ -4,47 +4,87 @@
#include "comp_gp_mux_pucur.h" #include "comp_gp_mux_pucur.h"
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "comp_protection.h"
#include "comp_powerout.h"
#include "comp_pd_manager.h"
#include "comm_event.h"
#include "comp_protocol_manager.h"
#include "app_porta.h"
#include "dpdm_run.h"
#define NTC_OFFSET 1156 #if NTC_ENABLE
typedef struct debouncer
void ntc_init(void)
{ {
uint16_t cnt; drv_clkctrl_pin_mul_cfg(RT1, 0);
uint16_t out; rt1_pucur_cfg(RT_20UA);
} debouncer_s; }
static debouncer_s deb;
static bool _debounce(debouncer_s *obj, bool in, uint16_t up_time, uint16_t down_time) // 当前是 1ms 进一次
void ntc_run(void)
{ {
if(in == obj->out) uint16_t ntc_val = 0;
static uint16_t ntc_derat_cnt = 0, ntc_recove_cnt = 0;
ntc_val = COMP_ADC_GET_RT1_VOL();
// 消抖时间的话, 是还需要/5, 比如给200ms, 实际是40ms
if(trigger_check(ntc_val, NTC_100,
true,
&ntc_derat_cnt,
DELAY_100MS)
)
{ {
obj->cnt = obj->out ? down_time : up_time; user_app.ntc_triggered_dera = true;
} }
else if(obj->cnt == 0 || --obj->cnt == 0)
if(trigger_check(ntc_val, NTC_50,
false,
&ntc_recove_cnt,
DELAY_100MS)
)
{ {
obj->out = in; user_app.ntc_triggered_dera = false;
obj->cnt = obj->out ? down_time : up_time;
} }
return obj->out; if(user_app.last_ntc_triggered_dera == user_app.ntc_triggered_dera)
} {
return;
}
void ntc_init(void) user_app.last_ntc_triggered_dera = user_app.ntc_triggered_dera;
{
drv_clkctrl_pin_mul_cfg(RT1, 0);
rt1_pucur_cfg(RT_100UA);
}
void ntc_run(void) // 触发NTC时, 双口都要回到5V, 并且DPDN要短接起来
{ if(user_app.ntc_triggered_dera)
uint16_t adc_value = 0; {
adc_value = COMP_ADC_GET_RT1_VOL(); dpdm_reset();
uint8_t out = 0; drv_dpdn_short_set(true);
out = _debounce(&deb, adc_value <= NTC_OFFSET, 1000, 100); drv_dpdn1_short_set(true);
if(out) // 走PD时让 设备自己降。 走其他协议时, 主动降。
// 如果没走PD,还需要考虑纯typeC状态,要把CC设到 1.5A 的电流广播值
if(dpdm_power_get_next_protocol() == PROTOCOL_PD_FIX
|| dpdm_power_get_next_protocol() == PROTOCOL_PD_PPS)
{
// 复位协议,屏蔽PD协议, DPDN恢复短接, 电压要降回5V
if(user_app.current_src_cap_idx != SRC_CAP_7W)
{
updata_diff_protocol_cap(SRC_CAP_7W, true);
}
}
else
{
comp_powerout_prl_set_viout(VOLTAGE_5V, CURRENT_3A);
}
}
else
{ {
// 温度恢复后, 重启下, 不然手机不会重新走协议
NVIC_SystemReset(); NVIC_SystemReset();
} }
} }
#endif

2
PD_CPS8841H_33W/code/app/src/porta_detect.c

@ -78,7 +78,7 @@ void usba_plugin_detect_init(uint8_t level)
USBA_DETACH_WIDTH_75MS)); USBA_DETACH_WIDTH_75MS));
// 配置完小电流寄存器后要等生效 // 配置完小电流寄存器后要等生效
drv_delay_ms(100); drv_delay_ms(200);
// log_info("usba_plugin_detect_init\n"); // log_info("usba_plugin_detect_init\n");
} }

1
PD_CPS8841H_33W/code/component/inc/comp_powerout.h

@ -376,6 +376,7 @@ void comp_powerout_prl_set_volt(uint16_t vout);
void comp_powerout_prl_set_cur(uint16_t cur); void comp_powerout_prl_set_cur(uint16_t cur);
void comp_powerout_prl_set_viout(uint16_t vout, uint16_t iout); void comp_powerout_prl_set_viout(uint16_t vout, uint16_t iout);
void comp_set_current(comp_powerout_info_s *powerout_info, uint16_t current); void comp_set_current(comp_powerout_info_s *powerout_info, uint16_t current);
void comp_set_voltage(comp_powerout_info_s *powerout_info, uint16_t voltage);
#endif #endif

5
PD_CPS8841H_33W/code/component/inc/comp_protection.h

@ -15,6 +15,7 @@
#include "config.h" #include "config.h"
#include "drv_dac.h" #include "drv_dac.h"
#include "comp_adc.h" #include "comp_adc.h"
#include "ntc.h"
#define VIN_UVP_ENABLE 0x0001 #define VIN_UVP_ENABLE 0x0001
#define DP_WET_ENABLE 0x0002 #define DP_WET_ENABLE 0x0002
@ -40,8 +41,8 @@
#define DN_OVP_VPT 4000 #define DN_OVP_VPT 4000
#define DP_OVP_VPT DN_OVP_VPT #define DP_OVP_VPT DN_OVP_VPT
#define NTC_OTP_VPT 393/*393mV---110C*/ #define NTC_OTP_VPT NTC_105
#define NTC_OTP_RECOVER_VPT 1056/*1056mV---80C*/ #define NTC_OTP_RECOVER_VPT NTC_50
#define NTC_OTP_DERATE 1954 #define NTC_OTP_DERATE 1954

1
PD_CPS8841H_33W/code/component/inc/comp_protocol_manager.h

@ -14,6 +14,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "config.h"
static bool buck_state; static bool buck_state;

2
PD_CPS8841H_33W/code/component/src/comp_dac.c

@ -26,7 +26,7 @@ const dac_cv_cfg_info_s DAC_CV_CONFIG =
const dac_cc_cfg_info_s DAC_CC_CONFIG = const dac_cc_cfg_info_s DAC_CC_CONFIG =
{ {
.target = DECL_DAC_CC_TARGET(CURRENT_3A), .target = DECL_DAC_CC_TARGET(CURRENT_5P5A),
.slewrate = 0x00, .slewrate = 0x00,
.enable = true .enable = true
}; };

17
PD_CPS8841H_33W/code/component/src/comp_pd_manager.c

@ -6,14 +6,14 @@ const pd_pdo_info_s PD_DEFAULT_CAP_INFO[] =
{ {
{ {
.pdo_cnt = 6, .pdo_cnt = 5,
.src_pdp = 33, .src_pdp = 33,
.pdo0 = PD_SRC_FPS_PDO(VOLTAGE_5V, CURRENT_3A, PD_SRC_FPS_FLAGS), .pdo0 = PD_SRC_FPS_PDO(VOLTAGE_5V, CURRENT_3A, PD_SRC_FPS_FLAGS),
.pdo1 = PD_SRC_FPS_PDO(VOLTAGE_9V, CURRENT_3A, 0), .pdo1 = PD_SRC_FPS_PDO(VOLTAGE_9V, CURRENT_3A, 0),
.pdo2 = PD_SRC_FPS_PDO(VOLTAGE_15V, CURRENT_2P2A, 0), .pdo2 = PD_SRC_FPS_PDO(VOLTAGE_15V, CURRENT_2P2A, 0),
.pdo3 = PD_SRC_FPS_PDO(VOLTAGE_20V, CURRENT_1P65A, 0), .pdo3 = PD_SRC_FPS_PDO(VOLTAGE_20V, CURRENT_1P65A, 0),
.pdo4 = PD_SRC_PPS_PDO(VOLTAGE_3P3V, VOLTAGE_11V, CURRENT_3A, true), .pdo4 = PD_SRC_PPS_PDO(VOLTAGE_5V, VOLTAGE_11V, CURRENT_3A, true),
.pdo5 = PD_SRC_PPS_PDO(VOLTAGE_3P3V, VOLTAGE_16V, CURRENT_2A, true), .pdo5 = 0, //PD_SRC_PPS_PDO(VOLTAGE_3P3V, VOLTAGE_16V, CURRENT_2A, true),
.pdo6 = 0, .pdo6 = 0,
}, },
@ -29,6 +29,17 @@ const pd_pdo_info_s PD_DEFAULT_CAP_INFO[] =
.pdo6 = 0, .pdo6 = 0,
}, },
{
.pdo_cnt = 1,
.src_pdp = 7,
.pdo0 = PD_SRC_FPS_PDO(VOLTAGE_5V, CURRENT_1P5A, PD_SRC_FPS_FLAGS),
.pdo1 = 0,
.pdo2 = 0,
.pdo3 = 0,
.pdo4 = 0,
.pdo5 = 0,
.pdo6 = 0,
},
}; };
const pd_config_init_s PD_INIT_CONFIG[] = const pd_config_init_s PD_INIT_CONFIG[] =

48
PD_CPS8841H_33W/code/component/src/comp_powerout.c

@ -59,11 +59,11 @@ const f_powerout_state_machine_action powerout_actions[] =
* @note * @note
* @retval * @retval
*/ */
static void comp_powerout_default_set(comp_powerout_info_s *powerout_info) void comp_powerout_default_set(comp_powerout_info_s *powerout_info)
{ {
pwr_request_s pwr_request = pwr_request_s pwr_request =
{ {
.request_cur = CURRENT_3P4A, .request_cur = CURRENT_5P5A,
.request_vol = VOLTAGE_5V, .request_vol = VOLTAGE_5V,
}; };
@ -85,6 +85,13 @@ void comp_set_current(comp_powerout_info_s *powerout_info, uint16_t current)
comp_powerout_cur_set(powerout_info, powerout_info->set_current); comp_powerout_cur_set(powerout_info, powerout_info->set_current);
} }
void comp_set_voltage(comp_powerout_info_s *powerout_info, uint16_t voltage)
{
powerout_info->set_vol = voltage;
powerout_info->prl_update_vol = voltage;
comp_powerout_vol_set(powerout_info, powerout_info->set_vol);
}
/* /*
* @brief powerout init * @brief powerout init
* @param powerout_info * @param powerout_info
@ -195,6 +202,8 @@ void comp_powerout_shutdown_machine(comp_powerout_info_s *powerout_info)
{ {
log_info("pwr_shut\n"); log_info("pwr_shut\n");
comp_powerout_default_set(powerout_info); comp_powerout_default_set(powerout_info);
// comp_powerout_prl_set_viout(VOLTAGE_5V, CURRENT_3P3A);
powerout_info->power_state = PWR_RDY_CHECK; powerout_info->power_state = PWR_RDY_CHECK;
} }
@ -342,6 +351,41 @@ void comp_powerout_ready_machine(comp_powerout_info_s *powerout_info)
pwr_request.request_cur = CURRENT_5P5A; pwr_request.request_cur = CURRENT_5P5A;
} }
// 因为初始要考虑A+C同时拉载的情况下上电,所以初始要设置5.5A电流,但是后续需要把电流设回正常值
// 单C口且无协议时,电流设回正常的 3.3A
// 单A口且无协议时,电流设回正常的 3.3A
// 这个后续的时间暂时定为2秒
if(user_app.first_power_cnt == 0)
{
if(typec_is_attched()
&& !port_a1_is_attached()
)
{
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)
{
pwr_request.request_cur = CURRENT_3P3A;
}
}
if(!typec_is_attched()
&& port_a1_is_attached()
//&& (pwr_request.request_vol <= VOLTAGE_5P5V)
)
{
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)
{
pwr_request.request_cur = CURRENT_3P3A;
}
}
}
if((powerout_info->last_vol != pwr_request.request_vol) || if((powerout_info->last_vol != pwr_request.request_vol) ||
(powerout_info->last_current != pwr_request.request_cur) || (powerout_info->last_current != pwr_request.request_cur) ||
(powerout_info->powerout_flags.bf.real_vol_restore) (powerout_info->powerout_flags.bf.real_vol_restore)

40
PD_CPS8841H_33W/code/component/src/comp_protection.c

@ -120,7 +120,11 @@ void comp_protection_init(void)
#endif #endif
#if !UART_DEUG #if !UART_DEUG
g_protection_param.protection_enable |= VIN_UVP_ENABLE | VIN_OCP_ENABLE;// | DPDN_WET_ENABLE; //| PORT_OTP_ENABLE; #if NTC_ENABLE
g_protection_param.protection_enable |= VIN_UVP_ENABLE | VIN_OCP_ENABLE | PORT_OTP_ENABLE;// | DPDN_WET_ENABLE; //| PORT_OTP_ENABLE;
#else
g_protection_param.protection_enable |= VIN_UVP_ENABLE | VIN_OCP_ENABLE;
#endif
#else #else
g_protection_param.protection_enable |= VIN_UVP_ENABLE | VIN_OCP_ENABLE;// | DPDN_WET_ENABLE; g_protection_param.protection_enable |= VIN_UVP_ENABLE | VIN_OCP_ENABLE;// | DPDN_WET_ENABLE;
#endif #endif
@ -251,18 +255,18 @@ void comp_protection_monitor(protection_param_s *protection_param)
} }
pro_vpt[PROT_OCP] = CURRENT_3P3A + user_app.usba_high_current_vol; pro_vpt[PROT_OCP] = CURRENT_3P3A + user_app.usba_high_current_vol;
user_app.test_c_ocp_current = pro_vpt[PROT_OCP]; // user_app.test_c_ocp_current = pro_vpt[PROT_OCP];
if(protection_param->otp_derate) // if(protection_param->otp_derate)
{ // {
pro_vpt[PROT_DERATE] = NTC_OTP_RECOVER; // pro_vpt[PROT_DERATE] = NTC_OTP_RECOVER;
pro_aspect[PROT_DERATE] = 0; // pro_aspect[PROT_DERATE] = 0;
} // }
else // else
{ // {
pro_vpt[PROT_DERATE] = NTC_OTP_DERATE; // pro_vpt[PROT_DERATE] = NTC_OTP_DERATE;
pro_aspect[PROT_DERATE] = 1; // pro_aspect[PROT_DERATE] = 1;
} // }
for(index = 0; index < PRO_CNT; index++) for(index = 0; index < PRO_CNT; index++)
@ -274,13 +278,13 @@ void comp_protection_monitor(protection_param_s *protection_param)
// log_info("protection_enable:%d\n", protection_param->protection_enable); // log_info("protection_enable:%d\n", protection_param->protection_enable);
log_info("pro_st:%d,%d\n", index, adc_sample[index]); log_info("pro_st:%d,%d\n", index, adc_sample[index]);
if(index == PROT_DERATE) // if(index == PROT_DERATE)
{ // {
protection_param->otp_derate = !protection_param->otp_derate; // protection_param->otp_derate = !protection_param->otp_derate;
log_info("derate:%d\n", protection_param->otp_derate); // log_info("derate:%d\n", protection_param->otp_derate);
} // }
else // else
{ {
#if UFCS_SUPPORT #if UFCS_SUPPORT

1
PD_CPS8841H_33W/code/platform/protocol/pd_protocol/inc/pd_send_new_src_cap.h

@ -6,6 +6,7 @@
#define SRC_CAP_30W 0 #define SRC_CAP_30W 0
#define SRC_CAP_20W 1 #define SRC_CAP_20W 1
#define SRC_CAP_7W 2
void pd_new_src_cap_update_work(pd_port_s *pd_port); void pd_new_src_cap_update_work(pd_port_s *pd_port);
void pd_dpm_update_source_cap(pd_port_s *pd_port, const pd_pdo_info_s *pdo, uint8_t src_cap_idx); void pd_dpm_update_source_cap(pd_port_s *pd_port, const pd_pdo_info_s *pdo, uint8_t src_cap_idx);

41
PD_CPS8841H_33W/code/platform/protocol/qc_protocol/src/qc_protocol.c

@ -60,50 +60,31 @@ void qc_voltage_request_work(qc_port_s *qc_port)
{ {
iset = CURRENT_3P3A; iset = CURRENT_3P3A;
// A + C 且都在5V时, 在powerout里会把电流设为5.5A // A + C 且都在5V时, 在powerout里会把电流设为5.5A
}
else if(qc_param->qc_assist.request_vol == 9000)
{
iset = CURRENT_3P3A;
if(port_a1_is_attached() && typec_is_attched())
{
iset = CURRENT_2P3A;
}
// 仅测试,单A口时,实际设置3.3A能出4A
// if(!typec_is_attched() && port_a1_is_attached())
// {
// iset = CURRENT_3P3A - 400;
// }
} }
else if(qc_param->qc_assist.request_vol == 12000) else if(qc_param->qc_assist.request_vol == 9000)
{ {
iset = CURRENT_2P8A; iset = CURRENT_2P3A;
if(port_a1_is_attached() && typec_is_attched())
{
iset = CURRENT_1P8A;
}
} }
else if(qc_param->qc_assist.request_vol >= 20000) else if(qc_param->qc_assist.request_vol >= 12000)
{ {
qc_param->qc_assist.request_vol = 20000; qc_param->qc_assist.request_vol = 12000;
iset = CURRENT_1P8A; iset = CURRENT_1P8A;
if(port_a1_is_attached() && typec_is_attched())
{
qc_param->qc_assist.request_vol = 12000;
iset = CURRENT_1P8A;
}
} }
else if(qc_param->qc_assist.request_vol <= 5000) else if(qc_param->qc_assist.request_vol <= 5000)
{ {
qc_param->qc_assist.request_vol = 5000; qc_param->qc_assist.request_vol = 5000;
iset = CURRENT_3P4A; iset = CURRENT_3P3A;
} }
if(qc_param->qc_assist.contionous_mode_state) if(qc_param->qc_assist.contionous_mode_state)
{ {
iset = CURRENT_3P4A; // iset = CURRENT_3P4A;
if(port_a1_is_attached() && typec_is_attched())
{
iset = CURRENT_2P3A;
}
set_cable_comp_enable(false); set_cable_comp_enable(false);
} }

3
PD_CPS8841H_33W/code/platform/protocol/scp_protocol/src/scp_protocol.c

@ -32,6 +32,9 @@ static void scp_register_attr_upgrade(scp_param_s *scp_param)
//0xce reg should nck for typec(22.5w) //0xce reg should nck for typec(22.5w)
scp_param->scp_prl_passist.register_attribute[SCP_S_FUN_1 >> 1] = REG_ATTR_MRW << 4 | REG_ATTR_RESV; scp_param->scp_prl_passist.register_attribute[SCP_S_FUN_1 >> 1] = REG_ATTR_MRW << 4 | REG_ATTR_RESV;
// 0x00~0x7b 全都屏蔽
// 2个寄存器用一个字节
memset(scp_param->scp_prl_passist.register_attribute, REG_ATTR_RESV, 0x3e);
} }

2
PD_CPS8841H_33W/code/platform/protocol/ufcs_protocol/inc/ufcs_protocol.h

@ -140,7 +140,7 @@ typedef struct ufcs_port_s
uint8_t port_num; uint8_t port_num;
uint8_t current_cap_gear; // 뎠품도貫 // uint8_t current_cap_gear;
} ufcs_port_s; } ufcs_port_s;

3
PD_CPS8841H_33W/code/platform/protocol/ufcs_protocol/src/ufcs_protocol.c

@ -16,6 +16,8 @@
#include "comp_sample_volt_cur_report.h" #include "comp_sample_volt_cur_report.h"
#include "comp_temp_report.h" #include "comp_temp_report.h"
#if UFCS_SUPPORT
/* /*
* @brief drv_dpdn1_short_staus_get * @brief drv_dpdn1_short_staus_get
* @param null * @param null
@ -255,3 +257,4 @@ void ufcs_prl_enable_ufcs(ufcs_port_s *ufcs_port, uint8_t en)
} }
#endif

1
PD_CPS8841H_33W/code/platform/rom_inc/comp/comp_config.h

@ -193,6 +193,7 @@
#define DELAY_6MS 6 #define DELAY_6MS 6
#define DELAY_7MS 7 #define DELAY_7MS 7
#define DELAY_10MS 10 #define DELAY_10MS 10
#define DELAY_12MS 12
#define DELAY_20MS 20 #define DELAY_20MS 20
#define DELAY_30MS 30 #define DELAY_30MS 30
#define DELAY_38MS 38 #define DELAY_38MS 38

1
PD_CPS8841H_33W/code/prl_portable/inc/ufcs.h

@ -72,5 +72,6 @@ static inline void ufcs_port_tx_handler(ufcs_port_s *ufcs_port)
void dpdm_mgr_ufcs_send_power_change(const ufcs_power_change_capabilities_u *new_power_change); void dpdm_mgr_ufcs_send_power_change(const ufcs_power_change_capabilities_u *new_power_change);
extern const ufcs_config_init_s UFCS_INIT_CONFIG[PORT_TYPE_DUAL_PORT]; extern const ufcs_config_init_s UFCS_INIT_CONFIG[PORT_TYPE_DUAL_PORT];
extern const ufcs_power_change_capabilities_u DEF_POWER_CHANGE_PDO[];
#endif #endif

9
PD_CPS8841H_33W/code/prl_portable/src/pd.c

@ -116,14 +116,7 @@ bool app_src_power_handler_patch(pd_param_s *pd_param)
if(request_type == PD_PDO_TYPE_FIXED) if(request_type == PD_PDO_TYPE_FIXED)
{ {
if(request_vol == VOLTAGE_20V) offest = CURRENT_0P3A;
{
offest = CURRENT_0P35A;
}
else
{
offest = CURRENT_0P4A;
}
set_cable_comp_enable(true); set_cable_comp_enable(true);
dpdm_power_set_next_protocol(PROTOCOL_PD_FIX); dpdm_power_set_next_protocol(PROTOCOL_PD_FIX);

21
PD_CPS8841H_33W/code/prl_portable/src/scp.c

@ -177,7 +177,7 @@ const uint8_t PORT0_A_SCP_REGISTER_VALUE[256] =
DECL_REG(0x7b, 0), DECL_REG(0x7b, 0),
DECL_REG(SCP_COMPILEDVER_H, SOFT_WARE_VERISION_H), DECL_REG(SCP_COMPILEDVER_H, SOFT_WARE_VERISION_H),
DECL_REG(SCP_COMPILEDVER_L, SOFT_WARE_VERISION_L), DECL_REG(SCP_COMPILEDVER_L, SOFT_WARE_VERISION_L),
DECL_REG(SCP_ADP_TYPE0, 0xbc), DECL_REG(SCP_ADP_TYPE0, 0x9c), // bit5是代表是否A类适配器 0xbc
DECL_REG(0x7f, 0), DECL_REG(0x7f, 0),
DECL_REG(SCP_ADP_TYPE1, 0x90), DECL_REG(SCP_ADP_TYPE1, 0x90),
DECL_REG(SCP_B_ADP_TYPE, SCP_B_ADP_TYPE_STD_B), DECL_REG(SCP_B_ADP_TYPE, SCP_B_ADP_TYPE_STD_B),
@ -198,7 +198,7 @@ const uint8_t PORT0_A_SCP_REGISTER_VALUE[256] =
DECL_REG(SCP_MAX_PWR, SCP_MAX_PWR_VAL(1, 22)), DECL_REG(SCP_MAX_PWR, SCP_MAX_PWR_VAL(1, 22)),
DECL_REG(SCP_CNT_PWR, SCP_MAX_PWR_VAL(1, 22)), DECL_REG(SCP_CNT_PWR, SCP_MAX_PWR_VAL(1, 22)),
DECL_REG(SCP_MIN_VOUT, SCP_VI_RANGE_VAL(2, 55)), DECL_REG(SCP_MIN_VOUT, SCP_VI_RANGE_VAL(2, 55)),
DECL_REG(SCP_MAX_VOUT, SCP_VI_RANGE_VAL(3, 11)), DECL_REG(SCP_MAX_VOUT, SCP_VI_RANGE_VAL(3, 10)),
DECL_REG(SCP_MIN_IOUT, SCP_VI_RANGE_VAL(1, 30)), DECL_REG(SCP_MIN_IOUT, SCP_VI_RANGE_VAL(1, 30)),
DECL_REG(SCP_MAX_IOUT, SCP_VI_RANGE_VAL(2, 22)), DECL_REG(SCP_MAX_IOUT, SCP_VI_RANGE_VAL(2, 22)),
DECL_REG(SCP_VSTEP, 0x14), DECL_REG(SCP_VSTEP, 0x14),
@ -261,13 +261,13 @@ const uint8_t PORT0_A_SCP_REGISTER_VALUE[256] =
DECL_REG(SCP_S_FUN_1, 0), DECL_REG(SCP_S_FUN_1, 0),
DECL_REG(SCP_S_FUN_2, 0x00), DECL_REG(SCP_S_FUN_2, 0x00),
DECL_REG(SCP_PWR_VOUT_SEG(1), 0x12), DECL_REG(SCP_PWR_VOUT_SEG(1), 0x12),
DECL_REG(SCP_PWR_IOUT_SEG(1), 0x1b), DECL_REG(SCP_PWR_IOUT_SEG(1), 0x19),
DECL_REG(SCP_PWR_VOUT_SEG(2), 0x14), DECL_REG(SCP_PWR_VOUT_SEG(2), 0x14),
DECL_REG(SCP_PWR_IOUT_SEG(2), 0x18), DECL_REG(SCP_PWR_IOUT_SEG(2), 0x16),
DECL_REG(SCP_PWR_VOUT_SEG(3), 0x15), DECL_REG(SCP_PWR_VOUT_SEG(3), 0x15),
DECL_REG(SCP_PWR_IOUT_SEG(3), 0x16), DECL_REG(SCP_PWR_IOUT_SEG(3), 0x14),
DECL_REG(SCP_PWR_VOUT_SEG(4), 0x18), DECL_REG(SCP_PWR_VOUT_SEG(4), 0x18),
DECL_REG(SCP_PWR_IOUT_SEG(4), 0x11), DECL_REG(SCP_PWR_IOUT_SEG(4), 0x0f),
DECL_REG(SCP_PWR_VOUT_SEG(5), 0), DECL_REG(SCP_PWR_VOUT_SEG(5), 0),
DECL_REG(SCP_PWR_IOUT_SEG(5), 0), DECL_REG(SCP_PWR_IOUT_SEG(5), 0),
DECL_REG(SCP_PWR_VOUT_SEG(6), 0), DECL_REG(SCP_PWR_VOUT_SEG(6), 0),
@ -388,7 +388,9 @@ void capabiloties_features(scp_prl_s *scp_prl_passist)
void scp_afc_identify(scp_param_s *scp_param) void scp_afc_identify(scp_param_s *scp_param)
{ {
#if AFC_SUPPORT
afc_port_prl_request(); afc_port_prl_request();
#endif
} }
@ -432,7 +434,12 @@ void scp_port_init(scp_port_s *scp_port)
scp_port->scp_prl_param.scp_prl_passist.scp_phy_callback = &mtp_scp_phy_callback_func; scp_port->scp_prl_param.scp_prl_passist.scp_phy_callback = &mtp_scp_phy_callback_func;
g_scp_a0_bit5_reset = false; g_scp_a0_bit5_reset = false;
scp_prl_enable_scp(scp_port, true);
// 客户要求单C时, 不走SCP
if(!typec_is_attched())
{
scp_prl_enable_scp(scp_port, true);
}
} }

17
PD_CPS8841H_33W/code/prl_portable/src/ufcs.c

@ -8,6 +8,7 @@
// ufcs_port_s g_ufcs_port; // ufcs_port_s g_ufcs_port;
#if UFCS_SUPPORT
static void ufcs_handshake_ping_callback_patch(ufcs_param_s *ufcs_param); static void ufcs_handshake_ping_callback_patch(ufcs_param_s *ufcs_param);
static void ufcs_src_volt_test_func(u_test_req *test_req); static void ufcs_src_volt_test_func(u_test_req *test_req);
@ -56,7 +57,7 @@ static const ufcs_phy_callback_s mtp_ufcs_phy_callback_func =
.send_ufcs_pkt = mtp_send_ufcs_pkt .send_ufcs_pkt = mtp_send_ufcs_pkt
}; };
#if UFCS_SUPPORT
/*********************UFCS************************************/ /*********************UFCS************************************/
#define SCP_RS82 0x00 #define SCP_RS82 0x00
@ -175,8 +176,6 @@ const ufcs_config_init_s UFCS_INIT_CONFIG[PORT_TYPE_DUAL_PORT] =
}; };
#endif
extern uint8_t g_ufcs_curr_tx_len; extern uint8_t g_ufcs_curr_tx_len;
@ -305,7 +304,6 @@ static void curr_expcode(error_info_u *error_info)
*/ */
static void ufcs_src_volt_test_func(u_test_req *test_req) static void ufcs_src_volt_test_func(u_test_req *test_req)
{ {
#if UFCS_SUPPORT
uint16_t volt_test_mode; uint16_t volt_test_mode;
uint16_t iset; uint16_t iset;
@ -328,7 +326,6 @@ static void ufcs_src_volt_test_func(u_test_req *test_req)
// prl_mgr_set_curr_cur(iset); // prl_mgr_set_curr_cur(iset);
comp_powerout_prl_set_cur(iset); comp_powerout_prl_set_cur(iset);
#endif
} }
@ -353,7 +350,9 @@ static uint8_t ufcs_src_power_change_msg_assemble(ufcs_param_s *ufcs_param)
ufcs_param->ufcs_assist.ufcs_sent_pkt.ufcs_sent_buf[4] = power_change_len; ufcs_param->ufcs_assist.ufcs_sent_pkt.ufcs_sent_buf[4] = power_change_len;
// 更新power_chang
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.power_change_cap[0].byte, &ufcs_port->ufcs_new_power_change_cur->byte, power_change_len);
// 更新到发送buff里
memcpy(&ufcs_param->ufcs_assist.ufcs_sent_pkt.ufcs_sent_buf[5], ufcs_param->ufcs_assist.power_change_cap[0].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; power_change_len += 5;
@ -388,9 +387,9 @@ void ufcs_port_init(ufcs_port_s *ufcs_port)
ufcs_port->ufcs_prl_param.ufcs_phy_callback = &mtp_ufcs_phy_callback_func; ufcs_port->ufcs_prl_param.ufcs_phy_callback = &mtp_ufcs_phy_callback_func;
dpdn_mgr_enable_dpdn_prl(true); dpdn_mgr_enable_dpdn_prl(true);
#if UFCS_DERATE_SUPPORT // #if UFCS_DERATE_SUPPORT
ufcs_port->current_cap_gear = UFCS_CAP_30W; // ufcs_port->current_cap_gear = UFCS_CAP_30W;
#endif // #endif
// Çå³ý½á¹¹ÌåµÈ // Çå³ý½á¹¹ÌåµÈ
ufcs_protocol_reset(&ufcs_port->ufcs_prl_param); ufcs_protocol_reset(&ufcs_port->ufcs_prl_param);
@ -440,3 +439,5 @@ void dpdm_mgr_ufcs_send_power_change(const ufcs_power_change_capabilities_u *new
ufcs_port->ufcs_new_power_change_cur = 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; ufcs_port->ufcs_send_power_change_en = !ufcs_port->ufcs_send_power_change_en;
} }
#endif

BIN
功率分配逻辑.eddx

Binary file not shown.
Loading…
Cancel
Save