|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2008-11-2 22:22:49
|
显示全部楼层
int FAT_RunFile(char *ini_dir)
{
U32 a,b,i;
U8 *Buf;
U8 *LCD_Buf;
char str_buf[1024];
char dir_buf[1024];
char *Str=str_buf;
char *dir=dir_buf;
struct FileInfoStruct File_Info;
////
i=FAT_OpenFile(ini_dir,&File_Info);
if(i==1)
{
Uart_Printf(0,"FAT Load '%s' Err!\n",ini_dir); //文件打开失败.
// GUI_LabelPrintf(40,LCD_YSIZE>>2,LCD_XSIZE-40*2,40,RGB565(31,0,0),RGB565(24,48,0),RGB565(10,20,10),Center,Font_ASC_8_16,"Open '%s' Err!",dir);
// Uart_Getch(0);
return 0;
}
////
Uart_Printf(0,"FAT Load '%s' Size=%d,Start Cluster=%d.\n",File_Info.Size,i);
////
Buf=malloc(File_Info.Size);
if(Buf==0)
{
Uart_Printf(0,"Load File:'%s';APP RAM Err!\n");
return 0;
}
////
FAT_DirLoadFile(ini_dir,Buf); //加载 ini文件.
a=0;
while(1)
{
if(Buf[a]=='\n') break;
if(Buf[a]==' ') break;
dir[a]=Buf[a];
a++;
}
dir[--a]='\0';
////
for(a=0;Buf[a]!='@';a++);
a++;
b=0;
while(1)
{
if(Buf[a]=='\n') break;
if(Buf[a]==' ') break;
if(b==8) break;
////
Str[b++]=Buf[a++];
}
Str='\0';
i=strtol(Str,NULL,16) ;
Uart_Puts(0,dir);
Uart_Printf(0," Read RAM=%X\n",i);
a=FAT_OpenFile(dir,&File_Info);
if(a==1)
{
Uart_Printf(0,"Open '%s' Err!\n",dir);
Uart_Printf(0,"Start Cluster=%d\n",a);
return 1;
}
////
Uart_Printf(0,"Size=%d;Start Cluster=%d.\n",File_Info.Size,a);
FAT_DirLoadFile(dir,(U8 *)i);
Uart_Printf(0,"Start Run to:0x%08X.\n",i);
Run_Address(i);
return 1;
} |
|