| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
ff.c File Reference
`#include "ff.h"`
`#include "diskio.h"`

Go to the source code of this file.

## Macros
#define | SS(fs) 512U /* Fixed sector size */
#define | ENTER_FF(fs)
#define | LEAVE_FF(fs, res) return res
#define | ABORT(fs, res) { fp->flag |= FA__ERROR; LEAVE_FF(fs, res); }
#define | IsUpper(c) (((c)>='A')&&((c)<='Z'))
#define | IsLower(c) (((c)>='a')&&((c)<='z'))
#define | IsDigit(c) (((c)>='0')&&((c)<='9'))
#define | IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E))
#define | IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E))
#define | NS 11 /* Index of name status byte in fn[] */
#define | NS_LOSS 0x01 /* Out of 8.3 format */
#define | NS_LFN 0x02 /* Force to create LFN entry */
#define | NS_LAST 0x04 /* Last segment */
#define | NS_BODY 0x08 /* Lower case flag (body) */
#define | NS_EXT 0x10 /* Lower case flag (ext) */
#define | NS_DOT 0x20 /* Dot entry */
#define | MIN_FAT16 4086 /* Minimum number of clusters for FAT16 */
#define | MIN_FAT32 65526 /* Minimum number of clusters for FAT32 */
#define | BS_jmpBoot 0 /* Jump instruction (3) */
#define | BS_OEMName 3 /* OEM name (8) */
#define | BPB_BytsPerSec 11 /* Sector size [byte] (2) */
#define | BPB_SecPerClus 13 /* Cluster size [sector] (1) */
#define | BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */
#define | BPB_NumFATs 16 /* Number of FAT copies (1) */
#define | BPB_RootEntCnt 17 /* Number of root dir entries for FAT12/16 (2) */
#define | BPB_TotSec16 19 /* Volume size [sector] (2) */
#define | BPB_Media 21 /* Media descriptor (1) */
#define | BPB_FATSz16 22 /* FAT size [sector] (2) */
#define | BPB_SecPerTrk 24 /* Track size [sector] (2) */
#define | BPB_NumHeads 26 /* Number of heads (2) */
#define | BPB_HiddSec 28 /* Number of special hidden sectors (4) */
#define | BPB_TotSec32 32 /* Volume size [sector] (4) */
#define | BS_DrvNum 36 /* Physical drive number (2) */
#define | BS_BootSig 38 /* Extended boot signature (1) */
#define | BS_VolID 39 /* Volume serial number (4) */
#define | BS_VolLab 43 /* Volume label (8) */
#define | BS_FilSysType 54 /* File system type (1) */
#define | BPB_FATSz32 36 /* FAT size [sector] (4) */
#define | BPB_ExtFlags 40 /* Extended flags (2) */
#define | BPB_FSVer 42 /* File system version (2) */
#define | BPB_RootClus 44 /* Root dir first cluster (4) */
#define | BPB_FSInfo 48 /* Offset of FSInfo sector (2) */
#define | BPB_BkBootSec 50 /* Offset of backup boot sector (2) */
#define | BS_DrvNum32 64 /* Physical drive number (2) */
#define | BS_BootSig32 66 /* Extended boot signature (1) */
#define | BS_VolID32 67 /* Volume serial number (4) */
#define | BS_VolLab32 71 /* Volume label (8) */
#define | BS_FilSysType32 82 /* File system type (1) */
#define | FSI_LeadSig 0 /* FSI: Leading signature (4) */
#define | FSI_StrucSig 484 /* FSI: Structure signature (4) */
#define | FSI_Free_Count 488 /* FSI: Number of free clusters (4) */
#define | FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */
#define | MBR_Table 446 /* MBR: Partition table offset (2) */
#define | SZ_PTE 16 /* MBR: Size of a partition table entry */
#define | BS_55AA 510 /* Boot sector signature (2) */
#define | DIR_Name 0 /* Short file name (11) */
#define | DIR_Attr 11 /* Attribute (1) */
#define | DIR_NTres 12 /* NT flag (1) */
#define | DIR_CrtTimeTenth 13 /* Created time sub-second (1) */
#define | DIR_CrtTime 14 /* Created time (2) */
#define | DIR_CrtDate 16 /* Created date (2) */
#define | DIR_LstAccDate 18 /* Last accessed date (2) */
#define | DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */
#define | DIR_WrtTime 22 /* Modified time (2) */
#define | DIR_WrtDate 24 /* Modified date (2) */
#define | DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */
#define | DIR_FileSize 28 /* File size (4) */
#define | LDIR_Ord 0 /* LFN entry order and LLE flag (1) */
#define | LDIR_Attr 11 /* LFN attribute (1) */
#define | LDIR_T 12 /* LFN type (1) */
#define | LDIR_Chksum 13 /* Sum of corresponding SFN entry */
#define | LDIR_FstClusLO 26 /* Filled by zero (0) */
#define | SZ_DIR 32 /* Size of a directory entry */
#define | LLE 0x40 /* Last long entry flag in LDIR_Ord */
#define | DDE 0xE5 /* Deleted directory entry mark in DIR_Name[0] */
#define | NDDE 0x05 /* Replacement of the character collides with DDE */
#define | DEF_NAMEBUF BYTE sfn[12]
#define | INIT_BUF(dobj) (dobj).fn = sfn
#define | FREE_BUF()

## Functions
static void | mem_cpy (void *dst, const void *src, UINT cnt)
static void | mem_set (void *dst, int val, UINT cnt)
static int | mem_cmp (const void *dst, const void *src, UINT cnt)
static int | chk_chr (const char *str, int chr)
static FRESULT | move_window (FATFS *fs, DWORD sector)
static FRESULT | sync (FATFS *fs)
DWORD | clust2sect (FATFS *fs, DWORD clst)
DWORD | get_fat (FATFS *fs, DWORD clst)
FRESULT | put_fat (FATFS *fs, DWORD clst, DWORD val)
static FRESULT | remove_chain (FATFS *fs, DWORD clst)
static DWORD | create_chain (FATFS *fs, DWORD clst)
static FRESULT | dir_sdi (DIR *dj, WORD idx)
static FRESULT | dir_next (DIR *dj, int stretch)
static DWORD | ld_clust (FATFS *fs, BYTE *dir)
static void | st_clust (BYTE *dir, DWORD cl)
static FRESULT | dir_find (DIR *dj)
static FRESULT | dir_read (DIR *dj)
static FRESULT | dir_register (DIR *dj)
static FRESULT | dir_remove (DIR *dj)
static FRESULT | create_name (DIR *dj, const TCHAR **path)
static void | get_fileinfo (DIR *dj, FILINFO *fno)
static FRESULT | follow_path (DIR *dj, const TCHAR *path)
static BYTE | check_fs (FATFS *fs, DWORD sect)
static FRESULT | chk_mounted (const TCHAR **path, FATFS **rfs, BYTE wmode)
static FRESULT | validate (void *obj)
FRESULT | f_mount (BYTE vol, FATFS *fs)
FRESULT | f_open (FIL *fp, const TCHAR *path, BYTE mode)
FRESULT | f_read (FIL *fp, void *buff, UINT btr, UINT *br)
FRESULT | f_write (FIL *fp, const void *buff, UINT btw, UINT *bw)
FRESULT | f_sync (FIL *fp)
FRESULT | f_close (FIL *fp)
FRESULT | f_lseek (FIL *fp, DWORD ofs)
FRESULT | f_opendir (DIR *dj, const TCHAR *path)
FRESULT | f_readdir (DIR *dj, FILINFO *fno)
FRESULT | f_stat (const TCHAR *path, FILINFO *fno)
FRESULT | f_getfree (const TCHAR *path, DWORD *nclst, FATFS **fatfs)
FRESULT | f_truncate (FIL *fp)
FRESULT | f_unlink (const TCHAR *path)
FRESULT | f_mkdir (const TCHAR *path)
FRESULT | f_chmod (const TCHAR *path, BYTE value, BYTE mask)
FRESULT | f_utime (const TCHAR *path, const FILINFO *fno)
FRESULT | f_rename (const TCHAR *path_old, const TCHAR *path_new)

## Variables
static FATFS * | FatFs [_VOLUMES]
static WORD | Fsid

## Macro Definition Documentation

#define ABORT | ( |  | fs,
|  |  | res
| ) |  | { fp->flag |= FA__ERROR; LEAVE_FF(fs, res); }

Definition at line 136 of file ff.c.

#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */

Definition at line 422 of file ff.c.

#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */

Definition at line 400 of file ff.c.

#define BPB_ExtFlags 40 /* Extended flags (2) */

Definition at line 418 of file ff.c.

#define BPB_FATSz16 22 /* FAT size [sector] (2) */

Definition at line 407 of file ff.c.

#define BPB_FATSz32 36 /* FAT size [sector] (4) */

Definition at line 417 of file ff.c.

#define BPB_FSInfo 48 /* Offset of FSInfo sector (2) */

Definition at line 421 of file ff.c.

#define BPB_FSVer 42 /* File system version (2) */

Definition at line 419 of file ff.c.

#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */

Definition at line 410 of file ff.c.

#define BPB_Media 21 /* Media descriptor (1) */

Definition at line 406 of file ff.c.

#define BPB_NumFATs 16 /* Number of FAT copies (1) */

Definition at line 403 of file ff.c.

#define BPB_NumHeads 26 /* Number of heads (2) */

Definition at line 409 of file ff.c.

#define BPB_RootClus 44 /* Root dir first cluster (4) */

Definition at line 420 of file ff.c.

#define BPB_RootEntCnt 17 /* Number of root dir entries for FAT12/16 (2) */

Definition at line 404 of file ff.c.

#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */

Definition at line 402 of file ff.c.

#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */

Definition at line 401 of file ff.c.

#define BPB_SecPerTrk 24 /* Track size [sector] (2) */

Definition at line 408 of file ff.c.

#define BPB_TotSec16 19 /* Volume size [sector] (2) */

Definition at line 405 of file ff.c.

#define BPB_TotSec32 32 /* Volume size [sector] (4) */

Definition at line 411 of file ff.c.

#define BS_55AA 510 /* Boot sector signature (2) */

Definition at line 434 of file ff.c.

#define BS_BootSig 38 /* Extended boot signature (1) */

Definition at line 413 of file ff.c.

#define BS_BootSig32 66 /* Extended boot signature (1) */

Definition at line 424 of file ff.c.

#define BS_DrvNum 36 /* Physical drive number (2) */

Definition at line 412 of file ff.c.

#define BS_DrvNum32 64 /* Physical drive number (2) */

Definition at line 423 of file ff.c.

#define BS_FilSysType 54 /* File system type (1) */

Definition at line 416 of file ff.c.

#define BS_FilSysType32 82 /* File system type (1) */

Definition at line 427 of file ff.c.

#define BS_jmpBoot 0 /* Jump instruction (3) */

Definition at line 398 of file ff.c.

#define BS_OEMName 3 /* OEM name (8) */

Definition at line 399 of file ff.c.

#define BS_VolID 39 /* Volume serial number (4) */

Definition at line 414 of file ff.c.

#define BS_VolID32 67 /* Volume serial number (4) */

Definition at line 425 of file ff.c.

#define BS_VolLab 43 /* Volume label (8) */

Definition at line 415 of file ff.c.

#define BS_VolLab32 71 /* Volume label (8) */

Definition at line 426 of file ff.c.

#define DDE 0xE5 /* Deleted directory entry mark in DIR_Name[0] */

Definition at line 455 of file ff.c.

#define DEF_NAMEBUF BYTE sfn[12]

Definition at line 488 of file ff.c.

#define DIR_Attr 11 /* Attribute (1) */

Definition at line 437 of file ff.c.

#define DIR_CrtDate 16 /* Created date (2) */

Definition at line 441 of file ff.c.

#define DIR_CrtTime 14 /* Created time (2) */

Definition at line 440 of file ff.c.

#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */

Definition at line 439 of file ff.c.

#define DIR_FileSize 28 /* File size (4) */

Definition at line 447 of file ff.c.

#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */

Definition at line 443 of file ff.c.

#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */

Definition at line 446 of file ff.c.

#define DIR_LstAccDate 18 /* Last accessed date (2) */

Definition at line 442 of file ff.c.

#define DIR_Name 0 /* Short file name (11) */

Definition at line 436 of file ff.c.

#define DIR_NTres 12 /* NT flag (1) */

Definition at line 438 of file ff.c.

#define DIR_WrtDate 24 /* Modified date (2) */

Definition at line 445 of file ff.c.

#define DIR_WrtTime 22 /* Modified time (2) */

Definition at line 444 of file ff.c.

#define ENTER_FF | ( |  | fs | ) |

Definition at line 132 of file ff.c.

#define FREE_BUF | ( |  | ) |

Definition at line 490 of file ff.c.

#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */

Definition at line 430 of file ff.c.

#define FSI_LeadSig 0 /* FSI: Leading signature (4) */

Definition at line 428 of file ff.c.

#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */

Definition at line 431 of file ff.c.

#define FSI_StrucSig 484 /* FSI: Structure signature (4) */

Definition at line 429 of file ff.c.

#define INIT_BUF | ( |  | dobj | ) | (dobj).fn = sfn

Definition at line 489 of file ff.c.

#define IsDBCS1 | ( |  | c | ) | (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E))

Definition at line 359 of file ff.c.

#define IsDBCS2 | ( |  | c | ) | (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E))

Definition at line 367 of file ff.c.

#define IsDigit | ( |  | c | ) | (((c)>='0')&&((c)<='9'))

Definition at line 354 of file ff.c.

#define IsLower | ( |  | c | ) | (((c)>='a')&&((c)<='z'))

Definition at line 353 of file ff.c.

#define IsUpper | ( |  | c | ) | (((c)>='A')&&((c)<='Z'))

Definition at line 352 of file ff.c.

#define LDIR_Attr 11 /* LFN attribute (1) */

Definition at line 449 of file ff.c.

#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */

Definition at line 451 of file ff.c.

#define LDIR_FstClusLO 26 /* Filled by zero (0) */

Definition at line 452 of file ff.c.

#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */

Definition at line 448 of file ff.c.

#define LDIR_T 12 /* LFN type (1) */

Definition at line 450 of file ff.c.

#define LEAVE_FF | ( |  | fs,
|  |  | res
| ) |  | return res

Definition at line 133 of file ff.c.

#define LLE 0x40 /* Last long entry flag in LDIR_Ord */

Definition at line 454 of file ff.c.

#define MBR_Table 446 /* MBR: Partition table offset (2) */

Definition at line 432 of file ff.c.

#define MIN_FAT16 4086 /* Minimum number of clusters for FAT16 */

Definition at line 390 of file ff.c.

#define MIN_FAT32 65526 /* Minimum number of clusters for FAT32 */

Definition at line 391 of file ff.c.

#define NDDE 0x05 /* Replacement of the character collides with DDE */

Definition at line 456 of file ff.c.

#define NS 11 /* Index of name status byte in fn[] */

Definition at line 379 of file ff.c.

#define NS_BODY 0x08 /* Lower case flag (body) */

Definition at line 383 of file ff.c.

#define NS_DOT 0x20 /* Dot entry */

Definition at line 385 of file ff.c.

#define NS_EXT 0x10 /* Lower case flag (ext) */

Definition at line 384 of file ff.c.

#define NS_LAST 0x04 /* Last segment */

Definition at line 382 of file ff.c.

#define NS_LFN 0x02 /* Force to create LFN entry */

Definition at line 381 of file ff.c.

#define NS_LOSS 0x01 /* Out of 8.3 format */

Definition at line 380 of file ff.c.

#define SS | ( |  | fs | ) | 512U /* Fixed sector size */

Definition at line 120 of file ff.c.

#define SZ_DIR 32 /* Size of a directory entry */

Definition at line 453 of file ff.c.

#define SZ_PTE 16 /* MBR: Size of a partition table entry */

Definition at line 433 of file ff.c.

## Function Documentation

static BYTE check_fs | ( | FATFS * | fs,
|  | DWORD | sect
| ) |  |
| static

Definition at line 2017 of file ff.c.

static int chk_chr | ( | const char * | str,
|  | int | chr
| ) |  |
| static

Definition at line 566 of file ff.c.

static FRESULT chk_mounted | ( | const TCHAR ** | path,
|  | FATFS ** | rfs,
|  | BYTE | wmode
| ) |  |
| static

Definition at line 2043 of file ff.c.

DWORD clust2sect | ( | FATFS * | fs,
|  | DWORD | clst
| ) |  |

Definition at line 803 of file ff.c.

static DWORD create_chain | ( | FATFS * | fs,
|  | DWORD | clst
| ) |  |
| static

Definition at line 980 of file ff.c.

static FRESULT create_name | ( | DIR * | dj,
|  | const TCHAR ** | path
| ) |  |
| static

Definition at line 1659 of file ff.c.

static FRESULT dir_find | ( | DIR * | dj | ) |
| static

Definition at line 1389 of file ff.c.

static FRESULT dir_next | ( | DIR * | dj,
|  | int | stretch
| ) |  |
| static

Definition at line 1115 of file ff.c.

static FRESULT dir_read | ( | DIR * | dj | ) |
| static

Definition at line 1450 of file ff.c.

static FRESULT dir_register | ( | DIR * | dj | ) |
| static

Definition at line 1507 of file ff.c.

static FRESULT dir_remove | ( | DIR * | dj | ) |
| static

Definition at line 1614 of file ff.c.

static FRESULT dir_sdi | ( | DIR * | dj,
|  | WORD | idx
| ) |  |
| static

Definition at line 1067 of file ff.c.

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

Definition at line 3391 of file ff.c.

FRESULT f_close | ( | FIL * | fp | ) |

Definition at line 2684 of file ff.c.

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

Definition at line 3133 of file ff.c.

FRESULT f_lseek | ( | FIL * | fp,
|  | DWORD | ofs
| ) |  |

Definition at line 2853 of file ff.c.

FRESULT f_mkdir | ( | const TCHAR * | path | ) |

Definition at line 3318 of file ff.c.

FRESULT f_mount | ( | BYTE | vol,
|  | FATFS * | fs
| ) |  |

Definition at line 2244 of file ff.c.

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

Definition at line 2284 of file ff.c.

FRESULT f_opendir | ( | DIR * | dj,
|  | const TCHAR * | path
| ) |  |

Definition at line 3011 of file ff.c.

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

Definition at line 2416 of file ff.c.

FRESULT f_readdir | ( | DIR * | dj,
|  | FILINFO * | fno
| ) |  |

Definition at line 3058 of file ff.c.

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

Definition at line 3474 of file ff.c.

FRESULT f_stat | ( | const TCHAR * | path,
|  | FILINFO * | fno
| ) |  |

Definition at line 3100 of file ff.c.

FRESULT f_sync | ( | FIL * | fp | ) |

Definition at line 2636 of file ff.c.

FRESULT f_truncate | ( | FIL * | fp | ) |

Definition at line 3200 of file ff.c.

FRESULT f_unlink | ( | const TCHAR * | path | ) |

Definition at line 3250 of file ff.c.

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

Definition at line 3433 of file ff.c.

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

Definition at line 2517 of file ff.c.

static FRESULT follow_path | ( | DIR * | dj,
|  | const TCHAR * | path
| ) |  |
| static

Definition at line 1955 of file ff.c.

DWORD get_fat | ( | FATFS * | fs,
|  | DWORD | clst
| ) |  |

Definition at line 821 of file ff.c.

static void get_fileinfo | ( | DIR * | dj,
|  | FILINFO * | fno
| ) |  |
| static

Definition at line 1873 of file ff.c.

static DWORD ld_clust | ( | FATFS * | fs,
|  | BYTE * | dir
| ) |  |
| static

Definition at line 1183 of file ff.c.

static int mem_cmp | ( | const void * | dst,
|  | const void * | src,
|  | UINT | cnt
| ) |  |
| static

Definition at line 556 of file ff.c.

static void mem_cpy | ( | void * | dst,
|  | const void * | src,
|  | UINT | cnt
| ) |  |
| static

Definition at line 530 of file ff.c.

static void mem_set | ( | void * | dst,
|  | int | val,
|  | UINT | cnt
| ) |  |
| static

Definition at line 547 of file ff.c.

static FRESULT move_window | ( | FATFS * | fs,
|  | DWORD | sector
| ) |  |
| static

Definition at line 721 of file ff.c.

FRESULT put_fat | ( | FATFS * | fs,
|  | DWORD | clst,
|  | DWORD | val
| ) |  |

Definition at line 864 of file ff.c.

static FRESULT remove_chain | ( | FATFS * | fs,
|  | DWORD | clst
| ) |  |
| static

Definition at line 927 of file ff.c.

static void st_clust | ( | BYTE * | dir,
|  | DWORD | cl
| ) |  |
| static

Definition at line 1200 of file ff.c.

static FRESULT sync | ( | FATFS * | fs | ) |
| static

Definition at line 763 of file ff.c.

static FRESULT validate | ( | void * | obj | ) |
| static

Definition at line 2210 of file ff.c.

## Variable Documentation

FATFS* FatFs[_VOLUMES]
| static

Definition at line 469 of file ff.c.

WORD Fsid
| static

Definition at line 475 of file ff.c.