我上面贴出来的是有问题的,f_close的时候返回0x01
后来我改成如下这样就可以成功创建文件了
u8 bmp_encode(u8 *filename,u16 x,u16 y,u16 width,u16 height,u8 mode)
{
FIL* f_bmp;
u8 res;
UINT bw;
u8 *databuf = "12345";
f_bmp=(FIL *)mymalloc(SRAMIN,sizeof(FIL));
if(mode==1)res=f_open(f_bmp,(const TCHAR*)filename,FA_READ|FA_WRITE);
if(mode==0||res==0x04)res=f_open(f_bmp,(const TCHAR*)filename,FA_WRITE|FA_CREATE_NEW);
res=f_write(f_bmp,databuf,6,&bw);
res = f_close(f_bmp);
return res;
}
int main(void)
{
...
...
pname=mymalloc(SRAMIN,30);
camera_new_pathname(pname);
if(bmp_encode(pname,0,0,240,320,0))
{
printf("\r\n数据写入有误!.....\r\n\r\n");
}
} |