From 675f5fd547a183d515a719e76e1f1359c9d872b3 Mon Sep 17 00:00:00 2001 From: 1624952103 Date: Tue, 20 Jan 2026 15:01:56 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E5=85=85=E7=94=B5IC=20?= =?utf8?q?=E8=AF=BB=E5=8F=96ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../sdk/zhihui/drivers/charge/hp4570/hp4570.c | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) 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 -- 2.17.1