main/ip5306.c
static esp_err_t clear_bits(uint8_t reg, uint8_t bits) {
    uint8_t val;
    esp_err_t ret;

    ret = master_i2c_read(BAT_I2C_ADDRESS, reg, &val, 1);
    if(ret != ESP_OK)
        return ret;

    val &= ~(bits);

    ret = master_i2c_write(BAT_I2C_ADDRESS, reg, &val, 1);
    if(ret != ESP_OK)
        return ret;

    return ESP_OK;
}
// REG_READ_4 not in datasheet, but values have been reverse engineered.
REG_READ_4 not in datasheet, but values have been reverse engineered.
REG_READ_4 not in datasheet but values have been reverse engineered .
static esp_err_t clear_bits(uint8_t reg, uint8_t bits) {
    uint8_t val;
    esp_err_t ret;
    ret = master_i2c_read(BAT_I2C_ADDRESS, reg, &val, 1);
    if(ret != ESP_OK)
        return ret;
    val &= ~(bits);
    ret = master_i2c_write(BAT_I2C_ADDRESS, reg, &val, 1);
    if(ret != ESP_OK)
        return ret;
    return ESP_OK;
}
static esp_err_t clear_bits ( uint8_t reg , uint8_t bits ) { uint8_t val ; esp_err_t ret ; ret = master_i2c_read ( BAT_I2C_ADDRESS , reg , & val , 1 ) ; if ( ret != ESP_OK ) return ret ; val &= ~ ( bits ) ; ret = master_i2c_write ( BAT_I2C_ADDRESS , reg , & val , 1 ) ; if ( ret != ESP_OK ) return ret ; return ESP_OK ; }
REG_READ_4 not in datasheet, but values have been reverse engineered.
REG_READ_4 not in datasheet but values have been reverse engineered .