初中生
最后登录1970-1-1
在线时间 小时
注册时间2017-8-11
|
楼主 |
发表于 2017-10-29 22:49:47
|
显示全部楼层
这是代码::::为什么不对呢??求解
printf("\r\n这是一个FatFs文件系统管理FLASH的实验\n");
res_mount = f_mount(&fsobject,"1:",1);
printf("\r\nf_mount res=%d",res_mount);
if(res_mount == FR_NO_FILESYSTEM) //挂载文件返回值为无文件系统时,进行格式化
{
res_mkfs = f_mkfs("1:",0,0);
printf("\r\nf_mkfs res=%d",res_mkfs);
//格式化后要取消挂载后重新挂载
res_mount = f_mount(NULL,"1:",1);
res_mount = f_mount(&fsobject,"1:",1);
printf("\r\nsecond res_mount=%d",res_mount);
}
res_open = f_open(&fp,"1:abcd.txt",FA_READ|FA_WRITE|FA_OPEN_ALWAYS);
printf("\r\nfopen res=%d",res_open);
if(res_open == FR_OK) //文件打开成功
{
res_write = f_write(&fp,write_string,sizeof(write_string),&bw);
printf("bw=%d",bw);
if(res_write == FR_OK)
{
f_lseek(&fp,0);
res_read = f_read(&fp,read_string,f_size(&fp),&br);
if(res_read == FR_OK)
{
printf("\r\n读取到的数据是:%s,%d",read_string,br);
}
}
}
|
-
这是输出结果
|