OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 13831|回复: 7

f_mount(0,*fs)移植不对吧,应该有三个参数的

[复制链接]

15

主题

78

帖子

0

精华

初级会员

Rank: 2

积分
180
金钱
180
注册时间
2012-11-21
在线时间
9 小时
发表于 2015-7-14 14:51:05 | 显示全部楼层 |阅读模式
5金钱
[mw_shl_code=c,true] // Register a work area for logical drive 0 f_mount(0,&fs,1); res=f_mkdir("0ATA");//在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 /* 0o 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);

你们移植时有遇到过此情况?

最佳答案

查看完整内容[请看2#楼]

新版FATFS mount 函数参数与老版不同,例:f_mount(fs[0],"0:",1);
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

14

主题

191

帖子

0

精华

QQ游客

积分
813
金钱
813
注册时间
2013-6-9
在线时间
181 小时
发表于 2015-7-14 14:51:06 | 显示全部楼层
新版FATFS mount 函数参数与老版不同,例:f_mount(fs[0],"0:",1);
回复

使用道具 举报

15

主题

78

帖子

0

精华

初级会员

Rank: 2

积分
180
金钱
180
注册时间
2012-11-21
在线时间
9 小时
 楼主| 发表于 2015-7-14 14:52:09 | 显示全部楼层
在第2行和26行。
回复

使用道具 举报

15

主题

78

帖子

0

精华

初级会员

Rank: 2

积分
180
金钱
180
注册时间
2012-11-21
在线时间
9 小时
 楼主| 发表于 2015-7-14 14:59:01 | 显示全部楼层
f_mount(0,&fs,1);--------改为这样的3个参数报错 main.c(146): error:  #167: argument of type "FATFS *" is incompatible with parameter of type "const TCHAR *"
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
回复

使用道具 举报

15

主题

78

帖子

0

精华

初级会员

Rank: 2

积分
180
金钱
180
注册时间
2012-11-21
在线时间
9 小时
 楼主| 发表于 2015-7-14 15:13:38 | 显示全部楼层
[mw_shl_code=c,true]查了下F103的定义,是两个变量[/mw_shl_code] [mw_shl_code=c,true]FRESULT f_mount ( BYTE vol, /* Logical drive number to be mounted/unmounted */ FATFS *fs /* Pointer to new file system object (NULL for unmount)*/ )[/mw_shl_code]
而F407的定义,是3个变量
[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个变量怎么写呢?
回复

使用道具 举报

4

主题

36

帖子

0

精华

新手上路

积分
47
金钱
47
注册时间
2019-1-2
在线时间
11 小时
发表于 2019-1-11 20:44:02 | 显示全部楼层
f_mount(fs[0],"0:",1);
回复

使用道具 举报

4

主题

36

帖子

0

精华

新手上路

积分
47
金钱
47
注册时间
2019-1-2
在线时间
11 小时
发表于 2019-1-11 21:02:10 | 显示全部楼层
f_mount(fs[0],"0:",1);         //挂载sd       
f_mount(NULL,"0:",1);//卸载
回复

使用道具 举报

22

主题

108

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
430
金钱
430
注册时间
2016-5-23
在线时间
118 小时
发表于 2021-12-8 09:29:20 | 显示全部楼层
fs[0]从哪儿来 ? FATFS结构体并没有这个啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-2-26 09:57

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表