Git Product home page Git Product logo

bq2429x-driver's Introduction

bq2429x-driver

BQ2429x I2C Controlled Charger Driver.

Usage

Create prototype read/write functions,

static int32_t i2c_write(void *handle, uint8_t reg, const uint8_t *bufp, uint16_t len)
{
    HAL_I2C_Mem_Write(handle, BQ2429X_I2C_ADD, reg, I2C_MEMADD_SIZE_8BIT, (uint8_t *)bufp, len, 1000);
    return 0;
}

static int32_t i2c_read(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len)
{
    HAL_I2C_Mem_Read(handle, BQ2429X_I2C_ADD, reg, I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
    return 0;
}

Configure the device,

bq2429x_ctx.handle    = &hi2c1;
bq2429x_ctx.read_reg  = i2c_read;
bq2429x_ctx.write_reg = i2c_write;
bq2429x_part_number_t part_number;
bq2429x_part_number_get(&bq2429x_ctx, &part_number);
if (part_number == BQ24296 || part_number == BQ24297)
{
    bq2429x_input_voltage_limit_set(&bq2429x_ctx, 15);
    bq2429x_input_current_limit_set(&bq2429x_ctx, 7);
    bq2429x_charge_enable(&bq2429x_ctx, true);
    bq2429x_minimum_system_voltage_set(&bq2429x_ctx, 0);
    bq2429x_boost_current_limit_set(&bq2429x_ctx, 1);
    bq2429x_charge_current_set(&bq2429x_ctx, 39);
    bq2429X_precharge_current_set(&bq2429x_ctx, 7);
    bq2429x_termination_current_set(&bq2429x_ctx, 2);
    bq2429x_charge_voltage_set(&bq2429x_ctx, 44);
    bq2429x_batt_low_threshold_set(&bq2429x_ctx, 0);
    bq2429x_recharge_voltage_set(&bq2429x_ctx, 1);
    bq2429x_termination_enable(&bq2429x_ctx, true);
    bq2429x_watchdog_timer_set(&bq2429x_ctx, 0);
    bq2429x_safety_timer_enable(&bq2429x_ctx, true);
    bq2429x_charge_timer_set(&bq2429x_ctx, 3);
    bq2429x_boost_voltage_set(&bq2429x_ctx, 7);
    bq2429x_boost_temp_monitor_set(&bq2429x_ctx, 3);
    bq2429x_thermal_regulation_threshold_set(&bq2429x_ctx, 3);
    bq2429x_batt_fault_interrupt_enable(&bq2429x_ctx, 0);
    bq2429x_chg_fault_interrupt_enable(&bq2429x_ctx, 0);
}

CE pin can be used to restart charging on fault condition.

void charger_restart(void)
{
    HAL_GPIO_WritePin(BQ_CE_GPIO_Port, BQ_CE_Pin, GPIO_PIN_SET);
    osDelay(250);
    HAL_GPIO_WritePin(BQ_CE_GPIO_Port, BQ_CE_Pin, GPIO_PIN_RESET);
}

That's all!

bq2429x-driver's People

Contributors

mikucukyilmaz avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.