From: Nathael Pajani Date: Sun, 30 Jan 2022 03:14:56 +0000 (+0100) Subject: Add function to stop continuous CC to BQ769x0 BMS support X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=96929b6944dd5e476a936ec0e695d9484a5252d5;p=soft%2Flpc82x%2Fcore Add function to stop continuous CC to BQ769x0 BMS support --- diff --git a/extdrv/bq769x0_bms.c b/extdrv/bq769x0_bms.c index 76357c1..cf276b5 100644 --- a/extdrv/bq769x0_bms.c +++ b/extdrv/bq769x0_bms.c @@ -232,6 +232,7 @@ int bq769x0_bms_load_present(struct bq769x0_bms_conf* conf) return 0; /* */ } + /* BMS Shut-Down. * Disable both charge and discharge and turn off BMS by sending shutdown sequence. * Only way out of sequence is power cycle (battery removal and re-insertion or button). @@ -316,6 +317,29 @@ int bq769x0_bms_set_continuous_conversion(struct bq769x0_bms_conf* conf) return 0; /* Configuration change success */ } +/* Place the bms in continuous CC convertion mode */ +int bq769x0_bms_stop_continuous_conversion(struct bq769x0_bms_conf* conf) +{ + int ret = 0; + uint8_t tmp = 0; + + /* Read actual config */ + ret = bq769x0_bms_get_regs(conf, SYS_CTRL_2, &tmp, 1); + if (ret != 0) { + conf->probe_ok = 15; + return ret; + } + msleep(2); + /* Set CC continuous conversion bit and write back */ + tmp &= ~CC_ENABLE; + ret = bq769x0_bms_set_regs(conf, SYS_CTRL_2, &tmp, 1); + if (ret != 0) { + conf->probe_ok = 16; + return ret; + } + return 0; /* Configuration change success */ +} + /* Enable/Disable charge and/or discharge * Note that it is not possible to keep the old charge/discharge state and modify * only the other one with this function. @@ -479,6 +503,8 @@ int bq769x0_bms_read_adc(struct bq769x0_bms_conf* conf, uint16_t* data, int type return 0; } + + int bq769x0_bms_get_and_erase_status(struct bq769x0_bms_conf* conf, uint8_t* status) { int ret = 0; diff --git a/include/extdrv/bq769x0_bms.h b/include/extdrv/bq769x0_bms.h index 06a4098..8278032 100644 --- a/include/extdrv/bq769x0_bms.h +++ b/include/extdrv/bq769x0_bms.h @@ -102,6 +102,9 @@ int bq769x0_bms_start_conversion(struct bq769x0_bms_conf* conf); /* Place the bms in continuous CC convertion mode */ int bq769x0_bms_set_continuous_conversion(struct bq769x0_bms_conf* conf); +/* Place the bms in continuous CC convertion mode */ +int bq769x0_bms_stop_continuous_conversion(struct bq769x0_bms_conf* conf); + /* Enable/Disable charge and/or discharge * Note that it is not possible to keep the old charge/discharge state and modify * only the other one with this function.