代码如下:
FRESULT result;
FATFS fs;
FIL file1;
DIR DirInf;
uint32_t bw;
char aa[] = "12345678";
result = f_mount(0, &fs); /* Mount a logical drive */
if (result != FR_OK)
{
printf("FileSystem Mounted Failed (%d)
", result);
}
result = f_opendir(&DirInf, "/");
if (result != FR_OK)
{
printf("Root Directory is Open Error (%d)
", result);
return;
}
result = f_open(&file1, "/HELLO1.txt", FA_CREATE_ALWAYS | FA_WRITE);
result = f_write(&file1, aa, 7, &bw);
if (result == FR_OK)
{
printf("---File Write Success
");
printf("----bw=%d
", bw);
}
else
{
printf(".txt File Write Failed");
}
f_close(&file1);
f_mount(0, NULL);
可以读取SD卡中现有的文件内容,可以新建立文件,f_write写入返回成功,但是实际没有写入,文件大小还是0,请高手帮忙一下。
此帖出自
小平头技术问答
一周热门 更多>