用的是HC32F4A0+SDIOC+FatFS0.15版本
但是把SD卡插到读卡器上,看到的就是空白。有没有大佬知道这是为什么
#include "FileEdit.h"
#include "ff.h"
#include "stdio.h"
#include "BSP_Timer_INT_Count.h"
FATFS fsobject;
FIL fp;
BYTE work[FF_MAX_SS];
const char write_buf[] = "abcdefg";
char read_buf[FF_MAX_SS] = "";
UINT bw;
UINT br;
void FatFS_Test(void)
{
FRESULT res;
/* 挂载文件系统 */
res = f_mount(&fsobject, "0:", 1); //挂载fsobject到文件系统、0: 存储器路径,也就是SD卡、1立即挂载
if(res != FR_OK)
{
res = f_mkfs("0:", 0, work, sizeof(work));
res = f_mount(NULL, "0:", 1);
res = f_mount(&fsobject, "0:", 1);
}
/* 打开、创建文件 */
f_mkdir("0:/dir0");
res = f_open(&fp, "0:/dir0/qwerpoiu.txt", FA_CREATE_ALWAYS | FA_WRITE | FA_READ);
if(res == LL_OK)
{
res = f_write(&fp, write_buf, sizeof(write_buf), &bw);
f_close(&fp);
res = f_open(&fp, "0:/dir0/qwerpoiu.txt", FA_READ);
if(res==LL_OK)
{
f_lseek(&fp, 0);
res = f_read(&fp, read_buf, f_size(&fp), &br);
__nop();
}
else
f_close(&fp);
}
f_unmount("0:");
}
更多回帖