AlexKlimaj / LiPow-Firmware

Lipo Battery Charger with USB C Power Delivery Based on the STM32G0
https://arkelectron.com/product/lipow-the-usb-c-lipo-battery-charger/
GNU General Public License v3.0
322 stars 98 forks source link

I2C Library for Controlling BQ25703A #6

Closed AlexKlimaj closed 5 years ago

AlexKlimaj commented 5 years ago

Need to write I2C library to communicate and control the programmable regulator. Need to be able to set the number of cells/voltage and current limit.

The following signals are connected from the BQ25703A to the STM32G0.

ILIM_HIZ - Default low on bootup, drive high before beginning charge. Drive low on fault, or end of charge.

Input current limit input. Program ILIM_HIZ voltage by connecting a resistor divider from supply rail to ILIM_HIZ pin to ground. The pin voltage is calculated as: V(ILIM_HIZ) = 1 V + 40 × IDPM × RAC, in which IDPM is the target input current. The input current limit used by the charger is the lower setting of ILIM_HIZ pin and REG0x0F() and REG0x0E(). When the pin voltage is below 0.4 V, the device enters Hi-Z mode with low quiescent current. When the pin voltage is above 0.8 V, the device is out of Hi-Z mode.

PROCHOTn - Need to decide how or if to use this one.

Active low open drain output of processor hot indicator. It monitors adapter input current, battery discharge current, and system voltage. After any event in the PROCHOT profile is triggered, a pulse is asserted. The minimum pulse width is adjustable in REG0x36[5:2].

CHRG_OK - Use to detect charging faults. Only charge if signal is High. Stop charge if low.

Open drain active high indicator to inform the system good power source is connected to the charger input. Connect to the pullup rail via 10-kΩ resistor. When VBUS rises above 3.5V or falls below 24.5V, CHRG_OK is HIGH after 50ms deglitch time. When VBUS is falls below 3.2 V or rises above 26 V, CHRG_OK is LOW. When fault occurs, CHRG_OK is asserted LOW.

EN_OTG - Reserve for future use. Leave low.

Active HIGH to enable OTG mode. When EN_OTG pin is HIGH and REG0x35[4] is HIGH, OTG can be enabled, refer to USB On-The-Go (OTG) for details of how to enable OTG function

AlexKlimaj commented 5 years ago

Done