diff --git a/code/application/source/sf_app/code/include/sf_battery.h b/code/application/source/sf_app/code/include/sf_battery.h index e94f50002..a4a88d041 100644 --- a/code/application/source/sf_app/code/include/sf_battery.h +++ b/code/application/source/sf_app/code/include/sf_battery.h @@ -37,4 +37,5 @@ INT16 sf_adc2Temperature(UINT16 adcValue, UINT8 type);/*type: 0:F 1:C*/ void sf_stamp_temperature_get(INT16 *fTem,INT16 *cTem); /*0:F 1:C*/ void sf_temper_update(void); INT16 sf_celsius_change_to_fahrenheit(INT16 cTemper); +UINT16 sf_battery_val_get(void); #endif diff --git a/code/application/source/sf_app/code/source/app/sf_common.c b/code/application/source/sf_app/code/source/app/sf_common.c index 4b2a15398..074ef51bb 100755 --- a/code/application/source/sf_app/code/source/app/sf_common.c +++ b/code/application/source/sf_app/code/source/app/sf_common.c @@ -883,7 +883,7 @@ static SINT32 sf_app_proccess_cmd_dev(SF_MESSAGE_BUF_S *pMessageBuf) stMessageBuf.cmdId = CMD_DEV; stMessageBuf.arg1 = SF_DEV_CMD_BAT; stMessageBuf.arg2 = sf_battery_value_get(0); - stMessageBuf.arg3 = (SINT32)sf_battery_type_get(); + stMessageBuf.arg3 = ((SINT32)(((sf_battery_type_get()) << 16) | (sf_battery_val_get()))); printf("[%s:%d]batteryVal=%d battery_type:%d\n",__FUNCTION__,__LINE__,stMessageBuf.arg2, stMessageBuf.arg3); sf_com_message_send_to_cardv(&stMessageBuf); //sf_app_set_battery(pMessageBuf->arg2, pMessageBuf->arg3); diff --git a/code/application/source/sf_app/code/source/battery/sf_battery.c b/code/application/source/sf_app/code/source/battery/sf_battery.c index 29b7be3c2..4f16020d1 100755 --- a/code/application/source/sf_app/code/source/battery/sf_battery.c +++ b/code/application/source/sf_app/code/source/battery/sf_battery.c @@ -397,7 +397,7 @@ void sf_battery_level_update(void) stMessageBuf.cmdId = CMD_DEV; stMessageBuf.arg1 = SF_DEV_CMD_BAT; stMessageBuf.arg2 = batteryVal; - stMessageBuf.arg3 = (SINT32)sf_battery_type_get(); + stMessageBuf.arg3 = ((SINT32)(((sf_battery_type_get()) << 16) | (sf_battery_val_get()))); printf("[%s:%d]batteryVal=%d battery_type:%d\n",__FUNCTION__,__LINE__,batteryVal, stMessageBuf.arg3); sf_com_message_send_to_cardv(&stMessageBuf); #endif @@ -1290,6 +1290,26 @@ UINT8 sf_battery_type_get(void) return SF_POWER_TYPE_DC; } +/************************************************* + Function: sf_battery_type_get + Description: Get battery type. + Input: N/A + Output: N/A + Return: value: battery type, 0:normal 1:LiPolymer + Others: N/A +*************************************************/ +UINT16 sf_battery_val_get(void) +{ + if(IsPowerDcIn) + return (UINT16)DcVoltageVal; + else if(LiPolymerVoltageVal) + return (UINT16)LiPolymerVoltageVal; + else if(BatVoltageVal) + return (UINT16)BatVoltageVal; + else + return 0; +} + /************************************************* Function: sf_is_battery_low Description: Judge whether the power is low diff --git a/code/lib/source/sifar/code/source/common/sf_common.c b/code/lib/source/sifar/code/source/common/sf_common.c index 54dccb19e..5e6d8b42a 100755 --- a/code/lib/source/sifar/code/source/common/sf_common.c +++ b/code/lib/source/sifar/code/source/common/sf_common.c @@ -80,6 +80,7 @@ static UINT8 FwUpdate = 0; static UINT8 IsNightLedOn = 0; static SF_BatteryLevel_e sf_LatestBattLevel = SF_BATT_LEVEL_0; static UINT8 batteryVal = 0; +static UINT16 powerVal = 0; static UINT8 batteryType = 0; static SINT16 fTemper = 0; static SINT16 cTemper = 0; @@ -1699,7 +1700,8 @@ static SINT32 sf_cardv_proccess_cmd_dev(SF_MESSAGE_BUF_S *pMessageBuf) break; case SF_DEV_CMD_BAT: batteryVal = pMessageBuf->arg2; - batteryType = pMessageBuf->arg3; + batteryType = pMessageBuf->arg3 & 0xf0; + powerVal = pMessageBuf->arg3 & 0xf; sf_cardv_battery_level_update(batteryVal); MLOGI("batteryVal:%d batteryType:%d\n",batteryVal,batteryType); @@ -2236,9 +2238,9 @@ UINT8 sf_cardv_battery_type_get(void) BOOL sf_is_flash_voltage_abnormal(void) { - printf("batteryVal=%d batteryType=%d \n", batteryVal, batteryType); + printf("powerVal=%d batteryType=%d \n", powerVal, batteryType); - if((/*SF_POWER_TYPE_DC*/1 != batteryType) && (batteryVal < 55) && (batteryVal < 55)) + if((/*SF_POWER_TYPE_DC*/1 != batteryType) && (powerVal < 55) ) { printf("low battery no write flash\n"); return TRUE;