|
|
@ -16,7 +16,7 @@ |
|
|
|
#include "ufcs_protocol.h" |
|
|
|
#include "ufcs.h" |
|
|
|
#include "comp_gpio.h" |
|
|
|
|
|
|
|
#include "comp_protection.h" |
|
|
|
|
|
|
|
static uint16_t dp_power_down_discern(scp_port_s *scp_port); |
|
|
|
|
|
|
@ -127,10 +127,9 @@ void buck_init(void) |
|
|
|
{ |
|
|
|
// RT4当dcdc使能引脚 buck是低电平使能
|
|
|
|
REG_CLKCTRL_PIN_MUL_SET->bf.gp2 = 3; |
|
|
|
drv_gpio_pull_up_resistor_en(GP2, 1); |
|
|
|
drv_gpio_enable_out(GPIO_PIN2); |
|
|
|
REG_ANALOG_GP->bf.aie |= (1 << GPIO_PIN2); |
|
|
|
drv_gpio_write(GPIO_PIN2, true); // 初始先关闭
|
|
|
|
REG_ANALOG_GP->bf.oden |= (1 << GPIO_PIN2); |
|
|
|
drv_gpio_write(GPIO_PIN2, false); // 初始先打开. 低电平是打开
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -168,6 +167,11 @@ void dpdm_time_run(void) |
|
|
|
|
|
|
|
void dpdm_run(void) |
|
|
|
{ |
|
|
|
if(g_protection_param.protection_flag) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
dpdm_t *p = (dpdm_t *)&g_dpdm; |
|
|
|
state_machine_run(&p->sm); |
|
|
|
} |
|
|
@ -184,15 +188,11 @@ static void Dpdm_Src_Idle_Entry(void *data) |
|
|
|
|
|
|
|
const static sm_state_t *Dpdm_Src_Idle_Run(const sm_state_t *self, void *data) |
|
|
|
{ |
|
|
|
dpdm_t *p = (dpdm_t *)data; |
|
|
|
p->dpdm_port = typec_is_attched() ? 0 : 1; |
|
|
|
log_info("dpdm_port:%d\n", p->dpdm_port); |
|
|
|
dpdm_power_set_port(p->dpdm_port); |
|
|
|
hvdcp_prl_init(&p->bc_port, p->dpdm_port); |
|
|
|
|
|
|
|
#if NTC_ENABLE |
|
|
|
|
|
|
|
// 若是触发了NTC, 则不走DPDN协议
|
|
|
|
// 若是触发了NTC, 则不走DPDN协议, 一直停在IDLE状态机里, 等温度降下去复位
|
|
|
|
// 或者等温度上去触发芯片复位
|
|
|
|
if(user_app.ntc_triggered_dera) |
|
|
|
{ |
|
|
|
return &g_dpdm_state[DPDM_SRC_STATE_IDLE]; |
|
|
@ -200,6 +200,11 @@ const static sm_state_t *Dpdm_Src_Idle_Run(const sm_state_t *self, void *data) |
|
|
|
else |
|
|
|
#endif |
|
|
|
{ |
|
|
|
dpdm_t *p = (dpdm_t *)data; |
|
|
|
p->dpdm_port = typec_is_attched() ? 0 : 1; |
|
|
|
log_info("dpdm_port:%d\n", p->dpdm_port); |
|
|
|
dpdm_power_set_port(p->dpdm_port); |
|
|
|
hvdcp_prl_init(&p->bc_port, p->dpdm_port); |
|
|
|
return &g_dpdm_state[DPDM_SRC_STATE_APPLE]; |
|
|
|
} |
|
|
|
|
|
|
|