Files
mkrtos-real/mkrtos_user/server/fs/fatfs/main.c
zhangzheng ef49739ad0 rpc
可用,并增加fs服务
2023-09-24 01:26:07 +08:00

49 lines
1.0 KiB
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 "u_log.h"
#include "ns_cli.h"
#include "u_rpc_svr.h"
#include "u_prot.h"
#include "fs_rpc.h"
#include <ff.h>
#include <stdio.h>
#include <assert.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");
obj_handler_t ipc_hd;
int ret = rpc_creaite_bind_ipc(THREAD_MAIN, NULL, &ipc_hd);
assert(ret >= 0);
ns_register("fs", ipc_hd);
fs_svr_init(ipc_hd);
fs_svr_loop();
while (1)
;
return -1;
}