42 lines
708 B
C
42 lines
708 B
C
#ifndef _IP5310_I2C_H_
|
||
#define _IP5310_I2C_H_
|
||
|
||
#include "apps_gather.h"
|
||
|
||
extern uint8_t bat_cpa;
|
||
extern uint8_t charge_flag;
|
||
extern uint8_t charging_flag;
|
||
|
||
//电芯电量寄存器
|
||
//bits [4~7]->[0000, 0001, 0011, 0111, 1111]->[<3%, 3~25%, 25~50%, 50~75%, >75%]
|
||
#define BATTERY_CAPACITY 0x74
|
||
|
||
//[3]bit, 1:充电开启, 0:充电关闭
|
||
#define CHARGE_FLAG 0x70
|
||
|
||
//[3]bit, 1:充电结束, 0:充电中
|
||
#define CHARGING_FLAG 0x71
|
||
|
||
//读命令
|
||
#define READ_CMD 0xEB
|
||
|
||
//写命令
|
||
#define WRITE_CMD 0xEA
|
||
|
||
#define BAT_CAP_3 0
|
||
#define BAT_CAP_3_25 1
|
||
#define BAT_CAP_25_50 3
|
||
#define BAT_CAP_50_75 7
|
||
#define BAT_CAP_75 15
|
||
#define BAT_CAP_CHARGING 20
|
||
|
||
//I2C读取电池电量
|
||
void read_battery(void);
|
||
|
||
|
||
|
||
|
||
#endif
|
||
|
||
|