增加高低温关机,修复老化死机,降低GPS优先级,更新电池温度曲线 3157/1 3157/head 3158/target/2
author1624952103 <pl@DESKTOP-EN9LKR5.localdomain>
Fri, 30 Jan 2026 03:05:55 +0000 (11:05 +0800)
committer1624952103 <pl@DESKTOP-EN9LKR5.localdomain>
Fri, 30 Jan 2026 03:05:55 +0000 (11:05 +0800)
code/sdk/zhihui/drivers/charge/service/charge_at_cmd.c
code/sdk/zhihui/services/battery/service/battery_driver.cpp
code/sdk/zhihui/services/battery/service/battery_service.cpp
code/sdk/zhihui/services/battery/service/battery_service.h
code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c
code/sdk/zhihui/services/gnss/src/uart_gnss.c

index c906d08..ef11b8d 100644 (file)
@@ -11,6 +11,7 @@
 #include "debug_print.h"
 #include "hp4570.h"
 #include "custom_utils.h"
+#include "battery_service.h"
 
 #define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0]))
 #define CHARGE_MAX_ARGC            8
@@ -84,7 +85,11 @@ static uint32_t hp4570_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
         }
         // ots_stop();
         g_charge_test_started = 0 ;
+    }else
+    {
+        batteryservice_set_test_bat_temp(start);
     }
+
     
     return ERRCODE_SUCC;
 }
index 7a21703..5482e48 100644 (file)
@@ -160,81 +160,236 @@ float pcb_ntc_map[][2]={
 {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},
@@ -340,6 +495,8 @@ static uint8_t cur_percent = 0;
 
 static uint8_t percernt_installized = 0;
 
+static float test_temp = 0;
+
 void battery_percent_init(uint8_t percent)
 { 
     percernt_installized = 1;
@@ -913,6 +1070,12 @@ uint8_t batteryservice_get_voltage(float *voltage)
 
 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);
@@ -934,6 +1097,13 @@ uint8_t batteryservice_get_pcb_temp(float *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
 }
index 05561f4..990d94a 100644 (file)
@@ -53,6 +53,8 @@ extern "C" {
 
 #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;
@@ -101,7 +103,8 @@ static unsigned long g_app_queue = 0xFFFFFFFF;
 #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
 
@@ -355,6 +358,8 @@ int get_charge_current_status(void)
 */
 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;
@@ -366,6 +371,27 @@ static void battery_check_chargement(void)
 
     //获取电池温度
     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);
@@ -414,12 +440,50 @@ static void battery_check_chargement(void)
              * 否则按正常流程充电
             */
 
-            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
@@ -427,6 +491,14 @@ static void battery_check_chargement(void)
                  *  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)
index 73627a4..1e675e0 100644 (file)
@@ -62,6 +62,7 @@ uint8_t get_02c_value(void);
 void battery_get_data(void);
 void battery_save_data(void);
 void battery_get_data_t(BATTERY_DATA_T **data,uint16_t *length);
+uint8_t batteryservice_set_test_bat_temp(float temp);
 
 #ifdef __cplusplus
 #if __cplusplus
index 31525d4..2488d30 100644 (file)
@@ -762,7 +762,8 @@ errcode_t aging_test_init(void)
         return ERRCODE_FAIL;\r
     }\r
 \r
-\r
+    uapi_dev_runtime_set_factory_test_status(1);\r
+    \r
     aging_t.flag = 1;\r
     \r
     return ERRCODE_SUCC;\r
index ba2f48b..e1da2fc 100644 (file)
@@ -238,7 +238,7 @@ int gnss_uart_init(void)
     app_task_definition_t taskcfg={0};
     taskcfg.create_queue_handle = create_gnss_uart_queue;
     taskcfg.attr.name="uart_gnss_service";
-    taskcfg.attr.priority = osPriorityAboveNormal3;//osPriorityNormal; GUI osPriorityAboveNormal2
+    taskcfg.attr.priority = osPriorityAboveNormal2;//osPriorityNormal; GUI osPriorityAboveNormal2
     taskcfg.attr.stack_size = GNSS_CMD_TASK_SIZE;
     taskcfg.func = uart_event_task;
     taskcfg.use_mem = USE_EXTEND_MEM;