f_open的返回不为零的可能性有很多种,可以李斗绝根据具体哪姿的返回销侍值,找到错误类型。
下面是具体的错误类型:
typedef enum {
FR_OK = 0, /* (0) Succeeded */
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
FR_INT_ERR, /* (2) Assertion failed */
FR_NOT_READY, /* (3) The physical drive cannot work */
FR_NO_FILE, /* (4) Could not find the file */
FR_NO_PATH, /* (5) Could not find the path */
FR_INVALID_NAME, /* (6) The path name format is invalid */
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
FR_EXIST, /* (8) Access denied due to prohibited access */
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
FR_NOT_ENABLED, /* (12) The volume has no work area */
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files >_FS_SHARE */
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
} FRESULT
还有f_mount也有返回值,你应该看看是否mount成功。
最有可能是念判正写文件没有成功另冲樱外一个可能是你不仔悔小心设置了文件为隐藏,不过可能性很小,除非你调用文件系统函数主动更改过文件属性
FatFS写文件的一般步骤是:
使用f_open函数打开文件,f_lseek函数将文件指针移动到文件尾(可选),f_write文件进行写,f_close关闭并将缓存数据(如果有的话)写入SD卡
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)