Files
mkrtos-real/mkrtos_user/server/fs/fatfs/main.c
2023-09-22 00:14:27 +08:00

37 lines
780 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <ff.h>
#include "u_log.h"
#include <stdio.h>
static FATFS fs;
static BYTE buff[512];
static MKFS_PARM defopt = {FM_ANY, 0, 0, 0};
int main(int args, char *argv[])
{
FRESULT res = f_mount(&fs, "0:", 1);
if (res != FR_OK)
{
res = f_mkfs("0:", &defopt, buff, 512); // 第三个参数可以设置成NULL默认使用heap memory
if (res != FR_OK)
{
printf("f_mkfs err.\n");
while (1)
;
}
else
{
res = f_mount(&fs, "0:", 1);
if (res != FR_OK)
{
printf("f_mount err.\n");
while (1)
;
}
}
}
printf("mount success\n");
while (1)
;
return -1;
}