Exemple #1
0
Fichier : rtc.c Projet : nis/EMP
void update_clock(void)
/*****************************************************************************
*   Function : See module specification (.h-file).
*****************************************************************************/
{
	INT8U state_changes = get_button_count();
	if(state_changes > 0)
	{
		update_normal(); // To get rid of any lingering boxes in the LCD.
		change_state(state_changes);
	}
	
	INT8S edit_counter = get_digiswitch_counter();
	
	switch ( rtc_state )
	{
		case RTC_NORMAL:
			update_normal();
			break;
			
		case RTC_EDIT_HOURS:
			adjust_hours(edit_counter);
			update_edit_hours();
			break;
			
		case RTC_EDIT_MINUTES:
			adjust_minutes(edit_counter);
			update_edit_minutes();
			break;
			
		case RTC_EDIT_SECONDS:
			adjust_seconds(edit_counter);
			update_edit_seconds();
			break;
			
		default:
			break;
	}

	
	// Wait 1/2 sec.
	_wait(MILLI_SEC(330));
}
Exemple #2
0
void reduction_entropy::
update_surfel_attributes(shared_surfel target_surfel_ptr, 
                         shared_entropy_surfel_vector const invalidated_neighbours) const {

    update_normal(target_surfel_ptr, invalidated_neighbours);
    update_color(target_surfel_ptr, invalidated_neighbours);

    // position needs to be updated before the radius is updated
    update_position(target_surfel_ptr, invalidated_neighbours);
    update_radius(target_surfel_ptr, invalidated_neighbours);
}
int update_from_normal_mode(void)
{
    int cell_type=0;
    int curr_cell_type=TYPE_LG, fw_cell_type=TYPE_LG;
    int ret = UPDATE_NONE;
    int curr_volt;
    int i,j;
    int fw_cfg_version;

    BAT_DBG("(%s) enter\n", __func__);

#if 0
    curr_cell_type = bq27520_batt_current_sel_type();
#endif
    fw_cell_type = bq27520_batt_fw_sel_type();
    curr_volt = bq27520_asus_battery_dev_read_volt();
    fw_cfg_version = bq27520_asus_battery_dev_read_fw_cfg_version();

    BAT_DBG("(%s) current_cell_type %d, fw_cell_type %d, current_volt %d, fw_cfg_version 0x%04X\n",
            __func__,
            curr_cell_type, fw_cell_type, curr_volt, fw_cfg_version
    );

    if (curr_cell_type == fw_cell_type) {
        if (fw_cfg_version == LATEST_FW_CFG_VERSION) {
            BAT_DBG(" No need to flash battery cell data due to that both firmware config version are equal");
            return ret;
        }
    }

    //Need update, check update voltage
    ret = UPDATE_VOLT_NOT_ENOUGH;
    if (curr_volt < 0 || curr_volt < 3700) {
        BAT_DBG_E("Voltage not enough \n");
        return ret;
    }

    ret = update_normal(curr_cell_type);

    return ret;
}
int update_from_normal_mode(bool forceupdate) {

    int curr_cell_type=TYPE_LG, fw_cell_type=TYPE_LG;
    int ret = UPDATE_NONE;
    int curr_volt;
    int fw_cfg_version;

    BAT_DBG("(%s) enter\n", __func__);

#if 0
    curr_cell_type = bq27520_batt_current_sel_type();
#endif
    fw_cell_type = bq27520_batt_fw_sel_type();
    curr_volt = bq27520_asus_battery_dev_read_volt();
    fw_cfg_version = bq27520_asus_battery_dev_read_fw_cfg_version();

    BAT_DBG("(%s) current_cell_type %d, fw_cell_type %d, current_volt %d, fw_cfg_version 0x%04X\n",
            __func__,
            curr_cell_type, fw_cell_type, curr_volt, fw_cfg_version
    );

    if (!forceupdate) {
         if (fw_cfg_version == LATEST_FW_CFG_VERSION) {
                BAT_DBG("========= No need to flash battery cell data due to that both data flash version are equal =========");
                goto Done;
         }
    }

    //Need update, check update voltage
    ret = UPDATE_VOLT_NOT_ENOUGH;
    if (curr_volt < 0 || curr_volt < 3700) {
        BAT_DBG_E("Voltage not enough \n");
        goto Done;
    }

    if (batt_info.gauge_version == IC_VERSION_G3) {
        BAT_DBG("bq27520 gauge is G3, no need enter ROM mode.\n");

    } else if (batt_info.gauge_version == IC_VERSION_G4) {
        //unseal for enter rom mode
        ret = bq27520_default_unseal();
        if (ret < 0) {
           // default password unseal fail
           BAT_DBG_E("bq27520_default_unseal fail !!!!\n");
           bq27520_rom_mode_wait(5000);
           ret = bq27520_ME560CG_unseal();
           if (ret < 0) {
              // ME560CG password unseal fail
              BAT_DBG_E("bq27520_ME560CG_unseal fail !!!!\n");
              ret = UPDATE_CHECK_MODE_FAIL;
              goto Done;
          }
       }
    }

    smb347_charging_toggle(false);
    ret = update_normal(curr_cell_type);
    smb347_charging_toggle(true);

Done:
    flash_gauge_status = ret;
    return ret;
}