下边的代码写了两种复制方式,一种是全部读出来然后写,另一种是一段一段的读然后一段一段的写。第一种方式可以,第二种方式死机在SD_Error SD_WaitReadOperation(void)。
用的是官方的SDIO+DMA 例程。
[mw_shl_code=applescript,true] //复制测试
f_open(&filsrc,"0:/test.txt",FA_READ);
tw = filsrc.obj.objsize;
bmpbuf = mymalloc(SRAMEX,tw);
f_close(&filsrc);
aw = 0;
do
{
f_open(&filsrc,"0:/test.txt",FA_READ);
f_read(&filsrc,bmpbuf,tw,&br);
f_close(&filsrc);
f_open(&fildst,"0:/test1.txt",FA_WRITE | FA_OPEN_ALWAYS);
f_write(&fildst,bmpbuf,tw,&bw);
f_close(&fildst);
nw = 0;
}while(nw);
myfree(SRAMEX,(void *)bmpbuf);
LCD_ShowString(0,0,100,24,16,"TXT OVER");//txt测试成功
bmpbuf = (u8 *)mymalloc(SRAMEX,4096);
res = f_open(&filsrc,"0:/abc.txt",FA_READ);
res = f_open(&fildst,"0:/back.txt",FA_CREATE_ALWAYS|FA_WRITE|FA_READ);
aw = 0;
while(res == FR_OK)
{
LCD_ShowxNum(0,80,aw,8,16,0);
res = f_read(&filsrc,bmpbuf,512,&br);
res = f_write(&fildst,bmpbuf,br,&bw);
aw += br;
if(br != 512)break;
}
LCD_ShowxNum(0,40,fildst.obj.objsize,8,16,0);
LCD_ShowxNum(0,60,filsrc.obj.objsize,8,16,0);
LCD_ShowxNum(0,80,aw,8,16,0);
f_close(&filsrc);
f_close(&fildst);
myfree(SRAMEX,(void *)bmpbuf);
LCD_ShowString(0,20,100,24,16,"BMP OVER");
while(1);[/mw_shl_code]
一周热门 更多>