/* convert ADC_bat_temp_volt to register */ static INT16 BattVoltToTemp(UINT32 dwVolt) { INT32 TRes; INT32 dwVCriBat = 0; INT32 sBaTTMP = -100; //SW workaround----------------------------------------------------- //dwVCriBat = (TBAT_OVER_CRITICAL_LOW * 1800) / (TBAT_OVER_CRITICAL_LOW + 39000); dwVCriBat = (TBAT_OVER_CRITICAL_LOW * RBAT_PULL_UP_VOLT) / (TBAT_OVER_CRITICAL_LOW + RBAT_PULL_UP_R); if(dwVolt > dwVCriBat) { TRes = TBAT_OVER_CRITICAL_LOW; } else { //TRes = (39000*dwVolt) / (1800-dwVolt); TRes = (RBAT_PULL_UP_R*dwVolt) / (RBAT_PULL_UP_VOLT-dwVolt); } //------------------------------------------------------------------ g_BAT_TemperatureR = TRes; /* convert register to temperature */ sBaTTMP = BattThermistorConverTemp(TRes); return sBaTTMP; }
/*Volt to Temp formula same with 6589*/ static INT16 BattVoltToTemp(UINT32 dwVolt) { INT32 TRes; INT32 dwVCriBat = 0; INT32 sBaTTMP = -100; //SW workaround----------------------------------------------------- //dwVCriBat = (TBAT_OVER_CRITICAL_LOW * 1800) / (TBAT_OVER_CRITICAL_LOW + 39000); #ifdef INPUT_PARAM_FROM_USER //dwVCriBat = (TBAT_OVER_CRITICAL_LOW * RBAT_PULL_UP_VOLT) / (TBAT_OVER_CRITICAL_LOW + RBAT_PULL_UP_R); dwVCriBat = (g_Tbat_over_critical_low * g_Rbat_pull_up_voltage) / (g_Tbat_over_critical_low + g_Rbat_pull_up_R); if(dwVolt > dwVCriBat) { TRes = g_Tbat_over_critical_low; } else { //TRes = (39000*dwVolt) / (1800-dwVolt); // TRes = (RBAT_PULL_UP_R*dwVolt) / (RBAT_PULL_UP_VOLT-dwVolt); TRes = (g_Rbat_pull_up_R*dwVolt) / (g_Rbat_pull_up_voltage-dwVolt); } //------------------------------------------------------------------ #else //SW workaround----------------------------------------------------- //dwVCriBat = (TBAT_OVER_CRITICAL_LOW * 1800) / (TBAT_OVER_CRITICAL_LOW + 39000); dwVCriBat = (TBAT_OVER_CRITICAL_LOW * RBAT_PULL_UP_VOLT) / (TBAT_OVER_CRITICAL_LOW + RBAT_PULL_UP_R); if(dwVolt > dwVCriBat) { TRes = TBAT_OVER_CRITICAL_LOW; } else { //TRes = (39000*dwVolt) / (1800-dwVolt); TRes = (RBAT_PULL_UP_R*dwVolt) / (RBAT_PULL_UP_VOLT-dwVolt); } //------------------------------------------------------------------ #endif g_BAT_TemperatureR = TRes; /* convert register to temperature */ sBaTTMP = BattThermistorConverTemp(TRes); return sBaTTMP; }
int BattVoltToTemp(int dwVolt) { kal_int64 TRes_temp; kal_int64 TRes; int sBaTTMP = -100; // TRes_temp = ((kal_int64)RBAT_PULL_UP_R*(kal_int64)dwVolt) / (RBAT_PULL_UP_VOLT-dwVolt); //TRes = (TRes_temp * (kal_int64)RBAT_PULL_DOWN_R)/((kal_int64)RBAT_PULL_DOWN_R - TRes_temp); TRes_temp = (RBAT_PULL_UP_R*(kal_int64)dwVolt); do_div(TRes_temp, (RBAT_PULL_UP_VOLT-dwVolt)); TRes = (TRes_temp * RBAT_PULL_DOWN_R); do_div(TRes, abs(RBAT_PULL_DOWN_R - TRes_temp)); /* convert register to temperature */ sBaTTMP = BattThermistorConverTemp((int)TRes); return sBaTTMP; }
/* convert ADC_bat_temp_volt to register */ int BattVoltToTemp(int dwVolt) { int TRes; int dwVCriBat = (TBAT_OVER_CRITICAL_LOW*RBAT_PULL_UP_VOLT)/(TBAT_OVER_CRITICAL_LOW+RBAT_PULL_UP_R); //~2000mV int sBaTTMP = -100; if(dwVolt > dwVCriBat) TRes = TBAT_OVER_CRITICAL_LOW; else TRes = (RBAT_PULL_UP_R*dwVolt)/(RBAT_PULL_UP_VOLT-dwVolt); /* convert register to temperature */ sBaTTMP = BattThermistorConverTemp(TRes); //#ifdef CONFIG_DEBUG_MSG_NO_BQ27500 LOGD(TAG "ft-BattVoltToTemp() : TBAT_OVER_CRITICAL_LOW = %d\n", TBAT_OVER_CRITICAL_LOW); LOGD(TAG "ft-BattVoltToTemp() : RBAT_PULL_UP_VOLT = %d\n", RBAT_PULL_UP_VOLT); LOGD(TAG "ft-BattVoltToTemp() : dwVolt = %d\n", dwVolt); LOGD(TAG "ft-BattVoltToTemp() : TRes = %d\n", TRes); LOGD(TAG "ft-BattVoltToTemp() : sBaTTMP = %d\n", sBaTTMP); //#endif return sBaTTMP; }