电梯直达跳转到指定楼层 1楼
发表于 4 天前 | 只看该作者 回帖奖励
FatFs版本是R0.11,不分区,新建文件、编辑文件都没有问题的。现在分成两个区,也没有问题,但是新建文件就有问题了,第二个分区新建文件一直出错,根据返回结果是12,The volume has no work area。劳烦大家帮忙看看
/* Register work area to the logical drive 0 */
f_mount(&FATfs, "0:", 0);
/* Create FAT volume on the logical drive 0. 2nd argument is ignored. */
res = f_mkfs("0:", 0, 4096);
if (FR_OK == res)
{
SEGGER_RTT_WriteString(0, "format logical drive 0 Succeeded\r\n");
}
else
{
SEGGER_RTT_WriteString(0, "format logical drive 0 faile\r\n");
Err_Reason(res);
}
/* Unregister work area from the logical drive 0 */
f_mount(0, "0:", 0);
/* Register a work area to the logical drive 1 */
f_mount(&FATfs, "1:", 0);
/* Create FAT volume on the logical drive 1. 2nd argument is ignored. */
res = f_mkfs("1:", 0, 4096);
if (FR_OK == res)
{
SEGGER_RTT_WriteString(0, "format logical drive 1 Succeeded\r\n");
}
else
{
SEGGER_RTT_WriteString(0, "format logical drive 1 faile\r\n");
Err_Reason(res);
}
/* Unregister work area from the logical drive 1 */
f_mount(0, "1:", 0);
}
void creatfile(void)
{
FRESULT res;
/* Register work area to the logical drive 0 */
res = f_mount(&FATfs, "0:", 0);
if (RES_OK != res)
{
SEGGER_RTT_WriteString(0, "mount logical drive 0 faile\r\n");
Err_Reason(res);
return;
}
/* creat a bin file */
res = f_open(&fil, "test.log", FA_CREATE_ALWAYS);
if (RES_OK == res)
{
SEGGER_RTT_WriteString(0, "creat log file Succeeded\r\n");
}
else
{
SEGGER_RTT_WriteString(0, "creat file log faile\r\n");
Err_Reason(res);
}
/* Close the file */
f_close(&fil);
/* Unregister work area */
f_mount(0, "0:", 0);
/* Register work area to the logical drive 1 */
res = f_mount(&FATfs, "1:", 0);
if (RES_OK != res)
{
SEGGER_RTT_WriteString(0, "mount logical drive 1 faile\r\n");
Err_Reason(res);
return;
}
/* creat a bin file */
res = f_open(&fil, "test.bin", FA_CREATE_ALWAYS);
if (RES_OK == res)
{
SEGGER_RTT_WriteString(0, "creat bin file Succeeded\r\n");
}
else
{
SEGGER_RTT_WriteString(0, "creat bin file faile\r\n");
Err_Reason(res);
}
/* Close the file */
f_close(&fil);
/* Unregister work area */
f_mount(0, "1:", 0);
}
复制代码转载