Exemple #1
0
static void do_battery_test(fwts_framework *fw, const uint32_t index)
{
	char name[PATH_MAX];
	char state[1024];

	*state = '\0';

	fwts_battery_get_name(fw, index, name);

	fwts_log_info(fw, "Test battery '%s'.", name);

	fwts_printf(fw, "==== Please PLUG IN the AC power of the machine ====\n");
	fwts_press_enter(fw);

	fwts_printf(fw, "==== Please now UNPLUG the AC power of the machine ====\n");
	wait_for_acpi_event(fw, name);
	check_discharging(fw, index, name);
	fwts_printf(fw, "==== Please wait 30 seconds while the battery is discharged a little ====\n");
	battery_discharge(fw, 30);
	fwts_printf(fw, "==== Please now PLUG IN the AC power of the machine ====\n");
	wait_for_acpi_event(fw, name);
	check_charging(fw, index, name);
	check_battery_cycle_count(fw, index, name);
	check_battery_trip_point(fw, index, name);
}
Exemple #2
0
int main(void)
{
    // Hardware Init
    delay_init();	    	 //ÑÓʱº¯Êý³õʼ»¯
    pwr_init();
    #ifdef YANMING3
    charger_init();
    if (check_standby_flag() == SUCCESS && check_charging() != CHARGING) {
        Key_GPIO_Config();
        exti_key_init();
        #ifdef DEBUG_POWER_OFF_WAKE_UP
        Screen_Init();
        OLED_Clear();
        OLED_Display_On();
        draw_about_mesage();
        #endif
        check_standby_wakeup_button_press();
        // If we boot up from standby by pressing 5 times, the system will reboot again without
        // this code block.
    }
    #endif

    // OLED Init
    Screen_Init();
    OLED_Clear();
    
    //
    low_switch_power_init();

    TIMx_Int_DeInit();
    EXTIX_DeInit();
    
    // Key
    Key_GPIO_Config();
    
    // PID related code
    ADC1_Configuration();
    PWM_Configuration();
    VoltagePID_Init();

    TIMx_Int_Init();
    rtc_init();

    // Our Init
    system_init();
    #ifndef YANMING3
    //iwdg_init();
    #endif

    while(1) {
        #ifndef YANMING3
        //iwdg_feed();
        #endif
        task_schedule();
    }
}
Exemple #3
0
void EXTI4_15_IRQHandler(void)
{
    if (EXTI_GetIntBitState(CHARGING_EXTILINE) != RESET) {
        if (check_charging() == CHARGING && get_charger_plug_flag() == CHARGER_UNPLUGGED) {
            set_charger_plug_flag();
            reboot_system(SUCCESS);
        }
        EXTI_ClearIntBitState(CHARGING_EXTILINE);
    }
}
Exemple #4
0
int determine_boot_type(void)
{
	DECLARE_GLOBAL_DATA_PTR;
	uint8_t charging;
	uint16_t batt_lvl;
	extern uint16_t check_charging(uint8_t* enabling);
	unsigned long bootcount = bootcount_load();
	char s [5];

	setenv("bootlimit", stringify(ACCLAIM_BOOTLIMIT));
	setenv("altbootcmd", "mmcinit 1; booti mmc1 recovery");
	batt_lvl = check_charging(&charging);
	lcd_console_init();
	// give subtle indicator if uboot is booting from emmc or sd

	if(charging)
		lcd_bl_set_brightness(35); //batt very low, let it charge
	lcd_console_setpos(0, 1); //indent slightly
	lcd_console_setcolor(CONSOLE_COLOR_GRAY, CONSOLE_COLOR_BLACK);
	if (running_from_sd()) {
		lcd_puts("SD");
		} else {
		lcd_puts("EMMC"); }
	sprintf(s, " %u", bootcount);
	lcd_puts(s);
	extern const char* board_rev_string(unsigned long btype);
	lcd_console_setpos(1, 1);
	lcd_printf("board rev: %s | %s", board_rev_string(gd->bd->bi_board_revision), (get_sdram_size() == SZ_512M?"512MB/8GB":"1GB/16GB"));
	lcd_console_setpos(2, 1);
	lcd_console_setcolor((batt_lvl < 30?(batt_lvl <= 10?CONSOLE_COLOR_RED:CONSOLE_COLOR_ORANGE):CONSOLE_COLOR_GREEN), CONSOLE_COLOR_BLACK);
	lcd_printf("batt level: %d\n charging %s", batt_lvl, (charging?"ENABLED":"DISABLED"));


	int action = get_boot_action();

	while(1){
		if(charging)
			lcd_bl_set_brightness(35); //batt very low, let it charge
		else
			lcd_bl_set_brightness(100); //batt very low, let it charge
		switch(action) {
		case BOOT_SD_NORMAL:
			setenv ("bootcmd", "setenv setbootargs setenv bootargs ${sdbootargs}; run setbootargs; mmcinit 0; fatload mmc 0:1 0x81000000 boot.img; booti 0x81000000");
			setenv ("altbootcmd", "run bootcmd"); // for sd boot altbootcmd is the same as bootcmd
			display_feedback(BOOT_SD_NORMAL);
			return 0;

        case BOOT_SD_RECOVERY:
            setenv ("bootcmd", "setenv setbootargs setenv bootargs ${sdbootargs}; run setbootargs; mmcinit 0; fatload mmc 0:1 0x81000000 recovery.img; booti 0x81000000");
            setenv ("altbootcmd", "run bootcmd"); // for sd boot altbootcmd is the same as bootcmd
			display_feedback(BOOT_SD_RECOVERY);
            return 0;

		case BOOT_SD_ALTBOOT:
			setenv ("bootcmd", "setenv setbootargs setenv bootargs ${sdbootargs}; run setbootargs; mmcinit 0; fatload mmc 0:1 0x81000000 altboot.img; booti 0x81000000");
			setenv ("altbootcmd", "run bootcmd"); // for sd boot altbootcmd is the same as bootcmd
			display_feedback(BOOT_SD_ALTBOOT);
			return 0;

	        //actually, boot from boot+512K -- thanks bauwks!
		case BOOT_EMMC_NORMAL:
			setenv("bootcmd", "mmcinit 1; booti mmc1 boot 0x80000");
			display_feedback(BOOT_EMMC_NORMAL);
			return 0;

		//actually, boot from recovery+512K -- thanks bauwks!
		case BOOT_EMMC_RECOVERY:
			setenv("bootcmd", "mmcinit 1; booti mmc1 recovery 0x80000");
			display_feedback(BOOT_EMMC_RECOVERY);
			return 0;

		case BOOT_EMMC_ALTBOOT:  // no 512K offset, this is just a file.
			setenv ("bootcmd", "setenv setbootargs setenv bootargs ${emmcbootargs}; run setbootargs; mmcinit 1; fatload mmc 1:5 0x81000000 altboot.img; booti 0x81000000");
			setenv ("altbootcmd", "run bootcmd"); // for emmc altboot altbootcmd is the same as bootcmd
			display_feedback(BOOT_EMMC_ALTBOOT);
			return 0;

		case BOOT_FASTBOOT:
			display_feedback(BOOT_FASTBOOT);
            run_command("fastboot", 0);
			break;
		case INVALID:
		default:
			printf("Aborting boot!\n");
			return 1;
		}
		action = do_menu();
	}
}