static void battery_update_info(struct batteryFTM *batt, char *info) { char *ptr; int temp = 0; #ifdef FEATURE_FTM_PMIC_632X int battery_fg_current = 0; bool pmic_is_connect = 0; #endif temp = get_ADC_channel(ADC_CHARGER, ADC_COUNT); if (temp != -1) { batt->charger_voltage = (temp/ADC_COUNT); /* Charger_Voltage */ if ( batt->charger_voltage >= 4100 ) { batt->charger_exist = true; batt->is_charging = true; } else { batt->charger_voltage = 0; batt->charger_exist = false; batt->is_charging = false; } } else { batt->charger_voltage = -1; batt->charger_exist = false; batt->is_charging = false; } //batt->bat_voltage = get_BAT_vol(); batt->bat_voltage = get_v_bat_sen(); if (batt->bat_voltage != -1) { #ifdef FEATURE_FTM_PMIC_632X batt->adc_vbat_current = ((batt->bat_voltage)*1024)/(4*1200); #else batt->adc_vbat_current = ((batt->bat_voltage)*1024)/(2*2800); #endif } else { batt->adc_vbat_current = -1; } //batt->current_charging = get_FG_current(); batt->current_charging = get_ADC_channel(ADC_BAT_FG_CURRENT, ADC_COUNT); temp = get_BAT_status(); if (temp != -1) { batt->is_calibration = (temp==1) ? true : false; } else { batt->is_calibration = false; } batt->bat_temperature = 25; #ifdef BATTERY_TYPE_B61UN temp = get_ADC_channel(ADC_BAT_TEMP, ADC_COUNT); if (temp != -1) { temp = (temp/ADC_COUNT); batt->bat_temperature = BattVoltToTemp(temp); } else { batt->bat_temperature = -100; } #endif #ifdef BATTERY_TYPE_BLP509 temp = get_ADC_channel(ADC_BAT_TEMP, ADC_COUNT); if (temp != -1) { temp = (temp/ADC_COUNT); batt->bat_temperature = BattVoltToTemp(temp); } else { batt->bat_temperature = -100; } #endif #ifdef BATTERY_TYPE_Z3 temp = get_ADC_channel(ADC_BAT_TEMP, ADC_COUNT); #ifdef FEATURE_FTM_PMIC_632X batt->bat_temperature = temp/ADC_COUNT; #else if (temp != -1) { temp = (temp/ADC_COUNT); batt->bat_temperature = BattVoltToTemp(temp); } else { batt->bat_temperature = -101; } #endif #endif #ifdef FEATURE_FTM_PMIC_632X temp = get_ADC_channel(ADC_BAT_FG_CURRENT, ADC_COUNT); if (temp != -1) { battery_fg_current = temp; } else { battery_fg_current = -1; } #endif #ifdef FEATURE_FTM_PMIC_632X if( batt->adc_vbat_current > 0 ) { pmic_is_connect = true; } else { pmic_is_connect = false; } #endif /* preare text view info */ ptr = info; ptr += sprintf(ptr, "%s : %d %s \n", uistr_info_title_battery_val, batt->bat_voltage, uistr_info_title_battery_mv); ptr += sprintf(ptr, "%s : %d %s \n", uistr_info_title_battery_temp, batt->bat_temperature, uistr_info_title_battery_c); ptr += sprintf(ptr, "%s : %s \n", uistr_info_title_battery_chr, (batt->is_charging) ? uistr_info_title_battery_yes : uistr_info_title_battery_no); ptr += sprintf(ptr, "%s : %d %s \n", uistr_info_title_battery_chr_val, batt->charger_voltage, uistr_info_title_battery_mv); #ifdef FEATURE_FTM_PMIC_632X ptr += sprintf(ptr, "%s: %d %s \n", uistr_info_title_battery_fg_cur, battery_fg_current, uistr_info_title_battery_ma); ptr += sprintf(ptr, "%s : %s \n", uistr_info_title_battery_pmic_chip, (pmic_is_connect) ? uistr_info_title_battery_connect : uistr_info_title_battery_no_connect); #endif return; }
static void battery_update_info(struct batteryFTM *batt, char *info) { char *ptr; int temp = 0; #ifdef FEATURE_FTM_PMIC_6329 int battery_fg_current = 0; bool pmic_is_connect = 0; #endif temp = get_ADC_channel(ADC_CHARGER, ADC_COUNT); if (temp != -1) { batt->charger_voltage = (temp/ADC_COUNT); /* Charger_Voltage */ if ( batt->charger_voltage >= 4100 ) { batt->charger_exist = true; batt->is_charging = true; } else { batt->charger_voltage = 0; batt->charger_exist = false; batt->is_charging = false; } } else { batt->charger_voltage = -1; batt->charger_exist = false; batt->is_charging = false; } #ifdef MTK_NCP1851_SUPPORT batt->bat_voltage = get_BAT_vol(); batt->current_charging = get_FG_current(); #else temp = get_ADC_channel(ADC_BAT_SEN, ADC_COUNT); if (temp != -1) { batt->bat_voltage = (temp/ADC_COUNT); #ifdef FEATURE_FTM_PMIC_6329 batt->adc_vbat_current = ((batt->bat_voltage)*1024)/(4*1200); #else batt->adc_vbat_current = ((batt->bat_voltage)*1024)/(2*2800); #endif } else { batt->bat_voltage = -1; batt->adc_vbat_current = -1; } temp = get_ADC_channel(ADC_I_SEN, ADC_COUNT); if (temp != -1) { temp = (temp/ADC_COUNT); /* I_sense */ if (batt->charger_exist) { batt->current_charging = ((temp-(batt->bat_voltage))*10)/2; } else { batt->current_charging = 0; } } else { batt->current_charging = -1; } #endif temp = get_BAT_status(); if (temp != -1) { batt->is_calibration = (temp==1) ? true : false; } else { batt->is_calibration = false; } batt->bat_temperature = 25; #ifdef BATTERY_TYPE_B61UN temp = get_ADC_channel(ADC_BAT_TEMP, ADC_COUNT); if (temp != -1) { temp = (temp/ADC_COUNT); batt->bat_temperature = BattVoltToTemp(temp); } else { batt->bat_temperature = -100; } #endif #ifdef BATTERY_TYPE_BLP509 temp = get_ADC_channel(ADC_BAT_TEMP, ADC_COUNT); if (temp != -1) { temp = (temp/ADC_COUNT); batt->bat_temperature = BattVoltToTemp(temp); } else { batt->bat_temperature = -100; } #endif #ifdef BATTERY_TYPE_Z3 temp = get_ADC_channel(ADC_BAT_TEMP, ADC_COUNT); #ifdef FEATURE_FTM_PMIC_6329 batt->bat_temperature = temp; #else if (temp != -1) { temp = (temp/ADC_COUNT); batt->bat_temperature = BattVoltToTemp(temp); } else { batt->bat_temperature = -101; } #endif #endif #ifdef FEATURE_FTM_PMIC_6329 temp = get_ADC_channel(ADC_BAT_FG_CURRENT, ADC_COUNT); if (temp != -1) { battery_fg_current = temp; } else { battery_fg_current = -1; } #endif #ifdef FEATURE_FTM_PMIC_6329 if( batt->adc_vbat_current > 0 ) { pmic_is_connect = true; } else { pmic_is_connect = false; } #endif /* preare text view info */ ptr = info; #ifndef MTK_NCP1851_SUPPORT ptr += sprintf(ptr, "BAT Cal. : %s\n", (batt->is_calibration) ? "YES" : "NO"); ptr += sprintf(ptr, "BAT Volt. : %d mV\n", batt->bat_voltage); ptr += sprintf(ptr, "BAT Temp. : %d Celsius\n", batt->bat_temperature); ptr += sprintf(ptr, "CHGR : %s\n", (batt->is_charging) ? "YES" : "NO"); ptr += sprintf(ptr, "CHGR Volt.: %d mV\n", batt->charger_voltage); ptr += sprintf(ptr, "CHGR Curr.: %d mA\n", batt->current_charging); ptr += sprintf(ptr, "AD32 : %d\n", batt->adc_vbat_3_2); ptr += sprintf(ptr, "AD42 : %d\n", batt->adc_vbat_4_2); ptr += sprintf(ptr, "CurAD : %d\n", batt->adc_vbat_current); #ifdef FEATURE_FTM_PMIC_6329 ptr += sprintf(ptr, "FG_Current: %dmA\n", battery_fg_current); ptr += sprintf(ptr, "PMIC Chip : %s\n", (pmic_is_connect) ? "Connect" : "NO connect"); #endif #else ptr += sprintf(ptr, "BAT Volt. : %d mV\n", batt->bat_voltage); ptr += sprintf(ptr, "BAT Temp. : %d Celsius\n", batt->bat_temperature); ptr += sprintf(ptr, "CHGR : %s\n", (batt->is_charging) ? "YES" : "NO"); ptr += sprintf(ptr, "CHGR Volt.: %d mV\n", batt->charger_voltage); #ifdef FEATURE_FTM_PMIC_6329 ptr += sprintf(ptr, "BAT Curr.: %dmA\n", battery_fg_current); #endif #endif return; }