CARME-M4 BSP  V1.5
FatFs

FatFs module is a generic FAT file system module. More...

+ Collaboration diagram for FatFs:

Modules

 Disk IO
 Low level disk I/O module skeleton for FatFs.
 
 User defined Functions
 Additional user defined functions.
 
 FIL.flag
 File access control and file status flags (FIL.flag)
 
 FATFS.fs_type
 FAT sub type (FATFS.fs_type)
 
 File attributes
 File attribute bits for directory entry.
 
 Multi-byte word access
 Multi-byte word access macros.
 
 Configuration
 FatFs configuration.
 
 Private definitions
 Module Private Definitions.
 
 Private functions
 Module Private Functions.
 
 CARME_SDIO_SD
 This file provides all the SD Card driver firmware functions.
 
 FreeRTOS Task Synchronization
 FatFs synchronize functions.
 
 Integer
 Integer type definitions for FatFs module.
 

Files

file  ff.h
 
file  ff.c
 

Data Structures

struct  FATFS
 File system object structure. More...
 
struct  FIL
 File object structure. More...
 
struct  DIR
 Directory object structure. More...
 
struct  FILINFO
 File status structure. More...
 

Macros

#define LD2PD(vol)   (BYTE)(vol)
 
#define LD2PT(vol)   0
 
#define _T(x)   x
 
#define _TEXT(x)   x
 
#define f_eof(fp)   (((fp)->fptr == (fp)->fsize) ? 1 : 0)
 Filepointer at the end of file?
 
#define f_error(fp)   ((fp)->err)
 
#define f_tell(fp)   ((fp)->fptr)
 
#define f_size(fp)   ((fp)->fsize)
 
#define EOF   (-1)
 

Typedefs

typedef char TCHAR
 

Enumerations

enum  FRESULT {
  FR_OK = 0, FR_DISK_ERR, FR_INT_ERR, FR_NOT_READY,
  FR_NO_FILE, FR_NO_PATH, FR_INVALID_NAME, FR_DENIED,
  FR_EXIST, FR_INVALID_OBJECT, FR_WRITE_PROTECTED, FR_INVALID_DRIVE,
  FR_NOT_ENABLED, FR_NO_FILESYSTEM, FR_MKFS_ABORTED, FR_TIMEOUT,
  FR_LOCKED, FR_NOT_ENOUGH_CORE, FR_TOO_MANY_OPEN_FILES, FR_INVALID_PARAMETER
}
 File function return code. More...
 

Functions

FRESULT f_open (FIL *fp, const TCHAR *path, BYTE mode)
 Open or Create a File. More...
 
FRESULT f_close (FIL *fp)
 Close File. More...
 
FRESULT f_read (FIL *fp, void *buff, UINT btr, UINT *br)
 Read File. More...
 
FRESULT f_write (FIL *fp, const void *buff, UINT btw, UINT *bw)
 Write File. More...
 
FRESULT f_lseek (FIL *fp, DWORD ofs)
 Seek File R/W Pointer. More...
 
FRESULT f_truncate (FIL *fp)
 Truncate File. More...
 
FRESULT f_sync (FIL *fp)
 Synchronize the File. More...
 
FRESULT f_opendir (DIR *dp, const TCHAR *path)
 Create a Directory Object. More...
 
FRESULT f_closedir (DIR *dp)
 Close Directory. More...
 
FRESULT f_readdir (DIR *dp, FILINFO *fno)
 Read Directory Entries in Sequence. More...
 
FRESULT f_mkdir (const TCHAR *path)
 Create a Directory. More...
 
FRESULT f_unlink (const TCHAR *path)
 Delete a File or Directory. More...
 
FRESULT f_rename (const TCHAR *path_old, const TCHAR *path_new)
 Rename File/Directory. More...
 
FRESULT f_stat (const TCHAR *path, FILINFO *fno)
 Get File Status. More...
 
FRESULT f_chmod (const TCHAR *path, BYTE value, BYTE mask)
 Change Attribute. More...
 
FRESULT f_utime (const TCHAR *path, const FILINFO *fno)
 Change Timestamp. More...
 
FRESULT f_getfree (const TCHAR *path, DWORD *nclst, FATFS **fatfs)
 Get Number of Free Clusters. More...
 
FRESULT f_mount (FATFS *fs, const TCHAR *path, BYTE opt)
 Mount/Unmount a Logical Drive. More...
 
FRESULT f_mkfs (const TCHAR *path, BYTE sfd, UINT au)
 
int f_putc (TCHAR c, FIL *fp)
 
int f_puts (const TCHAR *str, FIL *cp)
 
int f_printf (FIL *fp, const TCHAR *str,...)
 
TCHAR * f_gets (TCHAR *buff, int len, FIL *fp)
 

Detailed Description

FatFs module is a generic FAT file system module.

FatFs - FAT file system module include file.

FatFs - FAT file system module

Macro Definition Documentation

#define EOF   (-1)

End of file

Definition at line 326 of file ff.h.

#define f_error (   fp)    ((fp)->err)

Get Abort flag (error code)

Definition at line 321 of file ff.h.

#define f_size (   fp)    ((fp)->fsize)

Get Sectors per FAT

Examples:
sdcard.c.

Definition at line 323 of file ff.h.

#define f_tell (   fp)    ((fp)->fptr)

Get File read/write pointer

Definition at line 322 of file ff.h.

#define LD2PD (   vol)    (BYTE)(vol)

Each logical drive is bound to the same physical drive number

Definition at line 59 of file ff.h.

#define LD2PT (   vol)    0

Find first valid partition or in SFD

Definition at line 63 of file ff.h.

Enumeration Type Documentation

enum FRESULT

File function return code.

Enumerator
FR_OK 

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_INVALID_OBJECT 

9: The file/directory object is invalid

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

Definition at line 204 of file ff.h.

Function Documentation

FRESULT f_chmod ( const TCHAR *  path,
BYTE  value,
BYTE  mask 
)

Change Attribute.

Parameters
pathPointer to the file path
valueAttribute bits
maskAttribute mask to change
Returns
FRESULT

Definition at line 3566 of file ff.c.

FRESULT f_close ( FIL fp)

Close File.

Parameters
fpPointer to the file object to be closed
Returns
FRESULT
Examples:
sdcard.c.

Definition at line 2822 of file ff.c.

FRESULT f_closedir ( DIR dp)

Close Directory.

Parameters
dpPointer to the directory object to be closed
Returns
FRESULT

Definition at line 3212 of file ff.c.

FRESULT f_getfree ( const TCHAR *  path,
DWORD *  nclst,
FATFS **  fatfs 
)

Get Number of Free Clusters.

Parameters
pathPath name of the logical drive number
nclstPointer to a variable to return number of free clusters
fatfsPointer to return pointer to corresponding file system object
Returns
FRESULT

Definition at line 3311 of file ff.c.

FRESULT f_lseek ( FIL fp,
DWORD  ofs 
)

Seek File R/W Pointer.

Parameters
fpPointer to the file object
ofsFile pointer from top of file
Returns
FRESULT
Examples:
sdcard.c.

Definition at line 3005 of file ff.c.

FRESULT f_mkdir ( const TCHAR *  path)

Create a Directory.

Parameters
pathPointer to the directory path
Returns
FRESULT

Definition at line 3493 of file ff.c.

FRESULT f_mount ( FATFS fs,
const TCHAR *  path,
BYTE  opt 
)

Mount/Unmount a Logical Drive.

Parameters
fsPointer to the file system object (NULL:unmount)
pathLogical drive number to be mounted/unmounted
opt
  • 0: Do not mount (delayed mount)
  • 1: Mount immediately
Returns
FRESULT
Examples:
sdcard.c.

Definition at line 2392 of file ff.c.

FRESULT f_open ( FIL fp,
const TCHAR *  path,
BYTE  mode 
)

Open or Create a File.

Parameters
fpPointer to the blank file object
pathPointer to the file name
modeAccess mode and file open mode flags, see FIL.flag
Returns
FRESULT
Examples:
sdcard.c.

Definition at line 2434 of file ff.c.

FRESULT f_opendir ( DIR dp,
const TCHAR *  path 
)

Create a Directory Object.

Parameters
dpPointer to directory object to create
pathPointer to the directory path
Returns
FRESULT

Definition at line 3160 of file ff.c.

FRESULT f_read ( FIL fp,
void *  buff,
UINT  btr,
UINT *  br 
)

Read File.

Parameters
fpPointer to the file object
buffPointer to data buffer
btrNumber of bytes to read
brPointer to number of bytes read
Returns
FRESULT
Examples:
sdcard.c.

Definition at line 2565 of file ff.c.

FRESULT f_readdir ( DIR dp,
FILINFO fno 
)

Read Directory Entries in Sequence.

Parameters
dpPointer to the open directory object
fnoPointer to file information to return
Returns
FRESULT

Definition at line 3238 of file ff.c.

FRESULT f_rename ( const TCHAR *  path_old,
const TCHAR *  path_new 
)

Rename File/Directory.

Parameters
path_oldPointer to the old name
path_newPointer to the new name
Returns
FRESULT

Definition at line 3644 of file ff.c.

FRESULT f_stat ( const TCHAR *  path,
FILINFO fno 
)

Get File Status.

Parameters
pathPointer to the file path
fnoPointer to file information to return
Returns
FRESULT

Definition at line 3277 of file ff.c.

FRESULT f_sync ( FIL fp)

Synchronize the File.

Parameters
fpPointer to the file object
Returns
FRESULT

Definition at line 2779 of file ff.c.

FRESULT f_truncate ( FIL fp)

Truncate File.

Parameters
fpPointer to the file object
Returns
FRESULT

Definition at line 3373 of file ff.c.

FRESULT f_unlink ( const TCHAR *  path)

Delete a File or Directory.

Parameters
pathPointer to the file or directory path
Returns
FRESULT

Definition at line 3426 of file ff.c.

FRESULT f_utime ( const TCHAR *  path,
const FILINFO fno 
)

Change Timestamp.

Parameters
pathPointer to the file/directory name
fnoPointer to the time stamp to be set
Returns
FRESULT

Definition at line 3605 of file ff.c.

FRESULT f_write ( FIL fp,
const void *  buff,
UINT  btw,
UINT *  bw 
)

Write File.

Parameters
fpPointer to the file object
buffPointer to the data to be written
btwNumber of bytes to write
bwPointer to number of bytes written
Returns
FRESULT
Examples:
sdcard.c.

Definition at line 2664 of file ff.c.