From: SnickerSun Date: Tue, 23 Jan 2024 07:15:10 +0000 (+0800) Subject: 修复battery不能更新bug X-Git-Tag: release_V1.2.70_20241020_135402~1342 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=97c254be65fa71a4bf107f10ab9872e9bebe24a7;p=mirrors%2FFD230.git 修复battery不能更新bug --- diff --git a/code/sdk/application/battery/service/battery_service.c b/code/sdk/application/battery/service/battery_service.c index 4a58f846d..bb088f4be 100644 --- a/code/sdk/application/battery/service/battery_service.c +++ b/code/sdk/application/battery/service/battery_service.c @@ -412,9 +412,7 @@ static void battery_check_task(void const *arg) int32_t ret; common_notify_mail_t mail; uint32_t msgsize = (uint32_t)sizeof(common_notify_mail_t); - //开始timer - battery_timer_start_check_released(CHARGE_CHECK_TIMER_CYCLE_MS); - + while (1) { ret = osal_msg_queue_read_copy(g_app_queue, (void *)&mail, &msgsize, OSAL_MSGQ_WAIT_FOREVER); @@ -431,28 +429,30 @@ static void battery_check_task(void const *arg) if (mail.comm.app == BATTERY_CMD_CHECK_VOLTAGE) { - g_check_count++; + // PRINT("BATTERY_CMD_CHECK_VOLTAGE g_check_count %d\r\n",g_check_count); if(last_battery_charge_enable_status == true){ if (g_check_count*CHARGE_CHECK_TIMER_CYCLE_MS >= ENABLE_CHARGE_TIMEOUT_MS) { + // PRINT("BATTERY_CMD_CHECK_VOLTAGE disable_charge \r\n"); + g_check_count = 0 ; //超时交换状态 disable_charge(); last_battery_charge_enable_status = false; } - - }else if (last_battery_charge_enable_status == false) { if (g_check_count*CHARGE_CHECK_TIMER_CYCLE_MS >= DISABLE_CHARGE_CHECK_MS) { + // PRINT("BATTERY_CMD_CHECK_VOLTAGE battery_check_and_enable_charge \r\n"); + g_check_count = 0 ; //超时交换状态 battery_check_and_enable_charge(); - last_battery_charge_enable_status = false; + last_battery_charge_enable_status = true; } } @@ -481,6 +481,9 @@ errcode_t uapi_battery_init(void) // osal_kthread_set_priority(task_handle, 10); g_battery_timer = osTimerNew((osTimerFunc_t)battery_check_timer_callback, osTimerPeriodic, NULL, NULL); + //开始timer + battery_timer_start_check_released(CHARGE_CHECK_TIMER_CYCLE_MS); + return ERRCODE_SUCC; }