{2.2943,69},
{2.2275,70}
};
-float battery_ntc_map[][2]={
- {27.8,0},
- {26.6,1},
- {25.46,2},
- {24.38,3},
- {23.35,4},
- {22.37,5},
- {21.44,6},
- {20.55,7},
- {19.7,8},
- {18.9,9},
- {18.13,10},
- {17.39,11},
- {16.69,12},
- {16.02,13},
- {15.39,14},
- {14.78,15},
- {14.2,16},
- {13.64,17},
- {13.11,18},
- {12.61,19},
- {12.12,20},
- {11.66,21},
- {11.22,22},
- {10.79,23},
- {10.39,24},
- {10,25},
- {9.63,26},
- {9.27,27},
- {8.93,28},
- {8.61,29},
- {8.3,30},
- {8,31},
- {7.71,32},
- {7.43,33},
- {7.17,34},
- {6.92,35},
- {6.67,36},
- {6.44,37},
- {6.22,38},
- {6,39},
- {5.8,40},
- {5.6,41},
- {5.41,42},
- {5.23,43},
- {5.05,44},
- {4.88,45},
- {4.72,46},
- {4.57,47},
- {4.42,48},
- {4.27,49},
- {4.13,50},
- {4,51},
- {3.87,52},
- {3.75,53},
- {3.63,54},
- {3.51,55},
- {3.4,56},
- {3.3,57},
- {3.19,58},
- {3.09,59},
- {3,60},
- {2.91,61},
- {2.82,62},
- {2.73,63},
- {2.65,64},
- {2.57,65},
- {2.49,66},
- {2.42,67},
- {2.35,68},
- {2.28,69},
- {2.21,70}
+// float battery_ntc_map[][2]={
+// {27.8,0},
+// {26.6,1},
+// {25.46,2},
+// {24.38,3},
+// {23.35,4},
+// {22.37,5},
+// {21.44,6},
+// {20.55,7},
+// {19.7,8},
+// {18.9,9},
+// {18.13,10},
+// {17.39,11},
+// {16.69,12},
+// {16.02,13},
+// {15.39,14},
+// {14.78,15},
+// {14.2,16},
+// {13.64,17},
+// {13.11,18},
+// {12.61,19},
+// {12.12,20},
+// {11.66,21},
+// {11.22,22},
+// {10.79,23},
+// {10.39,24},
+// {10,25},
+// {9.63,26},
+// {9.27,27},
+// {8.93,28},
+// {8.61,29},
+// {8.3,30},
+// {8,31},
+// {7.71,32},
+// {7.43,33},
+// {7.17,34},
+// {6.92,35},
+// {6.67,36},
+// {6.44,37},
+// {6.22,38},
+// {6,39},
+// {5.8,40},
+// {5.6,41},
+// {5.41,42},
+// {5.23,43},
+// {5.05,44},
+// {4.88,45},
+// {4.72,46},
+// {4.57,47},
+// {4.42,48},
+// {4.27,49},
+// {4.13,50},
+// {4,51},
+// {3.87,52},
+// {3.75,53},
+// {3.63,54},
+// {3.51,55},
+// {3.4,56},
+// {3.3,57},
+// {3.19,58},
+// {3.09,59},
+// {3,60},
+// {2.91,61},
+// {2.82,62},
+// {2.73,63},
+// {2.65,64},
+// {2.57,65},
+// {2.49,66},
+// {2.42,67},
+// {2.35,68},
+// {2.28,69},
+// {2.21,70}
+// };
+
+float battery_ntc_map[][2] = {
+ {119.52, -30},
+ {113.30, -29},
+ {107.45, -28},
+ {101.93, -27},
+ {96.73, -26},
+ {91.83, -25},
+ {87.21, -24},
+ {82.85, -23},
+ {78.73, -22},
+ {74.85, -21},
+ {71.18, -20},
+ {67.71, -19},
+ {64.43, -18},
+ {61.33, -17},
+ {58.40, -16},
+ {55.62, -15},
+ {53.00, -14},
+ {50.51, -13},
+ {48.16, -12},
+ {45.93, -11},
+ {43.81, -10},
+ {41.81, -9},
+ {39.91, -8},
+ {38.11, -7},
+ {36.40, -6},
+ {34.77, -5},
+ {33.23, -4},
+ {31.77, -3},
+ {30.38, -2},
+ {29.05, -1},
+ // 常温段:0℃ ~ 49℃
+ {27.80, 0},
+ {26.60, 1},
+ {25.46, 2},
+ {24.38, 3},
+ {23.35, 4},
+ {22.37, 5},
+ {21.44, 6},
+ {20.55, 7},
+ {19.70, 8},
+ {18.90, 9},
+ {18.13, 10},
+ {17.39, 11},
+ {16.69, 12},
+ {16.02, 13},
+ {15.39, 14},
+ {14.78, 15},
+ {14.20, 16},
+ {13.64, 17},
+ {13.11, 18},
+ {12.61, 19},
+ {12.12, 20},
+ {11.66, 21},
+ {11.22, 22},
+ {10.79, 23},
+ {10.39, 24},
+ {10.00, 25},
+ {9.63, 26},
+ {9.27, 27},
+ {8.93, 28},
+ {8.61, 29},
+ {8.30, 30},
+ {8.00, 31},
+ {7.71, 32},
+ {7.43, 33},
+ {7.17, 34},
+ {6.92, 35},
+ {6.67, 36},
+ {6.44, 37},
+ {6.22, 38},
+ {6.00, 39},
+ {5.80, 40},
+ {5.60, 41},
+ {5.41, 42},
+ {5.23, 43},
+ {5.05, 44},
+ {4.88, 45},
+ {4.72, 46},
+ {4.57, 47},
+ {4.42, 48},
+ {4.27, 49},
+ {4.13, 50},
+ {4.00, 51},
+ {3.87, 52},
+ {3.75, 53},
+ {3.63, 54},
+ {3.51, 55},
+ {3.40, 56},
+ {3.30, 57},
+ {3.19, 58},
+ {3.09, 59},
+ {3.00, 60},
+ {2.91, 61},
+ {2.82, 62},
+ {2.73, 63},
+ {2.65, 64},
+ {2.57, 65},
+ {2.49, 66},
+ {2.42, 67},
+ {2.35, 68},
+ {2.28, 69},
+ {2.21, 70},
+ {2.15, 71},
+ {2.09, 72},
+ {2.03, 73},
+ {1.97, 74},
+ {1.91, 75},
+ {1.86, 76},
+ {1.80, 77},
+ {1.75, 78},
+ {1.70, 79},
+ {1.66, 80},
+ {1.61, 81},
+ {1.57, 82},
+ {1.52, 83},
+ {1.48, 84},
+ {1.44, 85},
+ {1.40, 86},
+ {1.37, 87},
+ {1.33, 88},
+ {1.29, 89},
+ {1.26, 90},
+ {1.23, 91},
+ {1.19, 92},
+ {1.16, 93},
+ {1.13, 94},
+ {1.10, 95},
+ {1.07, 96},
+ {1.05, 97},
+ {1.02, 98},
+ {0.99, 99},
+ {0.97, 100},
+ {0.95, 101},
+ {0.92, 102},
+ {0.90, 103},
+ {0.88, 104},
+ {0.85, 105},
+ {0.83, 106},
+ {0.81, 107},
+ {0.79, 108},
+ {0.77, 109},
+ {0.76, 110},
+ {0.74, 111},
+ {0.72, 112},
+ {0.70, 113},
+ {0.69, 114},
+ {0.67, 115},
+ {0.65, 116},
+ {0.64, 117},
+ {0.62, 118},
+ {0.61, 119},
+ {0.60, 120},
+ {0.53, 125}
};
-
float battery_percent_map[][2]={
#ifdef BOARD_LEINIAO
{4.200, 100},
static uint8_t percernt_installized = 0;
+static float test_temp = 0;
+
void battery_percent_init(uint8_t percent)
{
percernt_installized = 1;
uint8_t batteryservice_get_battery_temp(float *temp)
{
+ if(test_temp > 0 && test_temp <= 100)
+ {
+ *temp = test_temp;
+ return 0;
+ }
+
battery_info_t *current_battery_info = get_current_battery_info();
*temp = current_battery_info->battery_ntc_temp;
// PRINT("*temp : %.3f\n",*temp);
return 0;
}
+uint8_t batteryservice_set_test_bat_temp(float temp)
+{
+ printf("test_temp : %.3f\n",test_temp);
+ test_temp = temp;
+ return 0;
+}
+
#ifdef __cplusplus
#if __cplusplus
}
#define BAT_FILE_PATH "user/userdata/bat_data.bin"
+#define CHARGE_1C (260.0f)
+
bool batteryservice_get_voltage_by_channel(float *voltage, uint8_t channel);
battery_info_t *get_current_battery_info(void);
static bool g_batter_service_initialled = false;
#else
#define BATTERY_LOWPOWER_ALARM_SHUTDOWNLEVEL 5
#endif
-#define BATTERY_DISABLE_CHARGE_HI_TEMP_VALUE (50.0f) //停止充电温度
+#define BATTERY_DISABLE_CHARGE_HI_TEMP_VALUE (60.0f) //停止充电温度
+#define BATTERY_DISABLE_CHARGE_LOW_TEMP_VALUE (-10.0f) //停止充电温度
#define BATTERY_VOLTAGE_DEBOUNCE 2
*/
static uint8_t low_power_flag_1=1;
static uint8_t low_power_flag_2=1;
+static uint16_t last_charge_mA = 0;
+
static void battery_check_chargement(void)
{
float voltage;
//获取电池温度
batteryservice_get_battery_temp(&bat_temp);
+ printf("bat_temp:%f\n",bat_temp);
+ // bat_temp = -10;
+
+ float charge_mA = 0;
+
+ if(bat_temp >= BATTERY_DISABLE_CHARGE_HI_TEMP_VALUE || bat_temp <= BATTERY_DISABLE_CHARGE_LOW_TEMP_VALUE)
+ {
+ // PRINT("battery temp is too high : %.2f >= %.2f, disable charge!\n",bat_temp,BATTERY_DISABLE_CHARGE_HI_TEMP_VALUE);
+ // disable_charge();
+ // if(g_chargestatus != 0)
+ // {
+ // printf("hp4570_set_ceb_en(false); \n");
+ // #ifdef ENABLE_HP4570
+ // hp4570_set_ceb_en(false);
+ // #endif
+ // }
+ // g_chargestatus = 0;
+ // uapi_poweroff_device();
+ printf("battery temp is too high or low, device will power off\n");
+ shutdown_reboot_prejobs(SHUTDOWN_TYPE);
+ }
#ifdef DISABLE_VBUS_CHECK
PRINT("charging enable charge ! bat-temp %.2f Vs highest temp value %.2f !\n",bat_temp,BATTERY_DISABLE_CHARGE_HI_TEMP_VALUE);
* 否则按正常流程充电
*/
- if(bat_temp >= BATTERY_DISABLE_CHARGE_HI_TEMP_VALUE)
+ if(bat_temp >= BATTERY_DISABLE_CHARGE_HI_TEMP_VALUE || BATTERY_DISABLE_CHARGE_LOW_TEMP_VALUE <= 0)
{
PRINT("battery temp is too high : %.2f >= %.2f, disable charge!\n",bat_temp,BATTERY_DISABLE_CHARGE_HI_TEMP_VALUE);
disable_charge();
+ if(g_chargestatus != 0)
+ {
+ printf("hp4570_set_ceb_en(false); \n");
+ #ifdef ENABLE_HP4570
+ hp4570_set_ceb_en(false);
+ #endif
+ }
g_chargestatus = 0;
- }else{
+ }else{
+
+ if(bat_temp >= 0 && bat_temp < 15)
+ {
+ #ifdef ENABLE_HP4570
+ charge_mA = 0.2 * CHARGE_1C;
+ // hp4570_set_chrg_ichg_mA(0.2 * CHARGE_1C);
+ #endif
+ }
+ else if((bat_temp >= 15 && bat_temp < 25) || (bat_temp >= 45 && bat_temp < 60))
+ {
+ #ifdef ENABLE_HP4570
+ // hp4570_set_chrg_ichg_mA(0.5 * CHARGE_1C);
+ charge_mA = 0.5 * CHARGE_1C;
+ #endif
+ }
+ else if(bat_temp >= 25 && bat_temp < 45)
+ {
+ #ifdef ENABLE_HP4570
+ // hp4570_set_chrg_ichg_mA(CHARGE_1C);
+ charge_mA = CHARGE_1C;
+ #endif
+ }
+
+ if(charge_mA != last_charge_mA)
+ {
+ last_charge_mA = (uint16_t)charge_mA;
+ // printf("last_charge_mA : %d\n",last_charge_mA);
+ #ifdef ENABLE_HP4570
+ hp4570_set_chrg_ichg_mA(charge_mA);
+ #endif
+ }
/**
* check and control charge current event
* other stat , use high charge current
* pay attention to : debounce
*/
+
+ if(g_chargestatus == 0)
+ {
+ printf("hp4570_set_ceb_en(true) \n");
+ #ifdef ENABLE_HP4570
+ hp4570_set_ceb_en(true);
+ #endif
+ }
enable_charge();
if(percent >=90)