Пример #1
0
static int board_probe_bat_status(int standby_mode)
{
	int   bat_cal = 1;
	int   ret, chargemode = 0;
	//当前可以确定是火牛开机,但是是否开机还不确定,需要确认电池是否存在
	//当电池不存在即开机,电池存在则关机
	//新添加,根据环境变量,是启动当前的待机,或者android待机功能
	ret = script_parser_fetch("charging_type", "charging_type", &chargemode, 1);
	if((!ret) && chargemode)
	{
		gd->chargemode = 1;

		return 0;
	}
	if(battery_charge_cartoon_init(0) < 0)
	{
		tick_printf("init charge cartoon fail\n");

		return -1;
	}
	bat_cal = axp_probe_rest_battery_capacity();
	printf("bat not inited\n");
	if(battery_charge_cartoon_init(bat_cal/(100/(SUNXI_BAT_BMP_MAX-1))) < 0)
	{
		tick_printf("init charge cartoon fail\n");

		return -1;
	}
	if((!bat_cal) && (standby_mode))
	{
		bat_cal = 100;
	}

	return bat_cal;
}
Пример #2
0
static int board_probe_bat_status(int standby_mode)
{
	int   dc_exist, bat_exist, counter;
	int   bat_init = 0;
	int   bat_cal = 1;
	int   ret, chargemode = 0;
	//当前可以确定是火牛开机,但是是否开机还不确定,需要确认电池是否存在
	//当电池不存在即开机,电池存在则关机
	//新添加,根据环境变量,是启动当前的待机,或者android待机功能
	ret = script_parser_fetch("charging_type", "charging_type", &chargemode, 1);
	if((!ret) && chargemode)
	{
		chargemode = 1;
	}

	counter = 4;
	do
	{
		dc_exist = 0;
		bat_exist = 0;
		axp_power_get_dcin_battery_exist(&dc_exist, &bat_exist);
		printf("bat_exist=%d\n", bat_exist);
		if(bat_exist == -1)
		{
			printf("bat is unknown\n");
			if(!chargemode)
			{
				if(!bat_init)
				{
					if(battery_charge_cartoon_init(0) < 0)
					{
						tick_printf("init charge cartoon fail\n");

						return -1;
					}
					bat_init = 1;
				}
			}
			__msdelay(500);
		}
		else
		{
			break;
		}
	}
	while(counter --);
#ifdef FORCE_BOOT_STANDBY
	bat_exist = 1;
#else
	if(standby_mode)
	{
		bat_exist = 1;
	}
#endif
	if(bat_exist <= 0)
	{
		tick_printf("no battery exist\n");
		if(chargemode)
		{
			return 0;
		}
		if(bat_init)
		{
			battery_charge_cartoon_exit();
		}
		return 0;
	}
	if(chargemode)
	{
		printf("use android charge mode");
		gd->chargemode = 1;

		return 0;
	}
	if(!bat_init)
	{
		bat_cal = axp_probe_rest_battery_capacity();
		printf("bat not inited\n");
		if(battery_charge_cartoon_init(bat_cal/(100/(SUNXI_BAT_BMP_MAX-1))) < 0)
		{
			tick_printf("init charge cartoon fail\n");

			return -1;
		}
	}
	if((!bat_cal) && (standby_mode))
	{
		bat_cal = 100;
	}

	return bat_cal;
}