std::string interpolate_variables_into_string(const std::string &str, const variable_set& variables) { return do_interpolation(str, variables); }
std::string interpolate_variables_into_string(const std::string &str, const std::map<std::string,std::string> * const symbols) { auto set = string_map_variable_set<std::string>(*symbols); return do_interpolation(str, set); }
std::string interpolate_variables_into_string(const std::string &str, const string_map * const symbols) { string_map_variable_set set(*symbols); return do_interpolation(str, set); }
static int d2199_read_voltage(struct sec_fuelgauge_info *fuelgauge) { int new_vol_adc, base_weight, new_vol_orign = 0; int offset_with_new = 0; int ret = 0; //static int calOffset_4P2, calOffset_3P4 = 0; int num_multi = 0; int orign_offset = 0; u8 ta_status = 0; if(fuelgauge->info.volt_adc_init_done == FALSE ) { ta_status = adc_read_reg(fuelgauge, D2199_STATUS_C_REG); pr_debug("%s. STATUS_C register = 0x%X\n", __func__, ta_status); if(ta_status & D2199_GPI_3_TA_MASK) fuelgauge->is_charging = 1; else fuelgauge->is_charging = 0; } pr_debug("##### is_charging mode = %d\n", fuelgauge->is_charging); // Read voltage ADC ret = fuelgauge->info.d2199_read_adc(fuelgauge, D2199_ADC_VOLTAGE); pr_debug("[%s]READ_EOC = %d\n", __func__, fuelgauge->info.adc_res[D2199_ADC_VOLTAGE].is_adc_eoc); pr_debug("[%s]READ_ADC = %d\n", __func__, fuelgauge->info.adc_res[D2199_ADC_VOLTAGE].read_adc); if(ret < 0) return ret; if(fuelgauge->info.adc_res[D2199_ADC_VOLTAGE].is_adc_eoc) { int offset = 0; new_vol_orign = new_vol_adc = fuelgauge->info.adc_res[D2199_ADC_VOLTAGE].read_adc; if(fuelgauge->info.volt_adc_init_done) { // Initialization is done if(fuelgauge->is_charging) { // In case of charge. orign_offset = new_vol_adc - fuelgauge->info.average_volt_adc; base_weight = d2199_get_weight_from_lookup( C2K(fuelgauge->info.average_temperature), fuelgauge->info.average_volt_adc, fuelgauge->is_charging, orign_offset); offset_with_new = orign_offset * base_weight; fuelgauge->info.sum_total_adc += offset_with_new; num_multi = fuelgauge->info.sum_total_adc / NORM_CHG_NUM; if(num_multi) { fuelgauge->info.average_volt_adc += num_multi; fuelgauge->info.sum_total_adc = fuelgauge->info.sum_total_adc % NORM_CHG_NUM; } else { new_vol_adc = fuelgauge->info.average_volt_adc; } fuelgauge->info.current_volt_adc = new_vol_adc; } else { // In case of discharging. orign_offset = fuelgauge->info.average_volt_adc - new_vol_adc; base_weight = d2199_get_weight_from_lookup( C2K(fuelgauge->info.average_temperature), fuelgauge->info.average_volt_adc, fuelgauge->is_charging, orign_offset); offset_with_new = orign_offset * base_weight; if(fuelgauge->info.reset_total_adc) { fuelgauge->info.sum_total_adc = fuelgauge->info.sum_total_adc / 10; fuelgauge->info.reset_total_adc = 0; pr_debug("%s. sum_toal_adc was divided by 10\n", __func__); } fuelgauge->info.sum_total_adc += offset_with_new; pr_debug("Discharging. Recalculated base_weight = %d\n", base_weight); num_multi = fuelgauge->info.sum_total_adc / NORM_NUM; if(num_multi) { fuelgauge->info.average_volt_adc -= num_multi; fuelgauge->info.sum_total_adc = fuelgauge->info.sum_total_adc % NORM_NUM; } else { new_vol_adc = fuelgauge->info.average_volt_adc; } if(is_called_by_ticker == 0) { fuelgauge->info.current_volt_adc = new_vol_adc; } else { fuelgauge->info.current_volt_adc = new_vol_adc; is_called_by_ticker=0; } } } else { // Before initialization u8 i = 0; u8 res_msb, res_lsb, res_msb_adc, res_lsb_adc = 0; u32 capacity = 0, vbat_adc = 0; int convert_vbat_adc, X1, X0; int Y1, Y0 = FIRST_VOLTAGE_DROP_ADC; int X = C2K(fuelgauge->info.average_temperature); // If there is SOC data in the register // the SOC(capacity of battery) will be used as initial SOC res_lsb = adc_read_reg(fuelgauge, D2199_GP_ID_2_REG); res_msb = adc_read_reg(fuelgauge, D2199_GP_ID_3_REG); capacity = (((res_msb & 0x0F) << 8) | (res_lsb & 0xFF)); res_lsb_adc = adc_read_reg(fuelgauge, D2199_GP_ID_4_REG); res_msb_adc = adc_read_reg(fuelgauge, D2199_GP_ID_5_REG); vbat_adc = (((res_msb_adc & 0x0F) << 8) | (res_lsb_adc & 0xFF)); pr_debug("%s. capacity = %d, vbat_adc = %d \n", __func__, capacity, vbat_adc); if(capacity) { convert_vbat_adc = vbat_adc; pr_info("!#!#!# Boot BY Normal Power Off !#!#!# \n"); } else { // Initial ADC will be decided in here. pr_info("!#!#!# Boot BY Battery insert !#!#!# \n"); fuelgauge->info.pd2199->average_vbat_init_adc = (fuelgauge->info.pd2199->vbat_init_adc[0] + fuelgauge->info.pd2199->vbat_init_adc[1] + fuelgauge->info.pd2199->vbat_init_adc[2]) / 3; vbat_adc = fuelgauge->info.pd2199->average_vbat_init_adc; pr_debug("%s (L_%d). vbat_init_adc = %d, new_vol_orign = %d\n", __func__, __LINE__, fuelgauge->info.pd2199->average_vbat_init_adc, new_vol_orign); if(fuelgauge->is_charging) { if(vbat_adc < CHARGE_ADC_KRNL_F) { // In this case, vbat_adc is bigger than OCV // So, subtract a interpolated value // from initial average value(vbat_adc) u16 temp_adc = 0; if(vbat_adc < CHARGE_ADC_KRNL_H) vbat_adc = CHARGE_ADC_KRNL_H; X0 = CHARGE_ADC_KRNL_H; X1 = CHARGE_ADC_KRNL_L; Y0 = CHARGE_OFFSET_KRNL_H; Y1 = CHARGE_OFFSET_KRNL_L; temp_adc = do_interpolation(X0, X1, Y0, Y1, vbat_adc); convert_vbat_adc = vbat_adc - temp_adc; } else { convert_vbat_adc = new_vol_orign + CHARGE_OFFSET_KRNL2; } } else { vbat_adc = new_vol_orign; pr_debug("[L%d] %s discharging new_vol_adc = %d\n", __LINE__, __func__, vbat_adc); Y0 = FIRST_VOLTAGE_DROP_ADC; if(C2K(fuelgauge->info.average_temperature) <= BAT_LOW_LOW_TEMPERATURE) { convert_vbat_adc = vbat_adc + (Y0 + FIRST_VOLTAGE_DROP_LL_ADC); } else if(C2K(fuelgauge->info.average_temperature) >= BAT_ROOM_TEMPERATURE) { convert_vbat_adc = vbat_adc + Y0; } else { if(C2K(fuelgauge->info.average_temperature) <= BAT_LOW_MID_TEMPERATURE) { Y1 = Y0 + FIRST_VOLTAGE_DROP_ADC; Y0 = Y0 + FIRST_VOLTAGE_DROP_LL_ADC; X0 = BAT_LOW_LOW_TEMPERATURE; X1 = BAT_LOW_MID_TEMPERATURE; } else if(C2K(fuelgauge->info.average_temperature) <= BAT_LOW_TEMPERATURE) { Y1 = Y0 + FIRST_VOLTAGE_DROP_L_ADC; Y0 = Y0 + FIRST_VOLTAGE_DROP_ADC; X0 = BAT_LOW_MID_TEMPERATURE; X1 = BAT_LOW_TEMPERATURE; } else { Y1 = Y0 + FIRST_VOLTAGE_DROP_RL_ADC; Y0 = Y0 + FIRST_VOLTAGE_DROP_L_ADC; X0 = BAT_LOW_TEMPERATURE; X1 = BAT_ROOM_LOW_TEMPERATURE; } convert_vbat_adc = vbat_adc + Y0 + ((X - X0) * (Y1 - Y0)) / (X1 - X0); } } } new_vol_adc = convert_vbat_adc; pr_info("%s. # Calculated initial new_vol_adc = %d\n", __func__, new_vol_adc); if(new_vol_adc > MAX_FULL_CHARGED_ADC) { new_vol_adc = MAX_FULL_CHARGED_ADC; pr_debug("%s. Set new_vol_adc to max. ADC value\n", __func__); } for(i = AVG_SIZE; i ; i--) { fuelgauge->info.voltage_adc[i-1] = new_vol_adc; fuelgauge->info.sum_voltage_adc += new_vol_adc; } fuelgauge->info.current_volt_adc = new_vol_adc; fuelgauge->info.volt_adc_init_done = TRUE; fuelgauge->info.average_volt_adc = new_vol_adc; } fuelgauge->info.origin_volt_adc = new_vol_orign; fuelgauge->info.current_voltage = adc_to_vbat(fuelgauge->info.current_volt_adc, fuelgauge->is_charging); fuelgauge->info.average_voltage = adc_to_vbat(fuelgauge->info.average_volt_adc, fuelgauge->is_charging); }else { pr_err("%s. Voltage ADC read failure \n", __func__); ret = -EIO; } pr_debug("[%s]current volt_adc = %d, average_volt_adc = %d\n", __func__, fuelgauge->info.current_volt_adc, fuelgauge->info.average_volt_adc); pr_debug("[%s]current voltage = %d, average_voltage = %d\n", __func__, fuelgauge->info.current_voltage, fuelgauge->info.average_voltage); return ret; }