first 2016/02 SDFileSystemDMA inherited from Official SDFileSystem.
Dependents: SDFileSystemDMA-test DmdFullRGB_0_1
Fork of SDFileSystemDMA by
SDFileSystemDMA is enhanced SDFileSystem library for STM32 micros by using DMA functionality.
Max read transfer rate reaches over 2MByte/sec at 24MHz SPI clock if enough read buffer size is set.
Even though minimum read buffer size (512Byte) is set, read transfer rate will reach over 1MByte/sec at 24MHz SPI Clock.
( but depends on the ability of each SD card)
Test program is here.
https://developer.mbed.org/users/mimi3/code/SDFileSystemDMA-test/
Supported SPI port is shown below table.
(v): Verified. It works well.
(w): Probably it will work well. (not tested)
(c): Only compiled. (not tested)
(f): Over flash.
(r): Only read mode. (when _FS_READONLY==1)
(u) Under construction
(z): Dose not work.
Caution
If your board has SRAM less than or equal to 8KB, the buffer size must be set to 512 Bytes.
Supported Boards:
Cortex-M0
Board | SRAM | SPI1 | SPI2 | SPI3 |
---|---|---|---|---|
NUCLEO-F030R8 | 8KB | (v) | ||
DISCO-F051R8 | 8KB | (w) | ||
4KB | (f) | |||
NUCLEO-F042K6 | 6KB | (r) | ||
NUCLEO-F070RB | 16KB | (w) | ||
NUCLEO-F072RB | 16KB | (w) | ||
NUCLEO-F091RC | 32KB | (c) |
Cortex-L0
Board | SRAM | SPI1 | SPI2 | SPI3 |
---|---|---|---|---|
DISCO-L053C8 | 8KB | (c) | ||
NUCLEO-L053R8 | 8KB | (c) | ||
NUCLEO-L073RZ | 20KB | (c) |
Cortex-M3
Board | SRAM | SPI1 | SPI2 | SPI3 |
---|---|---|---|---|
DISCO-F100RB | 8KB | (v) | (v) | - |
BLUEPILL-F103CB | 20KB | (w) | (w) | - |
NUCLEO-F103RB | 20KB | (v) | (v) | - |
NUCLEO-L152RE | 80KB | (v) | (w) | - |
MOTE-L152RC | 32KB | (w) | (w) | - |
Cortex-M4
F3
Board | SRAM | SPI1 | SPI2 | SPI3 |
---|---|---|---|---|
DISCO-F303VC | 40KB | - | (v) | (v) |
NUCLEO-F303RE | 64KB | (w) | (w) | (w) |
NUCLEO-F302R8 | 16KB | - | - | (c) |
NUCLEO-F303K8 | 12KB | (c) | - | - |
DISCO-F334C8 | 12KB | (c) | - | - |
NUCLEO-F334R8 | 12KB | (c) | - | - |
F4
Board | SPI1 | SPI2 | SPI3 |
---|---|---|---|
ELMO-F411RE | (w) | - | (w) |
MTS-MDOT-F411RE | (u) | - | (u) |
MTS-DRAGONFLY-F411RE | (w) | - | (w) |
NUCLEO-F411RE | (v) | - | (v) |
NUCLEO-F401RE | (w) | - | (w) |
MTS-MDOT-F405RG | (u) | - | (u) |
NUCLEO-F410RB | (c) | - | (c) |
NUCLEO-F446RE | (c) | - | (c) |
NUCLEO-F429ZI | (c) | - | (c) |
B96B-F446VE | (c) | - | (c) |
NUCLEO-F446ZE | (c) | - | (c) |
DISCO-F429ZI | (u) | - | (u) |
DISCO-F469NI | (c) | - | (c) |
Information
This library is set to use "short file name" in SDFileSystemDMA/FATFileSystem/ChaN/ffconf.h . ( _USE_LFN=0)
You can change this option to _USE_LFN=1 .
FATFileSystem/ChaN/ff.h@38:7077795dbf81, 2017-01-22 (annotated)
- Committer:
- mimi3
- Date:
- Sun Jan 22 23:13:11 2017 +0900
- Revision:
- 38:7077795dbf81
- Parent:
- 10:b48d3ace55db
change: table.md
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mimi3 | 10:b48d3ace55db | 1 | /*---------------------------------------------------------------------------/ |
mimi3 | 10:b48d3ace55db | 2 | / FatFs - FAT file system module include R0.11a (C)ChaN, 2015 |
mimi3 | 10:b48d3ace55db | 3 | /----------------------------------------------------------------------------/ |
mimi3 | 10:b48d3ace55db | 4 | / FatFs module is a free software that opened under license policy of |
mimi3 | 10:b48d3ace55db | 5 | / following conditions. |
mimi3 | 10:b48d3ace55db | 6 | / |
mimi3 | 10:b48d3ace55db | 7 | / Copyright (C) 2015, ChaN, all right reserved. |
mimi3 | 10:b48d3ace55db | 8 | / |
mimi3 | 10:b48d3ace55db | 9 | / 1. Redistributions of source code must retain the above copyright notice, |
mimi3 | 10:b48d3ace55db | 10 | / this condition and the following disclaimer. |
mimi3 | 10:b48d3ace55db | 11 | / |
mimi3 | 10:b48d3ace55db | 12 | / This software is provided by the copyright holder and contributors "AS IS" |
mimi3 | 10:b48d3ace55db | 13 | / and any warranties related to this software are DISCLAIMED. |
mimi3 | 10:b48d3ace55db | 14 | / The copyright owner or contributors be NOT LIABLE for any damages caused |
mimi3 | 10:b48d3ace55db | 15 | / by use of this software. |
mimi3 | 10:b48d3ace55db | 16 | /---------------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 17 | |
mimi3 | 10:b48d3ace55db | 18 | |
mimi3 | 10:b48d3ace55db | 19 | #ifndef _FATFS |
mimi3 | 10:b48d3ace55db | 20 | #define _FATFS 64180 /* Revision ID */ |
mimi3 | 10:b48d3ace55db | 21 | |
mimi3 | 10:b48d3ace55db | 22 | #ifdef __cplusplus |
mimi3 | 10:b48d3ace55db | 23 | extern "C" { |
mimi3 | 10:b48d3ace55db | 24 | #endif |
mimi3 | 10:b48d3ace55db | 25 | |
mimi3 | 10:b48d3ace55db | 26 | #include "integer.h" /* Basic integer types */ |
mimi3 | 10:b48d3ace55db | 27 | #include "ffconf.h" /* FatFs configuration options */ |
mimi3 | 10:b48d3ace55db | 28 | #if _FATFS != _FFCONF |
mimi3 | 10:b48d3ace55db | 29 | #error Wrong configuration file (ffconf.h). |
mimi3 | 10:b48d3ace55db | 30 | #endif |
mimi3 | 10:b48d3ace55db | 31 | |
mimi3 | 10:b48d3ace55db | 32 | |
mimi3 | 10:b48d3ace55db | 33 | |
mimi3 | 10:b48d3ace55db | 34 | /* Definitions of volume management */ |
mimi3 | 10:b48d3ace55db | 35 | |
mimi3 | 10:b48d3ace55db | 36 | #if _MULTI_PARTITION /* Multiple partition configuration */ |
mimi3 | 10:b48d3ace55db | 37 | typedef struct { |
mimi3 | 10:b48d3ace55db | 38 | BYTE pd; /* Physical drive number */ |
mimi3 | 10:b48d3ace55db | 39 | BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ |
mimi3 | 10:b48d3ace55db | 40 | } PARTITION; |
mimi3 | 10:b48d3ace55db | 41 | extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ |
mimi3 | 10:b48d3ace55db | 42 | #define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ |
mimi3 | 10:b48d3ace55db | 43 | #define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ |
mimi3 | 10:b48d3ace55db | 44 | |
mimi3 | 10:b48d3ace55db | 45 | #else /* Single partition configuration */ |
mimi3 | 10:b48d3ace55db | 46 | #define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */ |
mimi3 | 10:b48d3ace55db | 47 | #define LD2PT(vol) 0 /* Find first valid partition or in SFD */ |
mimi3 | 10:b48d3ace55db | 48 | |
mimi3 | 10:b48d3ace55db | 49 | #endif |
mimi3 | 10:b48d3ace55db | 50 | |
mimi3 | 10:b48d3ace55db | 51 | |
mimi3 | 10:b48d3ace55db | 52 | |
mimi3 | 10:b48d3ace55db | 53 | /* Type of path name strings on FatFs API */ |
mimi3 | 10:b48d3ace55db | 54 | |
mimi3 | 10:b48d3ace55db | 55 | #if _LFN_UNICODE /* Unicode string */ |
mimi3 | 10:b48d3ace55db | 56 | #if !_USE_LFN |
mimi3 | 10:b48d3ace55db | 57 | #error _LFN_UNICODE must be 0 at non-LFN cfg. |
mimi3 | 10:b48d3ace55db | 58 | #endif |
mimi3 | 10:b48d3ace55db | 59 | #ifndef _INC_TCHAR |
mimi3 | 10:b48d3ace55db | 60 | typedef WCHAR TCHAR; |
mimi3 | 10:b48d3ace55db | 61 | #define _T(x) L ## x |
mimi3 | 10:b48d3ace55db | 62 | #define _TEXT(x) L ## x |
mimi3 | 10:b48d3ace55db | 63 | #endif |
mimi3 | 10:b48d3ace55db | 64 | |
mimi3 | 10:b48d3ace55db | 65 | #else /* ANSI/OEM string */ |
mimi3 | 10:b48d3ace55db | 66 | #ifndef _INC_TCHAR |
mimi3 | 10:b48d3ace55db | 67 | typedef char TCHAR; |
mimi3 | 10:b48d3ace55db | 68 | #define _T(x) x |
mimi3 | 10:b48d3ace55db | 69 | #define _TEXT(x) x |
mimi3 | 10:b48d3ace55db | 70 | #endif |
mimi3 | 10:b48d3ace55db | 71 | |
mimi3 | 10:b48d3ace55db | 72 | #endif |
mimi3 | 10:b48d3ace55db | 73 | |
mimi3 | 10:b48d3ace55db | 74 | |
mimi3 | 10:b48d3ace55db | 75 | |
mimi3 | 10:b48d3ace55db | 76 | /* File system object structure (FATFS) */ |
mimi3 | 10:b48d3ace55db | 77 | |
mimi3 | 10:b48d3ace55db | 78 | typedef struct { |
mimi3 | 10:b48d3ace55db | 79 | BYTE fs_type; /* FAT sub-type (0:Not mounted) */ |
mimi3 | 10:b48d3ace55db | 80 | BYTE drv; /* Physical drive number */ |
mimi3 | 10:b48d3ace55db | 81 | BYTE csize; /* Sectors per cluster (1,2,4...128) */ |
mimi3 | 10:b48d3ace55db | 82 | BYTE n_fats; /* Number of FAT copies (1 or 2) */ |
mimi3 | 10:b48d3ace55db | 83 | BYTE wflag; /* win[] flag (b0:dirty) */ |
mimi3 | 10:b48d3ace55db | 84 | BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ |
mimi3 | 10:b48d3ace55db | 85 | WORD id; /* File system mount ID */ |
mimi3 | 10:b48d3ace55db | 86 | WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ |
mimi3 | 10:b48d3ace55db | 87 | #if _MAX_SS != _MIN_SS |
mimi3 | 10:b48d3ace55db | 88 | WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */ |
mimi3 | 10:b48d3ace55db | 89 | #endif |
mimi3 | 10:b48d3ace55db | 90 | #if _FS_REENTRANT |
mimi3 | 10:b48d3ace55db | 91 | _SYNC_t sobj; /* Identifier of sync object */ |
mimi3 | 10:b48d3ace55db | 92 | #endif |
mimi3 | 10:b48d3ace55db | 93 | #if !_FS_READONLY |
mimi3 | 10:b48d3ace55db | 94 | DWORD last_clust; /* Last allocated cluster */ |
mimi3 | 10:b48d3ace55db | 95 | DWORD free_clust; /* Number of free clusters */ |
mimi3 | 10:b48d3ace55db | 96 | #endif |
mimi3 | 10:b48d3ace55db | 97 | #if _FS_RPATH |
mimi3 | 10:b48d3ace55db | 98 | DWORD cdir; /* Current directory start cluster (0:root) */ |
mimi3 | 10:b48d3ace55db | 99 | #endif |
mimi3 | 10:b48d3ace55db | 100 | DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ |
mimi3 | 10:b48d3ace55db | 101 | DWORD fsize; /* Sectors per FAT */ |
mimi3 | 10:b48d3ace55db | 102 | DWORD volbase; /* Volume start sector */ |
mimi3 | 10:b48d3ace55db | 103 | DWORD fatbase; /* FAT start sector */ |
mimi3 | 10:b48d3ace55db | 104 | DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ |
mimi3 | 10:b48d3ace55db | 105 | DWORD database; /* Data start sector */ |
mimi3 | 10:b48d3ace55db | 106 | DWORD winsect; /* Current sector appearing in the win[] */ |
mimi3 | 10:b48d3ace55db | 107 | BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ |
mimi3 | 10:b48d3ace55db | 108 | } FATFS; |
mimi3 | 10:b48d3ace55db | 109 | |
mimi3 | 10:b48d3ace55db | 110 | |
mimi3 | 10:b48d3ace55db | 111 | |
mimi3 | 10:b48d3ace55db | 112 | /* File object structure (FIL) */ |
mimi3 | 10:b48d3ace55db | 113 | |
mimi3 | 10:b48d3ace55db | 114 | typedef struct { |
mimi3 | 10:b48d3ace55db | 115 | FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ |
mimi3 | 10:b48d3ace55db | 116 | WORD id; /* Owner file system mount ID (**do not change order**) */ |
mimi3 | 10:b48d3ace55db | 117 | BYTE flag; /* Status flags */ |
mimi3 | 10:b48d3ace55db | 118 | BYTE err; /* Abort flag (error code) */ |
mimi3 | 10:b48d3ace55db | 119 | DWORD fptr; /* File read/write pointer (Zeroed on file open) */ |
mimi3 | 10:b48d3ace55db | 120 | DWORD fsize; /* File size */ |
mimi3 | 10:b48d3ace55db | 121 | DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ |
mimi3 | 10:b48d3ace55db | 122 | DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ |
mimi3 | 10:b48d3ace55db | 123 | DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ |
mimi3 | 10:b48d3ace55db | 124 | #if !_FS_READONLY |
mimi3 | 10:b48d3ace55db | 125 | DWORD dir_sect; /* Sector number containing the directory entry */ |
mimi3 | 10:b48d3ace55db | 126 | BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ |
mimi3 | 10:b48d3ace55db | 127 | #endif |
mimi3 | 10:b48d3ace55db | 128 | #if _USE_FASTSEEK |
mimi3 | 10:b48d3ace55db | 129 | DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */ |
mimi3 | 10:b48d3ace55db | 130 | #endif |
mimi3 | 10:b48d3ace55db | 131 | #if _FS_LOCK |
mimi3 | 10:b48d3ace55db | 132 | UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ |
mimi3 | 10:b48d3ace55db | 133 | #endif |
mimi3 | 10:b48d3ace55db | 134 | #if !_FS_TINY |
mimi3 | 10:b48d3ace55db | 135 | BYTE buf[_MAX_SS]; /* File private data read/write window */ |
mimi3 | 10:b48d3ace55db | 136 | #endif |
mimi3 | 10:b48d3ace55db | 137 | } FIL; |
mimi3 | 10:b48d3ace55db | 138 | |
mimi3 | 10:b48d3ace55db | 139 | |
mimi3 | 10:b48d3ace55db | 140 | |
mimi3 | 10:b48d3ace55db | 141 | /* Directory object structure (FATFS_DIR) */ |
mimi3 | 10:b48d3ace55db | 142 | |
mimi3 | 10:b48d3ace55db | 143 | typedef struct { |
mimi3 | 10:b48d3ace55db | 144 | FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ |
mimi3 | 10:b48d3ace55db | 145 | WORD id; /* Owner file system mount ID (**do not change order**) */ |
mimi3 | 10:b48d3ace55db | 146 | WORD index; /* Current read/write index number */ |
mimi3 | 10:b48d3ace55db | 147 | DWORD sclust; /* Table start cluster (0:Root dir) */ |
mimi3 | 10:b48d3ace55db | 148 | DWORD clust; /* Current cluster */ |
mimi3 | 10:b48d3ace55db | 149 | DWORD sect; /* Current sector */ |
mimi3 | 10:b48d3ace55db | 150 | BYTE* dir; /* Pointer to the current SFN entry in the win[] */ |
mimi3 | 10:b48d3ace55db | 151 | BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ |
mimi3 | 10:b48d3ace55db | 152 | #if _FS_LOCK |
mimi3 | 10:b48d3ace55db | 153 | UINT lockid; /* File lock ID (index of file semaphore table Files[]) */ |
mimi3 | 10:b48d3ace55db | 154 | #endif |
mimi3 | 10:b48d3ace55db | 155 | #if _USE_LFN |
mimi3 | 10:b48d3ace55db | 156 | WCHAR* lfn; /* Pointer to the LFN working buffer */ |
mimi3 | 10:b48d3ace55db | 157 | WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ |
mimi3 | 10:b48d3ace55db | 158 | #endif |
mimi3 | 10:b48d3ace55db | 159 | #if _USE_FIND |
mimi3 | 10:b48d3ace55db | 160 | const TCHAR* pat; /* Pointer to the name matching pattern */ |
mimi3 | 10:b48d3ace55db | 161 | #endif |
mimi3 | 10:b48d3ace55db | 162 | } FATFS_DIR; |
mimi3 | 10:b48d3ace55db | 163 | |
mimi3 | 10:b48d3ace55db | 164 | |
mimi3 | 10:b48d3ace55db | 165 | |
mimi3 | 10:b48d3ace55db | 166 | /* File information structure (FILINFO) */ |
mimi3 | 10:b48d3ace55db | 167 | |
mimi3 | 10:b48d3ace55db | 168 | typedef struct { |
mimi3 | 10:b48d3ace55db | 169 | DWORD fsize; /* File size */ |
mimi3 | 10:b48d3ace55db | 170 | WORD fdate; /* Last modified date */ |
mimi3 | 10:b48d3ace55db | 171 | WORD ftime; /* Last modified time */ |
mimi3 | 10:b48d3ace55db | 172 | BYTE fattrib; /* Attribute */ |
mimi3 | 10:b48d3ace55db | 173 | TCHAR fname[13]; /* Short file name (8.3 format) */ |
mimi3 | 10:b48d3ace55db | 174 | #if _USE_LFN |
mimi3 | 10:b48d3ace55db | 175 | TCHAR* lfname; /* Pointer to the LFN buffer */ |
mimi3 | 10:b48d3ace55db | 176 | UINT lfsize; /* Size of LFN buffer in TCHAR */ |
mimi3 | 10:b48d3ace55db | 177 | #endif |
mimi3 | 10:b48d3ace55db | 178 | } FILINFO; |
mimi3 | 10:b48d3ace55db | 179 | |
mimi3 | 10:b48d3ace55db | 180 | |
mimi3 | 10:b48d3ace55db | 181 | |
mimi3 | 10:b48d3ace55db | 182 | /* File function return code (FRESULT) */ |
mimi3 | 10:b48d3ace55db | 183 | |
mimi3 | 10:b48d3ace55db | 184 | typedef enum { |
mimi3 | 10:b48d3ace55db | 185 | FR_OK = 0, /* (0) Succeeded */ |
mimi3 | 10:b48d3ace55db | 186 | FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ |
mimi3 | 10:b48d3ace55db | 187 | FR_INT_ERR, /* (2) Assertion failed */ |
mimi3 | 10:b48d3ace55db | 188 | FR_NOT_READY, /* (3) The physical drive cannot work */ |
mimi3 | 10:b48d3ace55db | 189 | FR_NO_FILE, /* (4) Could not find the file */ |
mimi3 | 10:b48d3ace55db | 190 | FR_NO_PATH, /* (5) Could not find the path */ |
mimi3 | 10:b48d3ace55db | 191 | FR_INVALID_NAME, /* (6) The path name format is invalid */ |
mimi3 | 10:b48d3ace55db | 192 | FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ |
mimi3 | 10:b48d3ace55db | 193 | FR_EXIST, /* (8) Access denied due to prohibited access */ |
mimi3 | 10:b48d3ace55db | 194 | FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ |
mimi3 | 10:b48d3ace55db | 195 | FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ |
mimi3 | 10:b48d3ace55db | 196 | FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ |
mimi3 | 10:b48d3ace55db | 197 | FR_NOT_ENABLED, /* (12) The volume has no work area */ |
mimi3 | 10:b48d3ace55db | 198 | FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ |
mimi3 | 10:b48d3ace55db | 199 | FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ |
mimi3 | 10:b48d3ace55db | 200 | FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ |
mimi3 | 10:b48d3ace55db | 201 | FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ |
mimi3 | 10:b48d3ace55db | 202 | FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ |
mimi3 | 10:b48d3ace55db | 203 | FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_LOCK */ |
mimi3 | 10:b48d3ace55db | 204 | FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ |
mimi3 | 10:b48d3ace55db | 205 | } FRESULT; |
mimi3 | 10:b48d3ace55db | 206 | |
mimi3 | 10:b48d3ace55db | 207 | |
mimi3 | 10:b48d3ace55db | 208 | |
mimi3 | 10:b48d3ace55db | 209 | /*--------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 210 | /* FatFs module application interface */ |
mimi3 | 10:b48d3ace55db | 211 | |
mimi3 | 10:b48d3ace55db | 212 | FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ |
mimi3 | 10:b48d3ace55db | 213 | FRESULT f_close (FIL* fp); /* Close an open file object */ |
mimi3 | 10:b48d3ace55db | 214 | FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ |
mimi3 | 10:b48d3ace55db | 215 | FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ |
mimi3 | 10:b48d3ace55db | 216 | FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ |
mimi3 | 10:b48d3ace55db | 217 | FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ |
mimi3 | 10:b48d3ace55db | 218 | FRESULT f_truncate (FIL* fp); /* Truncate file */ |
mimi3 | 10:b48d3ace55db | 219 | FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ |
mimi3 | 10:b48d3ace55db | 220 | FRESULT f_opendir (FATFS_DIR* dp, const TCHAR* path); /* Open a directory */ |
mimi3 | 10:b48d3ace55db | 221 | FRESULT f_closedir (FATFS_DIR* dp); /* Close an open directory */ |
mimi3 | 10:b48d3ace55db | 222 | FRESULT f_readdir (FATFS_DIR* dp, FILINFO* fno); /* Read a directory item */ |
mimi3 | 10:b48d3ace55db | 223 | FRESULT f_findfirst (FATFS_DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ |
mimi3 | 10:b48d3ace55db | 224 | FRESULT f_findnext (FATFS_DIR* dp, FILINFO* fno); /* Find next file */ |
mimi3 | 10:b48d3ace55db | 225 | FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ |
mimi3 | 10:b48d3ace55db | 226 | FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ |
mimi3 | 10:b48d3ace55db | 227 | FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ |
mimi3 | 10:b48d3ace55db | 228 | FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ |
mimi3 | 10:b48d3ace55db | 229 | FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */ |
mimi3 | 10:b48d3ace55db | 230 | FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ |
mimi3 | 10:b48d3ace55db | 231 | FRESULT f_chdir (const TCHAR* path); /* Change current directory */ |
mimi3 | 10:b48d3ace55db | 232 | FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ |
mimi3 | 10:b48d3ace55db | 233 | FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ |
mimi3 | 10:b48d3ace55db | 234 | FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ |
mimi3 | 10:b48d3ace55db | 235 | FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ |
mimi3 | 10:b48d3ace55db | 236 | FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ |
mimi3 | 10:b48d3ace55db | 237 | FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ |
mimi3 | 10:b48d3ace55db | 238 | FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ |
mimi3 | 10:b48d3ace55db | 239 | FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ |
mimi3 | 10:b48d3ace55db | 240 | int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ |
mimi3 | 10:b48d3ace55db | 241 | int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ |
mimi3 | 10:b48d3ace55db | 242 | int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ |
mimi3 | 10:b48d3ace55db | 243 | TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ |
mimi3 | 10:b48d3ace55db | 244 | |
mimi3 | 10:b48d3ace55db | 245 | #define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize)) |
mimi3 | 10:b48d3ace55db | 246 | #define f_error(fp) ((fp)->err) |
mimi3 | 10:b48d3ace55db | 247 | #define f_tell(fp) ((fp)->fptr) |
mimi3 | 10:b48d3ace55db | 248 | #define f_size(fp) ((fp)->fsize) |
mimi3 | 10:b48d3ace55db | 249 | #define f_rewind(fp) f_lseek((fp), 0) |
mimi3 | 10:b48d3ace55db | 250 | #define f_rewinddir(dp) f_readdir((dp), 0) |
mimi3 | 10:b48d3ace55db | 251 | |
mimi3 | 10:b48d3ace55db | 252 | #ifndef EOF |
mimi3 | 10:b48d3ace55db | 253 | #define EOF (-1) |
mimi3 | 10:b48d3ace55db | 254 | #endif |
mimi3 | 10:b48d3ace55db | 255 | |
mimi3 | 10:b48d3ace55db | 256 | |
mimi3 | 10:b48d3ace55db | 257 | |
mimi3 | 10:b48d3ace55db | 258 | |
mimi3 | 10:b48d3ace55db | 259 | /*--------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 260 | /* Additional user defined functions */ |
mimi3 | 10:b48d3ace55db | 261 | |
mimi3 | 10:b48d3ace55db | 262 | /* RTC function */ |
mimi3 | 10:b48d3ace55db | 263 | #if !_FS_READONLY && !_FS_NORTC |
mimi3 | 10:b48d3ace55db | 264 | DWORD get_fattime (void); |
mimi3 | 10:b48d3ace55db | 265 | #endif |
mimi3 | 10:b48d3ace55db | 266 | |
mimi3 | 10:b48d3ace55db | 267 | /* Unicode support functions */ |
mimi3 | 10:b48d3ace55db | 268 | #if _USE_LFN /* Unicode - OEM code conversion */ |
mimi3 | 10:b48d3ace55db | 269 | WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ |
mimi3 | 10:b48d3ace55db | 270 | WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ |
mimi3 | 10:b48d3ace55db | 271 | #if _USE_LFN == 3 /* Memory functions */ |
mimi3 | 10:b48d3ace55db | 272 | void* ff_memalloc (UINT msize); /* Allocate memory block */ |
mimi3 | 10:b48d3ace55db | 273 | void ff_memfree (void* mblock); /* Free memory block */ |
mimi3 | 10:b48d3ace55db | 274 | #endif |
mimi3 | 10:b48d3ace55db | 275 | #endif |
mimi3 | 10:b48d3ace55db | 276 | |
mimi3 | 10:b48d3ace55db | 277 | /* Sync functions */ |
mimi3 | 10:b48d3ace55db | 278 | #if _FS_REENTRANT |
mimi3 | 10:b48d3ace55db | 279 | int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */ |
mimi3 | 10:b48d3ace55db | 280 | int ff_req_grant (_SYNC_t sobj); /* Lock sync object */ |
mimi3 | 10:b48d3ace55db | 281 | void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */ |
mimi3 | 10:b48d3ace55db | 282 | int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */ |
mimi3 | 10:b48d3ace55db | 283 | #endif |
mimi3 | 10:b48d3ace55db | 284 | |
mimi3 | 10:b48d3ace55db | 285 | |
mimi3 | 10:b48d3ace55db | 286 | |
mimi3 | 10:b48d3ace55db | 287 | |
mimi3 | 10:b48d3ace55db | 288 | /*--------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 289 | /* Flags and offset address */ |
mimi3 | 10:b48d3ace55db | 290 | |
mimi3 | 10:b48d3ace55db | 291 | |
mimi3 | 10:b48d3ace55db | 292 | /* File access control and file status flags (FIL.flag) */ |
mimi3 | 10:b48d3ace55db | 293 | |
mimi3 | 10:b48d3ace55db | 294 | #define FA_READ 0x01 |
mimi3 | 10:b48d3ace55db | 295 | #define FA_OPEN_EXISTING 0x00 |
mimi3 | 10:b48d3ace55db | 296 | |
mimi3 | 10:b48d3ace55db | 297 | #if !_FS_READONLY |
mimi3 | 10:b48d3ace55db | 298 | #define FA_WRITE 0x02 |
mimi3 | 10:b48d3ace55db | 299 | #define FA_CREATE_NEW 0x04 |
mimi3 | 10:b48d3ace55db | 300 | #define FA_CREATE_ALWAYS 0x08 |
mimi3 | 10:b48d3ace55db | 301 | #define FA_OPEN_ALWAYS 0x10 |
mimi3 | 10:b48d3ace55db | 302 | #define FA__WRITTEN 0x20 |
mimi3 | 10:b48d3ace55db | 303 | #define FA__DIRTY 0x40 |
mimi3 | 10:b48d3ace55db | 304 | #endif |
mimi3 | 10:b48d3ace55db | 305 | |
mimi3 | 10:b48d3ace55db | 306 | |
mimi3 | 10:b48d3ace55db | 307 | /* FAT sub type (FATFS.fs_type) */ |
mimi3 | 10:b48d3ace55db | 308 | |
mimi3 | 10:b48d3ace55db | 309 | #define FS_FAT12 1 |
mimi3 | 10:b48d3ace55db | 310 | #define FS_FAT16 2 |
mimi3 | 10:b48d3ace55db | 311 | #define FS_FAT32 3 |
mimi3 | 10:b48d3ace55db | 312 | |
mimi3 | 10:b48d3ace55db | 313 | |
mimi3 | 10:b48d3ace55db | 314 | /* File attribute bits for directory entry */ |
mimi3 | 10:b48d3ace55db | 315 | |
mimi3 | 10:b48d3ace55db | 316 | #define AM_RDO 0x01 /* Read only */ |
mimi3 | 10:b48d3ace55db | 317 | #define AM_HID 0x02 /* Hidden */ |
mimi3 | 10:b48d3ace55db | 318 | #define AM_SYS 0x04 /* System */ |
mimi3 | 10:b48d3ace55db | 319 | #define AM_VOL 0x08 /* Volume label */ |
mimi3 | 10:b48d3ace55db | 320 | #define AM_LFN 0x0F /* LFN entry */ |
mimi3 | 10:b48d3ace55db | 321 | #define AM_DIR 0x10 /* Directory */ |
mimi3 | 10:b48d3ace55db | 322 | #define AM_ARC 0x20 /* Archive */ |
mimi3 | 10:b48d3ace55db | 323 | #define AM_MASK 0x3F /* Mask of defined bits */ |
mimi3 | 10:b48d3ace55db | 324 | |
mimi3 | 10:b48d3ace55db | 325 | |
mimi3 | 10:b48d3ace55db | 326 | /* Fast seek feature */ |
mimi3 | 10:b48d3ace55db | 327 | #define CREATE_LINKMAP 0xFFFFFFFF |
mimi3 | 10:b48d3ace55db | 328 | |
mimi3 | 10:b48d3ace55db | 329 | |
mimi3 | 10:b48d3ace55db | 330 | |
mimi3 | 10:b48d3ace55db | 331 | /*--------------------------------*/ |
mimi3 | 10:b48d3ace55db | 332 | /* Multi-byte word access macros */ |
mimi3 | 10:b48d3ace55db | 333 | |
mimi3 | 10:b48d3ace55db | 334 | #if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ |
mimi3 | 10:b48d3ace55db | 335 | #define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) |
mimi3 | 10:b48d3ace55db | 336 | #define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) |
mimi3 | 10:b48d3ace55db | 337 | #define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) |
mimi3 | 10:b48d3ace55db | 338 | #define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) |
mimi3 | 10:b48d3ace55db | 339 | #else /* Use byte-by-byte access to the FAT structure */ |
mimi3 | 10:b48d3ace55db | 340 | #define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) |
mimi3 | 10:b48d3ace55db | 341 | #define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) |
mimi3 | 10:b48d3ace55db | 342 | #define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) |
mimi3 | 10:b48d3ace55db | 343 | #define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) |
mimi3 | 10:b48d3ace55db | 344 | #endif |
mimi3 | 10:b48d3ace55db | 345 | |
mimi3 | 10:b48d3ace55db | 346 | #ifdef __cplusplus |
mimi3 | 10:b48d3ace55db | 347 | } |
mimi3 | 10:b48d3ace55db | 348 | #endif |
mimi3 | 10:b48d3ace55db | 349 | |
mimi3 | 10:b48d3ace55db | 350 | #endif /* _FATFS */ |