31 lines
1.3 KiB
C
31 lines
1.3 KiB
C
#ifndef __BQ4050_H__
|
|
#define __BQ4050_H__
|
|
|
|
#include "driver/i2c.h"
|
|
#include "esp_log.h"
|
|
|
|
static i2c_port_t __BQ4050__I2C_port__;
|
|
static uint8_t __BQ4050__I2C_address__;
|
|
static void *(esp_err_t)__BQ4050_ERR_CB__;
|
|
|
|
void bq_Init(i2c_port_t I2C_NUM, uint8_t I2C_address, void *(esp_err_t)bq4050_err_cb);
|
|
uint8_t bq_BattState(); // Return CHG/DSG(0xF?/0x0?), OK/Bad(0x?0/0x?F)
|
|
uint16_t bq_GetAdvState(); // Return XDSG/XCHG/PF/SS/FC/FD/TAPR/VCT/CB/SMTH/SU/IN/VDQ/FCCX/EDV2/EDV1
|
|
uint16_t bq_GetVoltage(); // Unit: mV
|
|
int16_t bq_GetCurrent(); // Unit: mA
|
|
uint8_t bq_GetRSOC(); // Unit: %
|
|
uint16_t bq_GetT2E(); // Unit: min
|
|
uint16_t bq_GetT2F(); // Unit: min
|
|
uint16_t bq_GetPackTemp(); // Unit: 0.1K
|
|
uint8_t bq_GetMaxErr(); // Unit: %
|
|
uint8_t bq_GetHealth(); // Unit: %
|
|
uint16_t bq_GetCellVolt(uint8_t cellNo); // Unit: mV
|
|
uint16_t bq_GetCycleCnt();
|
|
esp_err_t bq4050_register_read(uint8_t reg_addr, uint8_t *data, size_t len);
|
|
esp_err_t bq4050_register_write(uint8_t *data, size_t len);
|
|
void ESP_I2C_ERROR_CHECK(esp_err_t errcode);
|
|
|
|
void bq_GetLifetimeBlock(uint8_t blockNo, uint8_t *blockBuf);
|
|
void bq_MACReadBlock(uint8_t *inBlock, uint8_t inLen, uint8_t *outBlock, uint8_t outLen);
|
|
|
|
#endif |