sggt/App/IP5310/ip5310_i2c.h

42 lines
708 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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