/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
__u32 usb_detect_enter(void)
{
	awxx_usb[0].index = 0;
	awxx_usb[0].reg_base = 	0x01c13000;
	awxx_usb[0].irq_no = GIC_SRC_USB0;
	awxx_usb[0].drq_no = 0x04;

	__inf("usb start detect\n");
	if(!usb_working)
	{
		__inf("usb enter detect\n");
		usb_working = 1;
		usb_clock_init();

		tmr_hd = wBoot_timer_request((void *)timer_test_usbdc, 0);
		if(!tmr_hd)
		{
			__inf("timer request fail\n");
		}
		else
		{
			wBoot_timer_start(tmr_hd, 400, 0);
		}
		wBoot_InsINT_Func(awxx_usb[0].irq_no, (int *)usb_detect_irq_handler, 0);
		wBoot_EnableInt(awxx_usb[0].irq_no);
		usb_init(&awxx_usb[0]);
		usb_soft_connect(&awxx_usb[0]);
	}


	return 0;
}
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int sprite_led_init(void)
{
    user_gpio_set_t     gpio_init;
	int					ret;
	int					delay;

	sprite_timer_hd = wBoot_timer_request((void *)sprite_timer_func, 0);
	if(!sprite_timer_hd)
	{
		__inf("reuqest timer for led failed\n");

		return -1;
	}
	else
	{
		sprite_led_status = 1;
		ret = wBoot_script_parser_fetch("card_boot", "sprite_work_delay", (void *)&delay, 1);
		if((ret) || (!delay))
		{
			delay = 500;
		}
	}
	__inf("try gpio config\n");
	sprite_led_hd = NULL;
	memset(&gpio_init, 0, sizeof(user_gpio_set_t));
	ret = wBoot_script_parser_fetch("card_boot", "sprite_gpio0", (void *)&gpio_init, sizeof(user_gpio_set_t)>>2);
	if(!ret)
	{
		if(gpio_init.port)
		{
			sprite_led_hd = wBoot_GPIO_Request(&gpio_init, 1);
			if(!sprite_led_hd)
			{
				__inf("reuqest gpio for led failed\n");

				goto _led_err;
			}
			__inf("gpio start\n");
			wBoot_timer_start(sprite_timer_hd, delay, 1);	//初始1000ms翻转一次,重复显示

			return 0;
		}
	}
	__inf("try codec config\n");
	codec_init();
	codec_led_hd = codec_play();
	wBoot_timer_start(sprite_timer_hd, delay, 1);	//初始1000ms翻转一次,重复显示

	return 0;


_led_err:
	if(sprite_timer_hd)
	{
		wBoot_timer_release(sprite_timer_hd);
	}

	return -1;
}
__s32 DRV_lcd_close(__u32 sel)
{
    lcd_flow_cnt[sel] = 0;
    lcd_op_finished[sel] = 0;
    lcd_timer[sel] = wBoot_timer_request((void*)DRV_lcd_close_callback,(void*)sel);

    BSP_disp_lcd_close_befor(sel);
    DRV_lcd_close_callback((void*)sel);

    return 0;
}
__s32 DRV_lcd_open(__u32 sel)
{
    lcd_flow_cnt[sel] = 0;
    lcd_op_finished[sel] = 0;
    lcd_timer[sel] = wBoot_timer_request((void*)DRV_lcd_open_callback,(void*)sel);
    if(!lcd_timer[sel])
    {
       __inf("%s wBoot_timer_request fail!\n",__FUNCTION__);
       
    }
    BSP_disp_lcd_open_before(sel);
    DRV_lcd_open_callback((void*)sel);


    return 0;
}