This is code is part of a Technion course project in advanced IoT, implementing a device to read and transmit sensors data from a Formula racing car built by students at Technion - Israel Institute of Technology.

Dependencies:   mbed Buffer

Fork of DISCO-L072CZ-LRWAN1_LoRa_PingPong by ST

This is code is part of a Technion course project in advanced IoT, implementing a device to read and transmit sensors data from a Formula racing car built by students at Technion - Israel Institute of Technology.

How to install

  • Create an account on Mbed: https://os.mbed.com/account/signup/
  • Import project into Compiler
  • In the Program Workspace select "Formula_Nucleo_Reader"
  • Select a Platform like so:
  1. Click button at top-left
  2. Add Board
  3. Search "B-L072Z-LRWAN1" and then "Add to your Mbed Compiler"
  • Finally click "Compile", if the build was successful, the binary would download automatically
  • To install it on device simply plug it in to a PC, open device drive and drag then drop binary file in it
Committer:
wardm
Date:
Sat May 19 11:41:10 2018 +0000
Revision:
12:02d779e8c4f6
Code for Technion Formula car sensors reader transmit

Who changed what in which revision?

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