/* bq769x0.h - Battery management system based on bq769x0 for Arduino Copyright (C) 2015 Martin J ger (m.jaeger@posteo.de) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #ifndef _BQ769X0_H_ #define _BQ769X0_H_ /* Includes ------------------------------------------------------------------*/ #include "hc32_ddl.h" // can be reduced to save some memory if smaller ICs are used #define MAX_NUMBER_OF_CELLS 15 #define MAX_NUMBER_OF_THERMISTORS 3 // IC type/size #define bq76920 1 #define bq76930 2 #define bq76940 3 // initialization, status update and shutdown void bq769x0_construct(void); int bq769x0_begin(uint8_t alertPin, uint8_t bootPin); int bq769x0_checkStatus(void); // returns 0 if everything is OK void bq769x0_updateData(void); void bq769x0_shutdown(void); uint8_t bq769x0_updateBalancingSwitches(uint16_t sBal, uint8_t mode); // charging control bool enableCharging(void); void disableCharging(void); bool enableDischarging(void); void disableDischarging(void); // limit settings (for battery protection) long setShortCircuitProtection(long current_mA, int delay_us); long setOvercurrentChargeProtection(long current_mA, int delay_ms); long setOvercurrentDischargeProtection(long current_mA, int delay_ms); int setCellUndervoltageProtection(int voltage_mV, int delay_s); int setCellOvervoltageProtection(int voltage_mV, int delay_s); // battery status uint16_t getNumberOfCells(void); uint32_t getBatteryVoltage(void); uint32_t getBatterySumVoltage(void); uint16_t getCellVoltage(uint16_t idCell); int getMinCellVoltage(void); int getMaxCellVoltage(void); float getTemperatureDegC(uint8_t channel); float getTemperatureDegF(uint8_t channel); uint16_t getCellBalStatus(void); uint8_t getAfeStatus(void); uint8_t getAfeCtrl1(void); uint8_t getAfeCtrl2(void); uint8_t getAfeProtect(uint8_t id); uint8_t getAfeUvTrip(void); uint8_t getAfeOvTrip(void); uint8_t bq769x0_getAlertStatus(void); void bq769x0_ResetAlert(void); // Methods bool determineAddressAndCrc(void); void updateVoltages(void); void updateCurrent(bool ignoreCCReadyFlag); void updateTemperatures(void); uint8_t readRegister(uint8_t address); void writeRegister(uint8_t address, int data); void updateAdcGain2(int32_t Gain2); #endif // _BQ769X0_H_ /*******************(C)COPYRIGHT 2022 AMG ********************END OF FILE******/