From: 1624952103 Date: Tue, 20 Jan 2026 07:01:56 +0000 (+0800) Subject: 优化充电IC 读取ID X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F3115%2Ftarget%2F1;p=mirrors%2FFD230.git 优化充电IC 读取ID --- diff --git a/code/sdk/zhihui/drivers/charge/hp4570/hp4570.c b/code/sdk/zhihui/drivers/charge/hp4570/hp4570.c index 717e26411..f4068ff33 100644 --- a/code/sdk/zhihui/drivers/charge/hp4570/hp4570.c +++ b/code/sdk/zhihui/drivers/charge/hp4570/hp4570.c @@ -243,15 +243,21 @@ bool hp4570_identify(uint8_t chip_ver){ // printf("vid_value[0] : 0x%x , vid_value[1] : 0x%x , pid_value[0] : 0x%x,pid_value[1] : 0x%x chip_ver_value : 0x%x\n",vid_value[0],vid_value[1],pid_value[0],pid_value[1],chip_ver_value); - if((vid_value[0]!=HP4570_REG_VID_LSB_DEF)|| (vid_value[1]!=HP4570_REG_VID_MSB_DEF)||(pid_value[0]!=HP4570_REG_PID_LSB_DEF)) - return FAIL; - - // if((vid_value[0]!=HP4570_REG_VID_LSB_DEF)|| - // (vid_value[1]!=HP4570_REG_VID_MSB_DEF)|| - // (pid_value[0]!=HP4570_REG_PID_LSB_DEF)|| - // (pid_value[1]!=HP4570_REG_PID_MSB_DEF)|| - // (chip_ver_value != chip_ver)) - // return FAIL; + + if((vid_value[0] != HP4570_REG_VID_LSB_DEF) || + (vid_value[1] != HP4570_REG_VID_MSB_DEF) || + (pid_value[0] != HP4570_REG_PID_LSB_DEF)) { + return FAIL; + } + + bool is_valid_combination = + ((pid_value[1] == 0x00) && (chip_ver_value == 0x02)) || + ((pid_value[1] == 0x03) && (chip_ver_value == 0x00)); + + if (!is_valid_combination) { + return FAIL; + } + return SUCCESS; } @@ -927,7 +933,7 @@ void hp4570_set_ideadbat_4x_en(bool en){ uint8_t hp4570_get_id(void) { uint8_t id = 0; - hp4570_i2c_addr = HP4570_I2C_ADDR; - hp4570_read_reg(HP4570_REG_CHIP_VER, &id); + if(hp4570_identify(HP4570N) == SUCCESS) + id = 0x2; return id; } \ No newline at end of file