[mw_shl_code=c,true] // Register a work area for logical drive 0
f_mount(0,&fs,1);
res=f_mkdir("0
ATA");//在SD卡里面新建文件夹
// Open source file
res = f_open(&fsrc, "srcfile.dat", FA_OPEN_EXISTING | FA_READ);
if (res) die(res);
// Create destination file
res = f_open(&fdst, "dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
if (res) die(res);
// Copy source to destination
for (;;) {
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
if (res || br == 0) break; // error or eof
res = f_write(&fdst, buffer, br, &bw);
if (res || bw < br) break; // error or disk full
}
// Close all files
f_close(&fsrc);
f_close(&fdst);
// Unregister a work area before discard it
f_mount(0, NULL,1);[/mw_shl_code]
[mw_shl_code=c,true]以下是f_mount定义[/mw_shl_code]
[mw_shl_code=c,true]/*-----------------------------------------------------------------------*/
/* Mount/Unmount a Logical Drive */
/*-----------------------------------------------------------------------*/
FRESULT f_mount (
FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/
const TCHAR* path, /* Logical drive number to be mounted/unmounted */
BYTE opt /* 0
o not mount (delayed mount), 1:Mount immediately */
)[/mw_shl_code]
我想实现创建TXT文件,但f_mount
(0,*fs)和
f_mount(0, NULL)总有errors.
查看定义后,发现有
f_mount3个参数。
于是我把f_mount(0,*fs)改成了f_mount(0,&fs,1);
f_mount(0, NULL)改成了f_mount(0, NULL,1);
你们移植时有遇到过此情况?
f_mount(0,&fs);----------这样的2个参数报错main.c(146): error: #167: argument of type "FATFS *" is incompatible with parameter of type ·"const TCHAR *
main.c(146): error: #165: too few arguments in function call
f_mount(0,*fs);----------这样的2个参数报错main.c(146): error: #75: operand of "*" must be a pointer
main.c(146): error: #165: too few arguments in function call
包含文件如下
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "lcd.h"
#include "key.h"
#include "sram.h"
#include "malloc.h"
#include "usmart.h"
#include "sdio_sdcard.h"
#include "malloc.h"
#include "w25qxx.h"
#include "ff.h"
#include "exfuns.h"
#include "stm32f4xx_fsmc.h"
还有
FATFS fs; // Work area (file system object) for logical drive
FIL fsrc, fdst; // file objects
BYTE buffer[4096]; // file copy buffer
FRESULT res; // FatFs function common result code
UINT br, bw; // File R/W count
[mw_shl_code=c,true]FRESULT f_mount ( FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ const TCHAR* path, /* Logical drive number to be mounted/unmounted */ BYTE opt /* 0o not mount (delayed mount), 1:Mount immediately */ )[/mw_shl_code] 那请问F407的3个变量怎么写呢?
f_mount(NULL,"0:",1);//卸载
一周热门 更多>