高中生
最后登录1970-1-1
在线时间 小时
注册时间2014-12-6
|
照着野火带文件系统的程序写了一编,下载到板子里面,发现操作失败,后来又把野火的程序编译下载进去,还是不行,出错的地方在f_open,返回值是13, There is no valid FAT volume on the physical drive
int main(void)
{
/* USART1 config */
USART1_Config();
printf("\r\n this is a fatfs test demo \r\n");
/* Sdio Interrupt Config */
NVIC_Configuration();
/* Register work area for each volume (Always succeeds regardless of disk status) */
res = f_mount(0,&fs);
//res = f_mkfs(0,0,_MAX_SS);有人说要加这个 格式化,可是我加了 这里就会出错,返回1
// f_mkdir("sub");
// f_mkdir("sub/sub1");
/* function disk_initialize() has been called in f_open */
/* Create new file on the drive 0 */
res = f_open(&fnew, "0:newfile.txt", FA_CREATE_ALWAYS | FA_WRITE );//res =13, There is no valid FAT volume on the physical drive 就是这里有问题
if ( res == FR_OK )
{
res = f_write(&fnew, textFileBuffer, sizeof(textFileBuffer), &bw);
f_close(&fnew);
}
res = f_open(&fnew, "0:newfile.txt", FA_OPEN_EXISTING | FA_READ);
res = f_read(&fnew, buffer, sizeof(buffer), &br);
printf("\r\n erere %s ", buffer);
/* Close open files */
f_close(&fnew);
/* Unregister work area prior to discard it */
f_mount(0, NULL);
while(1);
}
|
|