示例#1
0
/*----------------------------------------------------------------------------*/
u8 device_init(void)
{
    u8 sector_sizeof512 = 1;
    device_check();
    if (device_active & device_online)  ///<当前需要活动的设备在线
    {
        disp_port(MENU_SCAN_DISK);

        stop_decode();
//        deg_str("device init\n");
        fs_fun_init();

        if ((device_active & (~VIRTUAL_DEVICE)) == DEVICE_SDMMC0)
        {
            if (init_sd())                  ///<sd 卡鉴定
            {
                f_init(win_buffer, (u16)sdmmc_read, 1);//get_usb_device_pkt_size());    ///<鉴定成功后 初始化文件系统参数
            }
            else
            {
			return 0xff;                       ///<鉴定失败
            }

        }

        else if ((device_active & (~VIRTUAL_DEVICE)) == DEVICE_UDISK)
        {
            if (usb_host_emuerate_devcie(win_buffer))     ///<USB MASS STORAGE 枚举
            {
                sector_sizeof512 = get_usb_device_pkt_size();
                f_init(win_buffer, (u16)read_usb, sector_sizeof512);      ///<枚举成功后 初始化文件系统参数
            }
            else
            {
                return 0xff;             ///<枚举失败
            }
        }

    }
    else
    {
        return 0xff;
    }

//    deg_str("fat init\n");
    //if (!f_mount())                                      ///<文件系统初始化
    if (!f_mount_bsp(sector_sizeof512))
    {
        
        if((RECODE_INIT == encode_status))
        {
             if(0 == f_write_init(device_active & (~VIRTUAL_DEVICE)))  //初始化写设备的数据
             {
                 return 0xfd;
             }
             else
             {
                 return 0;
             }
        }
        fs_ext_setting(file_type);
        {
            u16 break_point;
            //get_rec_mem_info();
            if ((device_active & (~VIRTUAL_DEVICE)) == DEVICE_SDMMC0)
            {
                //break_point = disk_mus_point[0 + encode_cnt].id0;
			break_point = read_info(MEM_SD_PLAYPOINT_ID0);
			break_point=break_point<<8;
			break_point |= read_info(MEM_SD_PLAYPOINT_ID0+1);                
            }
            else if ((device_active & (~VIRTUAL_DEVICE) ) == DEVICE_UDISK)
            {
               // break_point = disk_mus_point[1 + encode_cnt].id0;
			break_point = read_info(MEM_USB_PLAYPOINT_ID0);
			break_point=break_point<<8;
			break_point |= read_info(MEM_USB_PLAYPOINT_ID0+1);                
		}
			
            	break_point_filenum = fs_scan_disk(break_point);
    		encode_fristfile = fs_msg_rec.firstfilenum;	  //录音文件总数
            	encode_filenum = fs_msg_rec.fileTotalInDir;	  //录音文件夹的第一个文件号

            //if (break_point_filenum)
            {
                //break_point_filenum = filenum_phy_logic(break_point_filenum);
            }
        }
		     




#if VIRTUAL_ENABLE
        logic_fileTotal = fs_msg.fileTotal - encode_filenum;          ///音乐文件总数

        if(device_active & VIRTUAL_DEVICE)
        {
            logic_fileTotal = encode_filenum;	//录音文件总数
        }
#else
        logic_fileTotal = fs_msg.fileTotal;
#endif
        
		
        if(0 == logic_fileTotal)//if (fs_msg.fileTotal == 0)
        {
            return 0xfe;
        }

        return 0;
    }
    else
    {
        return 0xff;	//无有效设备
    }
}
示例#2
0
/*----------------------------------------------------------------------------*/
u8 device_init(void)
{
		usb_sd_dev_toc=0;		

    device_online = get_device_online_status();
	if(playpoint_time.last_device != device_active)
	{
		write_playtime(&playpoint_time);
	}
    if (device_active & device_online)  ///<当前需要活动的设备在线
    {
		flush_all_msg();                ///<清空全部消息
        stop_decode();                  ///<停止解码
#if FILE_ENCRYPTION
         password_start(0);
#endif

#ifdef SYS_GPIO_SEL_FUNC
	     	if( gpio_sel_func){				
			return 0xff;
		 }
#endif

        if (device_active == BIT(USB_DISK))
        {
			if (usb_host_emuerate_devcie(win_buffer))     ///<USB MASS STORAGE 枚举
            {
#ifdef SYS_GPIO_SEL_FUNC
	     	if( gpio_sel_func){				
			return 0xff;
		 }
#endif            
				f_init(win_buffer, (u16)usb_otp_read, get_usb_device_pkt_size());      ///<枚举成功后 初始化文件系统参数
            }
            else
            {
				return 0xff;             ///<枚举失败
            }
        }
        else if (device_active == BIT(SDMMC))
        {
			if (init_sd())                  ///<sd 卡鉴定
            {
#ifdef SYS_GPIO_SEL_FUNC
	     	if( gpio_sel_func){				
			return 0xff;
		 }
#endif
            
				f_init(win_buffer, (u16)sdmmc_otp_read, 1);//get_usb_device_pkt_size());    ///<鉴定成功后 初始化文件系统参数
            }
            else
            {
				return 0xff;                       ///<鉴定失败
            }
        }
    }
#ifdef SYS_GPIO_SEL_FUNC
	     	if( gpio_sel_func){				
			return 0xff;
		 }
#endif
	
    if (!f_mount())                                      ///<文件系统初始化
    {

#ifdef SYS_GPIO_SEL_FUNC
	     	if( gpio_sel_func){				
			return 0xff;
		 }
#endif
    
		fs_ext_setting(file_type);
#ifdef SYS_GPIO_SEL_FUNC
	     	if( gpio_sel_func){				
			return 0xff;
		 }
#endif

		set_playpoint_info(read_playpoint_info(device_active));
#ifdef SYS_GPIO_SEL_FUNC
	     	if( gpio_sel_func){				
			return 0xff;
		 }
#endif

		fs_scan_disk();
#ifdef SYS_GPIO_SEL_FUNC
	     	if( gpio_sel_func){				
			return 0xff;
		 }
#endif

		playpoint_filenum = get_scan_filenumber();				   //根据对应设备的起始簇找出有断点的文件号
		/**/

		usb_sd_dev_toc=1;		
#ifdef DISABLE_USB_SD_BP_PLAY
			playpoint_filenum=0;
#endif		
		if(0 == playpoint_filenum)
		{
		    if(given_file_number)
			    given_file_number = 1;
		}
        if (fs_msg.fileTotal == 0)
        {

			return 0xfe;
        }
#if ((USE_DEVICE == MEMORY_STYLE)&&(FAT_MEMORY))    
        check_reserve_sector(device_active);
#endif 
        return 0;
    }
    else
	{
                                                 //无有效设备
        return 0xff;
	}
}