bleSDK_expansion_board/projects/blezongkong/src/app_bat.h

62 lines
2.6 KiB
C

#ifndef _APP_BAT_H_
#define _APP_BAT_H_
#define BAT_SxP1 4 // 电池四串一并
#define BAT_VOLT(_Volt) (_Volt * BAT_SxP1) //电压单位转换
#define BAT_Low_VOLT BAT_VOLT(105) //10.5V x 4 = 42V
#define BAT_Full_VOLT BAT_VOLT(144) //14.4V x 4 = 57.6V
// #define BAT_LEVEL_0PERCENT_VOLT BAT_VOLT(105) // 0%:(105~110]=(42.0V~44.0V]
// #define BAT_LEVEL_10PERCENT_VOLT BAT_VOLT(113) // 10%:(110~113]=(44.0V~45.2V]
// #define BAT_LEVEL_20PERCENT_VOLT BAT_VOLT(116) // 20%:(113~116]=(45.2V~46.4V]
// #define BAT_LEVEL_30PERCENT_VOLT BAT_VOLT(119) // 30%:(116~119]=(46.4V~47.6V]
// #define BAT_LEVEL_40PERCENT_VOLT BAT_VOLT(122) // 40%:(119~122]=(47.6V~48.8V]
// #define BAT_LEVEL_50PERCENT_VOLT BAT_VOLT(125) // 50%:(122~125]=(48.8V~50.0V]
// #define BAT_LEVEL_60PERCENT_VOLT BAT_VOLT(128) // 60%:(125~128]=(50.0V~51.2V]
// #define BAT_LEVEL_70PERCENT_VOLT BAT_VOLT(131) // 70%:(128~131]=(51.2V~52.4V]
// #define BAT_LEVEL_80PERCENT_VOLT BAT_VOLT(134) // 80%:(131~134]=(52.4V~53.6V]
// #define BAT_LEVEL_90PERCENT_VOLT BAT_VOLT(137) // 90%:(134~137]=(53.6V~54.8V]
// #define BAT_LEVEL_100PERCENT_VOLT BAT_VOLT(144) //100%:(137~144]=(54.8V~57.6V]
// 内阻 20mΩ * 4 =80mΩ // 线损 10A 0.1V
#define BAT_LEVEL_0PERCENT_VOLT BAT_VOLT(105) // 0%
#define BAT_LEVEL_10PERCENT_VOLT BAT_VOLT(107) // 10%
#define BAT_LEVEL_20PERCENT_VOLT BAT_VOLT(109) // 20%
#define BAT_LEVEL_30PERCENT_VOLT BAT_VOLT(111) // 30%
#define BAT_LEVEL_40PERCENT_VOLT BAT_VOLT(113) // 40%
#define BAT_LEVEL_50PERCENT_VOLT BAT_VOLT(115) // 50%
#define BAT_LEVEL_60PERCENT_VOLT BAT_VOLT(117) // 60%
#define BAT_LEVEL_70PERCENT_VOLT BAT_VOLT(119) // 70%
#define BAT_LEVEL_80PERCENT_VOLT BAT_VOLT(121) // 80%
#define BAT_LEVEL_90PERCENT_VOLT BAT_VOLT(123) // 90%
#define BAT_LEVEL_100PERCENT_VOLT BAT_VOLT(144) //100%
// 充电状态
typedef enum {
Bat_Low_STA=(1<<0),
Bat_30_STA=(1<<1),
Bat_60_STA=(1<<2),
Bat_80_STA=(1<<3),
Bat_100_STA=(1<<4),
Bat_NotCharge_STA=(1<<5),
Bat_Charge_STA=(1<<6),
} BAT_STA_t;
typedef struct BAT_Message{
uint8_t Bat_STA;
uint8_t Bat_Percent; // 42=42%
uint8_t Bat_Low_Volt_count; // 低压计数
uint16_t Bat_Voltage; // 480=48.0V
uint16_t Runing_Time; // 系统运行时间
uint16_t Deep_ACC_Time; // 深踩油门时间
} BAT_Message_t;
uint8_t pmu_voltage_to_percent(uint32_t volt); // 电压转百分比
void BAT_Message_Init(void);
#endif