Esempio n. 1
0
/*
*******************************************************************************
*                     ShowPictureEx
*
* Description:
*   把图片数据解析到指定的地址中,并且显示出来.
* 如果指定的地址为NULL, 则可以存放在任何地址。
*
* Parameters:
*   Para  	:  input.  Boot阶段的参数。
*   Path 	:  input.  图片存放在介质中的位置,如“c:\logo.bmp”
*   Addr	:  input.  存放解析后的图片,
*
* Return value:
*    0  :  成功
*   !0  :  失败
*
* note:
*   void
*
*******************************************************************************
*/
__u32 ShowPictureEx(char *Path, __u32 address)
{
	Picture_t PictureInfo;
	__s32 ret = 0;
	display_layer_info_t *layer_para = NULL;

	/* 参数初始化 */
	if(!board_res.layer_hd)
    {
        return 0;
    }
	memset(&PictureInfo, 0, sizeof(Picture_t));

	ret = Parse_Pic_BMP_ByPath(Path, &PictureInfo, address);
	if(ret != 0)
	{
		DMSG_PANIC("ERR: Parse_Pic_BMP failed\n");
		goto error;
	}

	/* 显示图片 */
	layer_para = ui_AllocLayerPara(&PictureInfo);
	ShowLayer(board_res.layer_hd, layer_para, board_res.display_source);
    #ifndef SPEED_UP_BOOT
	wBoot_timer_delay(50);
    #endif
    return (__u32)layer_para;

error:

	return 0;
}
Esempio n. 2
0
/*
*******************************************************************************
*                     WaitForDeInitFinish
*
* Description:
*   等待de初始化完毕
*
* Parameters:
*   void
*
* Return value:
*    0  :  成功
*   !0  :  失败
*
* note:
*   void
*
*******************************************************************************
*/
__s32 WaitForDeInitFinish(void)
{
	__s32 ret;
	__s32 timedly = 2000;
	__s32 check_time = timedly/50;

	do
	{
		ret = De_IsLCDOpen();
		if(ret == 1)
		{
			break;
		}
		else if(ret == -1)
		{
			return -1;
		}
		wBoot_timer_delay(50);
		check_time --;
		if(check_time <= 0)
		{
			return -1;
		}
	}
	while(1);

	return 0;

}
Esempio n. 3
0
/*
*******************************************************************************
*                     ShowPicture
*
* Description:
*   以图片的存储路径来显示一张图片
*
* Parameters:
*   Path    :  需要显示的图片路径,只支持BMP格
*   picture_group : 图片个数,最多同时有8个
*   show_way:  显示方式       参数保留,暂时不支持
*              要求所有图片的大小一致
* Return value:
*    0  :  成功
*   !0  :  失败
*
* note:
*   void
*
*******************************************************************************
*/
__s32 LCD_DisplayInit(void)
{
    __u32 	   screen_width = 0;
    char       font_name[16];

    display_layer_info_t *layer_para = NULL;
    /* 参数初始化 */
    memset(&display_info, 0, sizeof(display_info_set_t));
    memset(font_name, 0, 16);
	//获取字体大小
	screen_width = De_GetSceenWidth();
	if(screen_width > 480)
	{
		WORD_SIZE = 32;
		strcpy(font_name, "c:\\font32.sft");
	}
	else
	{
		WORD_SIZE = 24;
		strcpy(font_name, "c:\\font24.sft");
    }
    //申请一个图层用于显示,并获取display buffer的地址
    layer_para = LCD_DisplayAllocLayerPara();
    if(!layer_para)
    {
        return -1;
    }
    open_font(font_name, WORD_SIZE, display_info.screen_width,  display_info.screen_buf);   //打开字库
    /* 显示图片 */
	ShowLayer(board_res.layer_hd, layer_para);
    wBoot_timer_delay(50);

	return 0;
}
Esempio n. 4
0
__s32 ui_release_resource(__hdle show_hd)
{
    ui_show_multi_set_t *pic_info = (ui_show_multi_set_t *)show_hd;
    __u32  i, j;
    __s32  *addr;

    if(!show_hd)
    {
        return -1;
    }
    De_CloseLayer(board_res.layer_hd);
    addr = (__s32 *)pic_info->lcd_info.display_buffer;
    for(i=0;i<pic_info->lcd_info.lcd_height;i++)
    {
        for(j=0;j<pic_info->lcd_info.lcd_width;j++)
        {
            *addr = 0xff000000;
            addr ++;
        }
    }
    wBoot_free(pic_info->layer_para);
    wBoot_free(pic_info);
    wBoot_timer_delay(50);

    return 0;
}
Esempio n. 5
0
//重置图形,使所有显示的图形回复到第0副图
__s32 ui_reset_pic(__hdle show_hd)
{
    ui_show_multi_set_t  *pic_info = (ui_show_multi_set_t *)show_hd;
    char  *base_tmp_addr, *tmp_addr, *tmp_pic_addr;
    __u32  tmp_top, pic_width, pic_height;
    __u32  i, j;

    if(!show_hd)
    {
        return -1;
    }
    pic_width  = pic_info->pic[0].PictureInfo[0].Width;
    pic_height = pic_info->pic[0].PictureInfo[0].Height;

    tmp_top  = ( pic_info->lcd_info.lcd_height - pic_height)>>1;
    base_tmp_addr = (char *)pic_info->lcd_info.display_buffer;
    base_tmp_addr += tmp_top * pic_info->lcd_info.lcd_width * 4;
    //开始贴图
    for(i=0;i<pic_info->pic_total;i++)
    {
        tmp_addr = base_tmp_addr + (pic_info->pic[i].left<<2);
        tmp_pic_addr = (char *)pic_info->pic[i].PictureInfo[0].Buffer;
        for(j=0;j<pic_height;j++)
        {
            memcpy(tmp_addr, tmp_pic_addr, pic_width << 2);
            tmp_addr += pic_info->lcd_info.lcd_width * 4;
            tmp_pic_addr += pic_width << 2;
        }
        pic_info->pic[i].pic_turn = 0;
    }

    wBoot_timer_delay(75);

    return 0;
}
Esempio n. 6
0
static int shut_battery_full(void)
{
    int  alpha_step, i;
    int  aplha, delay_time;
    display_layer_info_t *layer_para;

    if(!pic_layer_para)
    {
        return -1;
    }
    layer_para = (display_layer_info_t *)pic_layer_para;
    alpha_step = 5;
    delay_time = 50;
    aplha = layer_para->alpha_val;

    for(i=0xff; i>0; i -= alpha_step)
    {
        layer_para->alpha_en = 1;
        aplha -= alpha_step;
        if(aplha > 0)
        {
            De_SetLayerPara(board_res.layer_hd, layer_para);
            wBoot_timer_delay(delay_time);
            layer_para->alpha_val = aplha;
        }
        else
        {
            break;
        }
    }

    return 0;
}
Esempio n. 7
0
void LCD_delay_ms(__u32 ms)
{
#ifdef __LINUX_OSAL__
    __u32 timeout = ms*HZ/1000;

    set_current_state(TASK_INTERRUPTIBLE);
    schedule_timeout(timeout);
#endif
#ifdef __BOOT_OSAL__
    wBoot_timer_delay(ms);//assume cpu runs at 1000Mhz,10 clock one cycle
#endif
}
void system_reset(void)
{
	WATCHDOG_REG_CTRL = 0xA57<<1;
    WATCHDOG_REG_CTRL &= ~1;
    WATCHDOG_REG_CTRL = 0;
    WATCHDOG_REG_MODE = 0x13;
    WATCHDOG_REG_MODE = 0x0;
    //开始重启
	wBoot_block_exit();
	WATCHDOG_REG_MODE = 0x3;
	wBoot_timer_delay(50);
	while(1);
}
Esempio n. 9
0
int ShowBatteryCharge_reset(__u32 pic_hd)
{
	bat_charge_show *battery_info = NULL;

	if(!pic_hd)
    {
        return -1;
    }

	battery_info = (bat_charge_show *)pic_hd;

    battery_info->layer_para->alpha_en = 1;
    battery_info->layer_para->alpha_val = 255;
    wBoot_timer_delay(50);
    De_SetLayerPara(board_res.layer_hd, battery_info->layer_para);
}
Esempio n. 10
0
//每个OS可以使用最多4个贴图,当选中任意一个OS的时候,使用
//当前OS的贴图轮流贴,呈现闪烁的效果
__s32 ui_coruscate_pic(__hdle show_hd, __u32 sel_num)
{
    ui_show_multi_set_t  *pic_info = (ui_show_multi_set_t *)show_hd;
    __u32 tmp_pic_index;
    char  *base_tmp_addr, *tmp_addr, *tmp_pic_addr;
    __u32  tmp_top, pic_width, pic_height;
    __u32  j;

    if(!show_hd)
    {
        return -1;
    }
    if(sel_num >= pic_info->pic_total)
    {
        return -1;
    }
    //获取当前显示图片的顺序
    tmp_pic_index = pic_info->pic[sel_num].pic_turn;

    pic_width  = pic_info->pic[0].PictureInfo[0].Width;
    pic_height = pic_info->pic[0].PictureInfo[0].Height;

    tmp_top  = ( pic_info->lcd_info.lcd_height - pic_height)>>1;
    base_tmp_addr = (char *)pic_info->lcd_info.display_buffer;
    base_tmp_addr += tmp_top * pic_info->lcd_info.lcd_width * 4;
    //开始贴图
    tmp_addr = base_tmp_addr + (pic_info->pic[sel_num].left<<2);
    tmp_pic_addr = (char *)pic_info->pic[sel_num].PictureInfo[tmp_pic_index].Buffer;
    for(j=0;j<pic_height;j++)
    {
        memcpy(tmp_addr, tmp_pic_addr, pic_width << 2);
        tmp_addr += pic_info->lcd_info.lcd_width * 4;
        tmp_pic_addr += pic_width << 2;
    }
    //调整下次的顺序
    tmp_pic_index ++;
    if(tmp_pic_index >= pic_info->pic[sel_num].valid_num)
    {
        tmp_pic_index = 0;
    }
    pic_info->pic[sel_num].pic_turn = tmp_pic_index;

    wBoot_timer_delay(250);

    return 0;
}
Esempio n. 11
0
__s32 ShowBatteryCharge_degrade(__u32 pic_hd, int step_time)
{
	bat_charge_show *battery_info = NULL;
	int  alpha_step, i;
	int  aplha, delay_time;

	if(!pic_hd)
    {
        return -1;
    }
//    if(step_time <= 0)
//    {
//    	step_time = 10;
//    }
//    else if(step_time > 10)
//    {
//    	step_time = 10;
//    }
    battery_info = (bat_charge_show *)pic_hd;
	alpha_step = 5;
	delay_time = 50;
	aplha = battery_info->layer_para->alpha_val;

	for(i=0xff;i>0;i -= alpha_step)
	{
		battery_info->layer_para->alpha_en = 1;
		aplha -= alpha_step;
		if(aplha > 0)
		{
			De_SetLayerPara(board_res.layer_hd, battery_info->layer_para);
			wBoot_timer_delay(delay_time);
			battery_info->layer_para->alpha_val = aplha;

		}
		else
		{
			break;
		}
	}

	return 0;
}
Esempio n. 12
0
__s32 ShowBatteryCharge_degrade(__u32 pic_hd, int step_time)
{
	bat_charge_show *battery_info = NULL;
	int  alpha_step;
	int  alpha, delay_time;
	//int  i;

	if(!pic_hd)
    {
        return -1;
    }

    battery_info = (bat_charge_show *)pic_hd;
	alpha_step = 5;
	delay_time = 50;
	alpha = battery_info->layer_para->alpha_val;

	battery_info->layer_para->alpha_en = 1;
	alpha -= alpha_step;
	if(alpha > 0)
	{
		De_SetLayerPara(board_res.layer_hd, battery_info->layer_para);
		wBoot_timer_delay(delay_time);
		battery_info->layer_para->alpha_val = alpha;
	}
	else
	{
		return -1;
	}
//	else
//	{
//		break;
//	}
//	}

	return 0;
}
Esempio n. 13
0
/*
*******************************************************************************
*                     ShowPicture
*
* Description:
*   以图片的存储路径来显示一张图片
*
* Parameters:
*   Path    :  需要显示的图片路径,只支持BMP格
*   picture_group : 图片个数,最多同时有8个
*   show_way:  显示方式       参数保留,暂时不支持
*              要求所有图片的大小一致
* Return value:
*    0  :  成功
*   !0  :  失败
*
* note:
*   void
*
*******************************************************************************
*/
__hdle ShowMultiPicture(pic_name_info_t *pic_name_info, __u32 picture_group, __u32 show_way)
{
    __s32     ret;
    __u32     i, j = 0;
    __u32     tmp_left, tmp_top, tmp_width;
    char     *tmp_addr, *base_tmp_addr;
    char     *tmp_pic_addr;
    __u32     pic_width, pic_height;
    ui_show_multi_set_t  *pic_info = NULL;

    /* 参数初始化 */
    if(!board_res.layer_hd)
    {
        return (__hdle)0;
    }
	//寻找出所有的图片格式
	if(picture_group > 8)
	{
	    picture_group = 8;
	}
	pic_info = (ui_show_multi_set_t *)wBoot_malloc(sizeof(ui_show_multi_set_t));
	if(!pic_info)
	{
	    return (__hdle)0;
	}
	memset((void *)pic_info, 0, sizeof(ui_show_multi_set_t));
	pic_info->pic_total = picture_group;
	for(i=0;i<picture_group;i++)
	{
	    for(j=0;j<pic_name_info[i].valid_num;j++)
	    {
	        ret = Parse_Pic_BMP_ByPath(pic_name_info[i].name[j], &(pic_info->pic[i].PictureInfo[pic_info->pic[i].valid_num]), 0);
    	    if(ret)
            {
                __inf("decode %s bmp file failed\n", pic_name_info[i].name[j]);
            }
            else
            {
                pic_info->pic[i].valid_num ++;
            }
        }
	}
	//申请一个图层用于显示,并获取display buffer的地址
    pic_info->layer_para = ui_multi_AllocLayerPara((void *)&(pic_info->lcd_info), 0);
    //根据获取的用户数据,开始填充参数
    //暂时只做左右排列

    //按照从左到右摆放的方式,寻找每个编组的图应该在的位置
    pic_width    = pic_info->pic[0].PictureInfo[0].Width;
    pic_height   = pic_info->pic[0].PictureInfo[0].Height;

    tmp_top  = ( pic_info->lcd_info.lcd_height - pic_height)>>1;
    tmp_width= pic_info->lcd_info.lcd_width/picture_group;
    tmp_left = (tmp_width - pic_width)>>1;
    for(i=0;i<picture_group;i++)
    {
        pic_info->pic[i].left = tmp_left + i * tmp_width;
        pic_info->pic[i].top  = tmp_top;
    }
    //开始贴图,第一次
    base_tmp_addr = (char *)pic_info->lcd_info.display_buffer;
    base_tmp_addr += tmp_top * pic_info->lcd_info.lcd_width * 4;
    //开始一个图一个图的开始贴图
    for(i=0;i<picture_group;i++)
    {
        tmp_addr = base_tmp_addr + (pic_info->pic[i].left<<2);
        tmp_pic_addr = (char *)pic_info->pic[i].PictureInfo[0].Buffer;
        for(j=0;j<pic_height;j++)
        {
            memcpy(tmp_addr, tmp_pic_addr, pic_width << 2);
            tmp_addr += pic_info->lcd_info.lcd_width * 4;
            tmp_pic_addr += pic_width << 2;
        }
    }
	/* 显示图片 */
	ShowLayer(board_res.layer_hd, pic_info->layer_para, board_res.display_source);
    wBoot_timer_delay(50);

	return (__hdle)pic_info;
}
Esempio n. 14
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  : 0:正常启动
*			   -1:关机
*
*    说明    :如果是量产完成,直接关机
*
*
************************************************************************************************************
*/
__s32 check_power_status(void)
{
    __s32 status;
    __s32 power_start;

#ifdef CONFIG_AW_HOMELET_PRODUCT
    return 0;
#endif

    status = wBoot_power_get_level();
    if(status == BATTERY_RATIO_TOO_LOW_WITHOUT_DCIN)						//低电状态下,无外部电源,直接关机
    {
        __inf("battery low power with no dc or ac, should set power off\n");
        ShowPictureEx("c:\\os_show\\low_pwr.bmp", 0);
        wBoot_timer_delay(3000);

        return -1;
    }
    power_start = 0;
    // 0: 不允许插火牛直接开机,必须通过判断:满足以下条件可以直接开机:长按power按键,前次是系统状态,如果电池电量过低,则不允许开机
    // 1: 任意状态下,允许插火牛直接开机,同时要求电池电量足够高
    // 2: 不允许插火牛直接开机,必须通过判断:满足以下条件可以直接开机:长按power按键,前次是系统状态,不要求电池电量
    // 3: 任意状态下,允许插火牛直接开机,不要求电池电量
    if(wBoot_script_parser_fetch("target", "power_start", &power_start, 1))
    {
        power_start=0;
    }
    __debug("status=%d\n",status);
    switch(status)
    {
    case BATTERY_RATIO_ENOUGH:
        __inf("battery enough\n");
        break;
    case BATTERY_RATIO_TOO_LOW_WITH_DCIN:
        __inf("battery too low with dc\n");
        break;
    case BATTERY_RATIO_TOO_LOW_WITHOUT_DCIN:
        __inf("battery too low without dc\n");
        break;
    default:
        break;
    }
    __inf("power_start=%x\n", power_start);
    if(status == BATTERY_RATIO_TOO_LOW_WITH_DCIN)					//低电,同时带外部电源状态下
    {
        if(!(power_start & 0x02))	//需要判断当前电池电量,要求power_start的第1bit的值为0
        {   //此种情况下,直接关机
            __inf("battery low power with dc or ac, should charge longer\n");
            ShowPictureEx("c:\\os_show\\bempty.bmp", 0);
            wBoot_timer_delay(3000);

            return -1;
        }
        else
        {
            if(power_start == 3)	//不需要判断当前电池电量,如果为3,则进入系统,如果为0,则进行后续判断
            {
                return 0;
            }
        }
    }
    else							//电池电量足够情况下
    {
        if(power_start & 0x01)		//如果第0bit的值为1,则进入系统
        {
            return 0;
        }
    }								//其它情况下,进入后续判断

    status = -1;
    status = wBoot_power_check_startup();
#ifdef FORCE_BOOT_STANDBY
    status = 0;
#endif
    if(status)
    {
        return 0;
    }
    {

        __u32 dcin, bat_exist;
        __s32 bat_cal, this_bat_cal;
        __u32 bat_show_hd = NULL;
        int   i, j;
        int   bat_full_status = 0;
        //当前可以确定是火牛开机,但是是否开机还不确定,需要确认电池是否存在
        WaitForDeInitFinish();//等 LCD init结束,release hard timer.
        power_int_reg();
        usb_detect_enter();
        bat_show_hd = ShowBatteryCharge_init(0);

        //wBoot_timer_delay(1500);
        dcin = 0;
        bat_exist = 0;
        wBoot_power_get_dcin_battery_exist(&dcin, &bat_exist);
        if(!bat_exist)
        {
            __inf("no battery exist\n");
            ShowBatteryCharge_exit(bat_show_hd);
            power_int_rel();
            usb_detect_exit();

            return 0;
        }
        wlibc_int_disable();
        this_bat_cal = wBoot_power_get_cal();
        wlibc_int_enable();
        __inf("base bat_cal = %d\n", this_bat_cal);
        if(this_bat_cal > 95)
        {
            this_bat_cal = 100;
        }
        if(this_bat_cal == 100)
        {
            ShowBatteryCharge_exit(bat_show_hd);
            bat_show_hd = NULL;
            show_battery_full(&bat_full_status);
            for(i =0; i<12; i++)
            {
                if(power_ops_int_status & 0x02)	//短按
                {
                    power_ops_int_status &= ~0x02;
                    j = 0;
                    __inf("short key\n");
                }
                else if(power_ops_int_status & 0x01)	//长按
                {
                    wlibc_int_disable();
                    power_int_rel();
                    usb_detect_exit();
                    power_ops_int_status &= ~0x01;
                    wlibc_int_enable();
                    power_int_reg();
                    __inf("long key\n");

                    return 0;
                }
                wBoot_timer_delay(250);
            }
        }
        else
        {
            int one_delay;

            one_delay = 1000/(10 - (this_bat_cal/10));
            for(j=0; j<3; j++)
            {
                for(i=this_bat_cal; i<110; i+=10)
                {
                    ShowBatteryCharge_rate(bat_show_hd, i);
                    wBoot_timer_delay(one_delay);
                    if(power_ops_int_status & 0x02)	//短按
                    {
                        power_ops_int_status &= ~0x02;
                        j = 0;
                        __inf("short key\n");
                    }
                    else if(power_ops_int_status & 0x01)	//长按
                    {
                        ShowBatteryCharge_exit(bat_show_hd);
                        wlibc_int_disable();
                        power_int_rel();
                        usb_detect_exit();
                        power_ops_int_status &= ~0x01;
                        wlibc_int_enable();
                        power_int_reg();
                        __inf("long key\n");

                        return 0;
                    }
                }
            }
            ShowBatteryCharge_rate(bat_show_hd, this_bat_cal);
            wBoot_timer_delay(1000);
        }
        wBoot_power_get_key();
        __inf("extenal power low go high startup\n");
        /******************************************************************
        *
        *	standby 返回值说明
        *
        *	   -1: 进入standby失败
        *		1: 普通按键唤醒
        *		2: 电源按键短按唤醒
        *		3: 电源按键长按唤醒
        *		4: 外部电源移除唤醒
        *		5: 电池充电完成
        *		6: 在唤醒状态下外部电源被移除
        *		7: 在唤醒状态下充电完成
        *
        ******************************************************************/
        do
        {

            if(power_ops_int_status & 0x04)
            {
                status = 8;
                power_ops_int_status &= ~0x04;
            }
            else
            {
                wlibc_int_disable();
                power_int_rel();
                usb_detect_exit();
                wlibc_int_enable();
                De_CloseLayer(board_res.layer_hd);
                wBoot_EnableInt(GIC_SRC_NMI);
                __inf("enter standby\n");
                status = wBoot_standby();
                __inf("exit standby by %d\n", status);
                wBoot_DisableInt(GIC_SRC_NMI);

                wlibc_int_disable();
                bat_cal = wBoot_power_get_cal();
                wlibc_int_enable();
                __inf("current bat_cal = %d\n", bat_cal);
                if(bat_cal > this_bat_cal)
                {
                    this_bat_cal = bat_cal;
                    if(this_bat_cal > 95)
                    {
                        this_bat_cal = 100;
                    }
                }
            }
            switch(status)
            {
            case 2:		//短按power按键导致唤醒
            {
                power_int_reg();
                De_OpenLayer(board_res.layer_hd);
                if(this_bat_cal == 100)
                {
                    if(bat_show_hd)
                    {
                        ShowBatteryCharge_exit(bat_show_hd);
                        bat_show_hd = NULL;
                    }
                    show_battery_full(&bat_full_status);
                    for(i =0; i<12; i++)
                    {
                        if(power_ops_int_status & 0x02)	//短按
                        {
                            power_ops_int_status &= ~0x02;
                            i = 0;
                            __msg("short key\n");
                        }
                        else if(power_ops_int_status & 0x01)	//长按
                        {
                            ShowBatteryCharge_exit(bat_show_hd);
                            wlibc_int_disable();
                            power_int_rel();
                            usb_detect_exit();
                            power_ops_int_status &= ~0x01;
                            wlibc_int_enable();
                            power_int_reg();
                            __inf("long key\n");

                            return 0;
                        }
                        wBoot_timer_delay(250);
                    }
                }
                else
                {
                    int one_delay;

                    one_delay = 1000/(10 - (this_bat_cal/10));
                    for(j=0; j<3; j++)
                    {
                        for(i=this_bat_cal; i<110; i+=10)
                        {
                            ShowBatteryCharge_rate(bat_show_hd, i);
                            wBoot_timer_delay(one_delay);
                            if(power_ops_int_status & 0x02)	//短按
                            {
                                power_ops_int_status &= ~0x02;
                                j = 0;
                                __msg("short key\n");
                            }
                            else if(power_ops_int_status & 0x01)	//长按
                            {
                                ShowBatteryCharge_exit(bat_show_hd);
                                wlibc_int_disable();
                                power_int_rel();
                                usb_detect_exit();
                                power_ops_int_status &= ~0x01;
                                wlibc_int_enable();
                                power_int_reg();
                                __inf("long key\n");

                                return 0;
                            }
                        }
                    }
                    ShowBatteryCharge_rate(bat_show_hd, this_bat_cal);
                    wBoot_timer_delay(1000);
                }
            }
            break;

            case 3:		//长按电源按键之后,关闭电池图标,进入系统
            {
                ShowBatteryCharge_exit(bat_show_hd);
                power_int_reg();

                return 0;
            }

            case 4:		//当移除外部电源时候,重新显示当前电池图标后,3秒后关机
            case 5:		//当电池充电完成的时候,需要关机
                De_OpenLayer(board_res.layer_hd);
                ShowBatteryCharge_rate(bat_show_hd, this_bat_cal);
            case 6:
            case 7:
            {
                power_int_reg();
                if((status != 4) && (status != 5))
                {
                    De_OpenLayer(board_res.layer_hd);
                    ShowBatteryCharge_rate(bat_show_hd, this_bat_cal);
                }
                wBoot_timer_delay(500);
                if(bat_show_hd)
                {
                    ShowBatteryCharge_degrade(bat_show_hd, 10);
                    ShowBatteryCharge_exit(bat_show_hd);
                }
                else
                {
                    shut_battery_full();
                }

                return -1;
            }
            case 8:		//standby过程中检测到vbus接入
            {
                usb_detect_enter();
                wBoot_timer_delay(600);
                usb_detect_exit();
            }
            break;
            case 9:		//standby过程中检测到vbus移除,同时存在普通dc
            {
                power_set_usbpc();
            }
            break;

            default:
                break;
            }
        }
        while(1);
    }
}
Esempio n. 15
0
/*
*******************************************************************************
*                     BootMain
*
* Description:
*    BOOT主应用程序
*
* Parameters:
*    void
*
* Return value:
*    void
*
* note:
*    void
*
*******************************************************************************
*/
int BootMain(int argc, char **argv)
{
	__s32                 ret;
    int                   erase_flash;
	MBR					  mbr_info;
    boot_global_info_t   *global_info;

    DMSG_INFO("big firmware! here we go !\n");
	DMSG_INFO("Sprite start\n");
	{
		char ch;

		ch = wBoot_getc_delay( 1 );  // 27000000
	    __inf("%d\n", ch);

	    switch(ch)
	   	{
	   		case '1':
	   		{
	   			usb_start();
	    		usb_run();
	    		break;
	   		}
	   		case '2':
	   		{
	   			__inf("Jump to fel\n");
	   			wBoot_jump_fel( );
	   			break;
	   		}
	   		case '-':
	   		{
	   			__u32 dbg = 0x55;

	            __inf("hold\n");
		        while(dbg == 0x55);
		        break;
	   		}
	   		case '+':
	   		{
	   			force_debug = 1;
	        	break;
	   		}
	   		default:
	   			break;
	   	}
	}
	*(volatile unsigned int *)(0x1c20C00 + 0x118) = 0;
	*(volatile unsigned int *)(0x1c20C00 + 0x11C) = 3;
	//数据初始化
	memset(&board_res, 0, sizeof(boot_hardware_res));
    //申请内存,填充第一个启动脚本
    global_info = (boot_global_info_t *)wBoot_malloc(sizeof(boot_global_info_t));
    if(!global_info)
    {
        __wrn("unable to malloc memory for bootini\n");

        return -1;
    }
    //填充启动脚本
    memset(global_info, 0, sizeof(boot_global_info_t));
    ret = script_patch("c:\\boot.ini", global_info, 0);
    if(ret < 0)
    {
        __wrn("unable to parser boot.ini\n");

        return -1;
    }
    //初始化显示设备
    __inf("display init\n");
    cue = -1;
    if(boot_ui_init(global_info->display_device, global_info->display_mode) >= 0)
    {
    	//开启字符显示
    	__inf("char init\n");
    	boot_ui_char_init(0);
    	cue = 0;
    }
    sprite_led_init();
    sprite_wrn_init();
    //获取MBR信息
    __inf("mbr fetch\n");
	ret = card_mbr_info((void *)&mbr_info);
	if(ret < 0)
	{
		__wrn("unable to get mbr info\n");

        return -1;
	}
	boot_ui_check_device_open();
    
	ret = wBoot_script_parser_fetch("platform", "eraseflag", &erase_flash, 1);
	if((!ret) && (erase_flash))
	{
		erase_flash = 1;
	}
	else
	{
		erase_flash = 0;
	}
    
    //开始准备系统数据
    ret = card_sprite((void *)&mbr_info,erase_flash, cue);

	sprite_wrn_exit();
	sprite_led_exit(ret);
	if(!ret)
	{
		char	buffer[512];

		board_res.led_status[0] = CARD_SPRITE_SUCCESSED;
		sprite_wrn("CARD OK\n");

		__inf("get work mode\n");
		memset(buffer, 0, 512);
		wBoot_block_dread(15, 1, buffer);
		if(strcmp(buffer, "1234567890abcdefghijklmnopqrstuvwxyz"))
		{
			__inf("try to close\n");
			wBoot_timer_delay(3000);

			wBoot_power_set_off();
		}
		else
		{
			int ret;

			__inf("try to format\n");
			wBoot_timer_delay(500);
			ret = FormatDisk();
			__inf("format %d\n", ret);
			WATCHDOG_REG_MODE = 0x0;
			wBoot_timer_delay(500);
			WATCHDOG_REG_MODE = 0x3;
		}
	}
	else
	{
		board_res.led_status[0] = CARD_SPRITE_FAIL;
	}
	{
		__u32 dbg = 0x55;

		while(dbg == 0x55);
	}

    return 0;
}
__s32 DRV_DE_Standby(__u32 cmd, void *pArg)
{
	__s32 ret;
	__s32 timedly = 5000;
	__s32 check_time = timedly/DELAY_ONCE_TIME;

	if(cmd == EGON2_MOD_ENTER_STANDBY)
	{
		DRV_lcd_close(0);
		do
		{
			ret = DRV_lcd_check_close_finished(0);
			if(ret == 1)
			{
				break;
			}
			else if(ret == -1)
			{
				return -1;
			}
			wBoot_timer_delay(DELAY_ONCE_TIME);
			check_time --;
			if(check_time <= 0)
			{
				return -1;
			}
		}
		while(1);
		BSP_disp_clk_off(3);

		return 0;
	}
	else if(cmd == EGON2_MOD_EXIT_STANDBY)
	{
		BSP_disp_clk_on(3);
		DRV_lcd_open(0);
		do
		{
			ret = DRV_lcd_check_open_finished(0);
			if(ret == 1)
			{
				break;
			}
			else if(ret == -1)
			{
				return -1;
			}
			wBoot_timer_delay(DELAY_ONCE_TIME);
			check_time --;
			if(check_time <= 0)
			{
				return -1;
			}
		}
		while(1);

		return 0;
	}

	return -1;
}
void boot_ui_printf( const char * str, ...)
{
	int  base_color;
	char string[32];
	char *p;
	__s32 hex_flag ;
	va_list argp;

	va_start( argp, str );

	base_color = boot_ui_get_color();
	base_color &= 0xffffff;
	boot_ui_set_color(base_color);
    if(change_line == 1)
    {
        if(uichar_change_newline())
        {
        	__inf("boot ui char: unable to change to one new line\n");

        	goto boot_ui_print_err;
        }
        wBoot_timer_delay(10);
        change_line = 0;
    }

	while( *str )
	{
		if( *str == '%' )
		{
			++str;
			p = string;
			hex_flag = 'X';
			switch( *str )
			{
			    case 'u':
				case 'd':
				{
					int_to_string_dec( va_arg( argp,  __s32 ), string );
                    if(uichar_putstr( p, 32 ))
                    {
                      	goto boot_ui_print_err;
                    }
					++str;
					break;
				}
				case 'x': hex_flag = 'x';	         // jump to " case 'X' "
				case 'p':
				case 'X':
				{
					int_to_string_hex( va_arg( argp,  __s32 ), string, hex_flag );
					if(uichar_putstr( p , 32))
					{
						goto boot_ui_print_err;
					}
                    ++str;
					break;
				}
				case 'c':
				{
					if(uichar_putchar( va_arg( argp,  __s32 ) ))
					{
						goto boot_ui_print_err;
					}
					++str;
					break;
				}
				case 's':
				{
					if(uichar_putstr( va_arg( argp, char * ), 32 ))
					{
						goto boot_ui_print_err;
					}
					++str;
					break;
				}
				default :
				{
					if(uichar_putchar( '%' ))          // if current character is not Conversion Specifiers 'dxpXucs',
					{
						goto boot_ui_print_err;
					}
					if(uichar_putchar( *str ))         // output directly '%' and current character, and then
					{
						goto boot_ui_print_err;
					}
					++str;                        // let 'str' point to next character.
				}
			}
		}
		else
		{
			if( *str == '\n' )                      // if current character is '\n', insert and output '\r'