BeRTOS
ff.h
00001 /*---------------------------------------------------------------------------/
00002 /  FatFs - FAT file system module include file  R0.07a       (C)ChaN, 2009
00003 /----------------------------------------------------------------------------/
00004 / FatFs module is an open source software to implement FAT file system to
00005 / small embedded systems. This is a free software and is opened for education,
00006 / research and commercial developments under license policy of following trems.
00007 /
00008 /  Copyright (C) 2009, ChaN, all right reserved.
00009 /
00010 / * The FatFs module is a free software and there is NO WARRANTY.
00011 / * No restriction on use. You can use, modify and redistribute it for
00012 /   personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY.
00013 / * Redistributions of source code must retain the above copyright notice.
00014 /----------------------------------------------------------------------------*/
00015 
00016 /*---------------------------------------------------------------------------/
00017 / FatFs Configuration Options
00018 /
00019 / CAUTION! Do not forget to make clean the project after any changes to
00020 / the configuration options.
00021 /
00022 /----------------------------------------------------------------------------*/
00023 #ifndef _FATFS
00024 #define _FATFS
00025 
00026 #include "integer.h"
00027 #include "cfg/cfg_fat.h"
00028 
00029 #ifndef _WORD_ACCESS
00030 #define _WORD_ACCESS    0
00031 #endif
00032 /* The _WORD_ACCESS option defines which access method is used to the word
00033 /  data in the FAT structure.
00034 /
00035 /   0: Byte-by-byte access. Always compatible with all platforms.
00036 /   1: Word access. Do not choose this unless following condition is met.
00037 /
00038 /  When the byte order on the memory is big-endian or address miss-aligned
00039 /  word access results incorrect behavior, the _WORD_ACCESS must be set to 0.
00040 /  If it is not the case, the value can also be set to 1 to improve the
00041 /  performance and code efficiency. */
00042 
00043 #ifndef _FS_READONLY
00044 #define _FS_READONLY    0
00045 #endif
00046 /* Setting _FS_READONLY to 1 defines read only configuration. This removes
00047 /  writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
00048 /  f_truncate and useless f_getfree. */
00049 
00050 #ifndef _FS_MINIMIZE
00051 #define _FS_MINIMIZE    0
00052 #endif
00053 /* The _FS_MINIMIZE option defines minimization level to remove some functions.
00054 /
00055 /   0: Full function.
00056 /   1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename
00057 /      are removed.
00058 /   2: f_opendir and f_readdir are removed in addition to level 1.
00059 /   3: f_lseek is removed in addition to level 2. */
00060 
00061 #ifndef _FS_TINY
00062 #define _FS_TINY    0
00063 #endif
00064 /* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system
00065 /  object instead of the sector buffer in the individual file object for file
00066 /  data transfer. This reduces memory consumption 512 bytes each file object. */
00067 
00068 #ifndef _USE_STRFUNC
00069 #define _USE_STRFUNC    0
00070 #endif
00071 /* To enable string functions, set _USE_STRFUNC to 1 or 2. */
00072 
00073 #ifndef _USE_MKFS
00074 #define _USE_MKFS   0
00075 #endif
00076 /* To enable f_mkfs function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
00077 
00078 
00079 #ifndef _USE_FORWARD
00080 #define _USE_FORWARD    0
00081 #endif
00082 /* To enable f_forward function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */
00083 
00084 
00085 #ifndef _DRIVES
00086 #define _DRIVES     1
00087 #endif
00088 /* Number of volumes (logical drives) to be used. */
00089 
00090 #ifndef _MAX_SS
00091 #define _MAX_SS 512
00092 #endif
00093 /* Maximum sector size to be handled. (512/1024/2048/4096) */
00094 /* 512 for memroy card and hard disk, 1024 for floppy disk, 2048 for MO disk */
00095 
00096 #ifndef _MULTI_PARTITION
00097 #define _MULTI_PARTITION    0
00098 #endif
00099 /* When _MULTI_PARTITION is set to 0, each volume is bound to the same physical
00100 / drive number and can mount only first primaly partition. When it is set to 1,
00101 / each volume is tied to the partitions listed in Drives[]. */
00102 
00103 #ifndef _CODE_PAGE
00104 #define _CODE_PAGE  932
00105 #endif
00106 /* The _CODE_PAGE specifies the OEM code page to be used on the target system.
00107 /  When it is non LFN configuration, there is no difference between SBCS code
00108 /  pages. When LFN is enabled, the code page must always be set correctly.
00109 /   437 - U.S.
00110 /   720 - Arabic
00111 /   737 - Greek
00112 /   775 - Baltic
00113 /   850 - Multilingual Latin 1
00114 /   852 - Latin 2
00115 /   855 - Cyrillic
00116 /   857 - Turkish
00117 /   858 - Multilingual Latin 1 + Euro
00118 /   862 - Hebrew
00119 /   866 - Russian
00120 /   874 - Thai
00121 /   932 - Japanese Shift-JIS       (DBCS)
00122 /   936 - Simplified Chinese GBK   (DBCS)
00123 /   949 - Korean                   (DBCS)
00124 /   950 - Traditional Chinese Big5 (DBCS)
00125 /   1258 - Vietnam
00126 */
00127 
00128 #ifndef _USE_LFN
00129 #define _USE_LFN    0
00130 #endif
00131 #ifndef _MAX_LFN
00132 #define _MAX_LFN    255     /* Maximum LFN length to handle (max:255) */
00133 #endif
00134 /* The _USE_LFN option switches the LFN support.
00135 /
00136 /   0: Disable LFN.
00137 /   1: Enable LFN with static working buffer on the bss. NOT REENTRANT.
00138 /   2: Enable LFN with dynamic working buffer on the caller's STACK.
00139 /
00140 /  The working buffer occupies (_MAX_LFN + 1) * 2 bytes. When enable LFN,
00141 /  a Unicode - OEM code conversion function ff_convert() must be added to
00142 /  the project. */
00143 
00144 #ifndef _FS_REENTRANT
00145 #define _FS_REENTRANT   0
00146 #endif
00147 #ifndef _TIMEOUT
00148 #define _TIMEOUT        1000    /* Timeout period in unit of time ticks */
00149 #endif
00150 #ifndef _SYNC_t
00151 #define _SYNC_t         HANDLE  /* Type of sync object used on the OS. */
00152                                 /* e.g. HANDLE, OS_EVENT*, ID and etc.. */
00153 #endif
00154 /* To make the FatFs module re-entrant, set _FS_REENTRANT to 1 and add user
00155 /  provided synchronization handlers, ff_req_grant, ff_rel_grant,
00156 /  ff_del_syncobj and ff_cre_syncobj function to the project. */
00157 
00158 
00159 
00160 /* End of configuration options. Do not change followings without care.     */
00161 /*--------------------------------------------------------------------------*/
00162 
00163 
00164 
00165 /* Definitions corresponds to multiple sector size */
00166 
00167 #if _MAX_SS == 512
00168 #define SS(fs)  512
00169 #else
00170 #if _MAX_SS == 1024 || _MAX_SS == 2048 || _MAX_SS == 4096
00171 #define SS(fs)  ((fs)->s_size)
00172 #else
00173 #error Sector size must be 512, 1024, 2048 or 4096.
00174 #endif
00175 #endif
00176 
00177 
00178 
00179 /* File system object structure */
00180 
00181 typedef struct _FATFS {
00182     BYTE    fs_type;    /* FAT sub type */
00183     BYTE    drive;      /* Physical drive number */
00184     BYTE    csize;      /* Number of sectors per cluster */
00185     BYTE    n_fats;     /* Number of FAT copies */
00186     BYTE    wflag;      /* win[] dirty flag (1:must be written back) */
00187     BYTE    pad1;
00188     WORD    id;         /* File system mount ID */
00189     WORD    n_rootdir;  /* Number of root directory entries (0 on FAT32) */
00190 #if _FS_REENTRANT
00191     _SYNC_t sobj;       /* Identifier of sync object */
00192 #endif
00193 #if _MAX_SS != 512U
00194     WORD    s_size;     /* Sector size */
00195 #endif
00196 #if !_FS_READONLY
00197     BYTE    fsi_flag;   /* fsinfo dirty flag (1:must be written back) */
00198     BYTE    pad2;
00199     DWORD   last_clust; /* Last allocated cluster */
00200     DWORD   free_clust; /* Number of free clusters */
00201     DWORD   fsi_sector; /* fsinfo sector */
00202 #endif
00203     DWORD   sects_fat;  /* Sectors per fat */
00204     DWORD   max_clust;  /* Maximum cluster# + 1. Number of clusters is max_clust - 2 */
00205     DWORD   fatbase;    /* FAT start sector */
00206     DWORD   dirbase;    /* Root directory start sector (Cluster# on FAT32) */
00207     DWORD   database;   /* Data start sector */
00208     DWORD   winsect;    /* Current sector appearing in the win[] */
00209     BYTE    win[_MAX_SS];/* Disk access window for Directory/FAT */
00210 } FATFS;
00211 
00212 
00213 
00214 /* Directory object structure */
00215 
00216 typedef struct _DIR {
00217     WORD    id;         /* Owner file system mount ID */
00218     WORD    index;      /* Current index number */
00219     FATFS*  fs;         /* Pointer to the owner file system object */
00220     DWORD   sclust;     /* Table start cluster (0:Static table) */
00221     DWORD   clust;      /* Current cluster */
00222     DWORD   sect;       /* Current sector */
00223     BYTE*   dir;        /* Pointer to the current SFN entry in the win[] */
00224     BYTE*   fn;         /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
00225 #if _USE_LFN
00226     WCHAR*  lfn;        /* Pointer to the LFN working buffer */
00227     WORD    lfn_idx;    /* Last matched LFN index (0xFFFF:No LFN) */
00228 #endif
00229 } DIR;
00230 
00231 
00232 
00233 /* File object structure */
00234 
00235 typedef struct _FIL {
00236     FATFS*  fs;         /* Pointer to the owner file system object */
00237     WORD    id;         /* Owner file system mount ID */
00238     BYTE    flag;       /* File status flags */
00239     BYTE    csect;      /* Sector address in the cluster */
00240     DWORD   fptr;       /* File R/W pointer */
00241     DWORD   fsize;      /* File size */
00242     DWORD   org_clust;  /* File start cluster */
00243     DWORD   curr_clust; /* Current cluster */
00244     DWORD   dsect;      /* Current data sector */
00245 #if !_FS_READONLY
00246     DWORD   dir_sect;   /* Sector containing the directory entry */
00247     BYTE*   dir_ptr;    /* Ponter to the directory entry in the window */
00248 #endif
00249 #if !_FS_TINY
00250     BYTE    buf[_MAX_SS];/* File R/W buffer */
00251 #endif
00252 } FIL;
00253 
00254 
00255 
00256 /* File status structure */
00257 
00258 typedef struct _FILINFO {
00259     DWORD fsize;        /* File size */
00260     WORD fdate;         /* Last modified date */
00261     WORD ftime;         /* Last modified time */
00262     BYTE fattrib;       /* Attribute */
00263     char fname[13];     /* Short file name (8.3 format) */
00264 #if _USE_LFN
00265     char *lfname;       /* Pointer to the LFN buffer */
00266     int lfsize;         /* Size of LFN buffer [bytes] */
00267 #endif
00268 } FILINFO;
00269 
00270 
00271 
00272 /* DBCS code ranges */
00273 
00274 #if _CODE_PAGE == 932   /* CP932 (Japanese Shift-JIS) */
00275 #define _DF1S   0x81    /* DBC 1st byte range 1 start */
00276 #define _DF1E   0x9F    /* DBC 1st byte range 1 end */
00277 #define _DF2S   0xE0    /* DBC 1st byte range 2 start */
00278 #define _DF2E   0xFC    /* DBC 1st byte range 2 end */
00279 #define _DS1S   0x40    /* DBC 2nd byte range 1 start */
00280 #define _DS1E   0x7E    /* DBC 2nd byte range 1 end */
00281 #define _DS2S   0x80    /* DBC 2nd byte range 2 start */
00282 #define _DS2E   0xFC    /* DBC 2nd byte range 2 end */
00283 
00284 #elif _CODE_PAGE == 936 /* CP936 (Simplified Chinese GBK) */
00285 #define _DF1S   0x81
00286 #define _DF1E   0xFE
00287 #define _DS1S   0x40
00288 #define _DS1E   0x7E
00289 #define _DS2S   0x80
00290 #define _DS2E   0xFE
00291 
00292 #elif _CODE_PAGE == 949 /* CP949 (Korean) */
00293 #define _DF1S   0x81
00294 #define _DF1E   0xFE
00295 #define _DS1S   0x41
00296 #define _DS1E   0x5A
00297 #define _DS2S   0x61
00298 #define _DS2E   0x7A
00299 #define _DS3S   0x81
00300 #define _DS3E   0xFE
00301 
00302 #elif _CODE_PAGE == 950 /* CP950 (Traditional Chinese Big5) */
00303 #define _DF1S   0x81
00304 #define _DF1E   0xFE
00305 #define _DS1S   0x40
00306 #define _DS1E   0x7E
00307 #define _DS2S   0xA1
00308 #define _DS2E   0xFE
00309 
00310 #else                   /* SBCS code pages */
00311 #define _DF1S   0
00312 
00313 #endif
00314 
00315 
00316 
00317 /* Character code support macros */
00318 
00319 #define IsUpper(c)  (((c)>='A')&&((c)<='Z'))
00320 #define IsLower(c)  (((c)>='a')&&((c)<='z'))
00321 #define IsDigit(c)  (((c)>='0')&&((c)<='9'))
00322 
00323 #if _DF1S   /* DBCS configuration */
00324 
00325 #if _DF2S   /* Two 1st byte areas */
00326 #define IsDBCS1(c)  (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E))
00327 #else       /* One 1st byte area */
00328 #define IsDBCS1(c)  ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E)
00329 #endif
00330 
00331 #if _DS3S   /* Three 2nd byte areas */
00332 #define IsDBCS2(c)  (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E))
00333 #else       /* Two 2nd byte areas */
00334 #define IsDBCS2(c)  (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E))
00335 #endif
00336 
00337 #else       /* SBCS configuration */
00338 
00339 #define IsDBCS1(c)  0
00340 #define IsDBCS2(c)  0
00341 
00342 #endif /* _DF1S */
00343 
00344 
00345 
00346 /* Definitions corresponds to multi partition */
00347 
00348 #if _MULTI_PARTITION        /* Multiple partition configuration */
00349 
00350 typedef struct _PARTITION {
00351     BYTE pd;    /* Physical drive# */
00352     BYTE pt;    /* Partition # (0-3) */
00353 } PARTITION;
00354 
00355 extern
00356 const PARTITION Drives[];           /* Logical drive# to physical location conversion table */
00357 #define LD2PD(drv) (Drives[drv].pd) /* Get physical drive# */
00358 #define LD2PT(drv) (Drives[drv].pt) /* Get partition# */
00359 
00360 #else                       /* Single partition configuration */
00361 
00362 #define LD2PD(drv) (drv)    /* Physical drive# is equal to the logical drive# */
00363 #define LD2PT(drv) 0        /* Always mounts the 1st partition */
00364 
00365 #endif
00366 
00367 
00368 
00369 /* File function return code (FRESULT) */
00370 
00371 typedef enum {
00372     FR_OK = 0,          /* 0 */
00373     FR_DISK_ERR,        /* 1 */
00374     FR_INT_ERR,         /* 2 */
00375     FR_NOT_READY,       /* 3 */
00376     FR_NO_FILE,         /* 4 */
00377     FR_NO_PATH,         /* 5 */
00378     FR_INVALID_NAME,    /* 6 */
00379     FR_DENIED,          /* 7 */
00380     FR_EXIST,           /* 8 */
00381     FR_INVALID_OBJECT,  /* 9 */
00382     FR_WRITE_PROTECTED, /* 10 */
00383     FR_INVALID_DRIVE,   /* 11 */
00384     FR_NOT_ENABLED,     /* 12 */
00385     FR_NO_FILESYSTEM,   /* 13 */
00386     FR_MKFS_ABORTED,    /* 14 */
00387     FR_TIMEOUT          /* 15 */
00388 } FRESULT;
00389 
00390 
00391 
00392 /*--------------------------------------------------------------*/
00393 /* FatFs module application interface                           */
00394 
00395 FRESULT f_mount (BYTE, FATFS*);                     /* Mount/Unmount a logical drive */
00396 FRESULT f_open (FIL*, const char*, BYTE);           /* Open or create a file */
00397 FRESULT f_read (FIL*, void*, UINT, UINT*);          /* Read data from a file */
00398 FRESULT f_write (FIL*, const void*, UINT, UINT*);   /* Write data to a file */
00399 FRESULT f_lseek (FIL*, DWORD);                      /* Move file pointer of a file object */
00400 FRESULT f_close (FIL*);                             /* Close an open file object */
00401 FRESULT f_opendir (DIR*, const char*);              /* Open an existing directory */
00402 FRESULT f_readdir (DIR*, FILINFO*);                 /* Read a directory item */
00403 FRESULT f_stat (const char*, FILINFO*);             /* Get file status */
00404 FRESULT f_getfree (const char*, DWORD*, FATFS**);   /* Get number of free clusters on the drive */
00405 FRESULT f_truncate (FIL*);                          /* Truncate file */
00406 FRESULT f_sync (FIL*);                              /* Flush cached data of a writing file */
00407 FRESULT f_unlink (const char*);                     /* Delete an existing file or directory */
00408 FRESULT f_mkdir (const char*);                      /* Create a new directory */
00409 FRESULT f_chmod (const char*, BYTE, BYTE);          /* Change attriburte of the file/dir */
00410 FRESULT f_utime (const char*, const FILINFO*);      /* Change timestamp of the file/dir */
00411 FRESULT f_rename (const char*, const char*);        /* Rename/Move a file or directory */
00412 FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*);   /* Forward data to the stream */
00413 FRESULT f_mkfs (BYTE, BYTE, WORD);                  /* Create a file system on the drive */
00414 
00415 #if _USE_STRFUNC
00416 int f_putc (int, FIL*);                             /* Put a character to the file */
00417 int f_puts (const char*, FIL*);                     /* Put a string to the file */
00418 int f_printf (FIL*, const char*, ...);              /* Put a formatted string to the file */
00419 char* f_gets (char*, int, FIL*);                    /* Get a string from the file */
00420 #define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
00421 #define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
00422 #ifndef EOF
00423 #define EOF -1
00424 #endif
00425 #endif
00426 
00427 
00428 
00429 /*--------------------------------------------------------------*/
00430 /* User defined functions                                       */
00431 
00432 /* Real time clock */
00433 #if !_FS_READONLY
00434 DWORD get_fattime (void);   /* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */
00435                             /* 15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */
00436 #endif
00437 
00438 /* Unicode - OEM code conversion */
00439 #if _USE_LFN
00440 WCHAR ff_convert (WCHAR, UINT);
00441 #endif
00442 
00443 /* Sync functions */
00444 #if _FS_REENTRANT
00445 BOOL ff_cre_syncobj(BYTE, _SYNC_t*);
00446 BOOL ff_del_syncobj(_SYNC_t);
00447 BOOL ff_req_grant(_SYNC_t);
00448 void ff_rel_grant(_SYNC_t);
00449 #endif
00450 
00451 
00452 
00453 /*--------------------------------------------------------------*/
00454 /* Flags and offset address                                     */
00455 
00456 
00457 /* File access control and file status flags (FIL.flag) */
00458 
00459 #define FA_READ             0x01
00460 #define FA_OPEN_EXISTING    0x00
00461 #if _FS_READONLY == 0
00462 #define FA_WRITE            0x02
00463 #define FA_CREATE_NEW       0x04
00464 #define FA_CREATE_ALWAYS    0x08
00465 #define FA_OPEN_ALWAYS      0x10
00466 #define FA__WRITTEN         0x20
00467 #define FA__DIRTY           0x40
00468 #endif
00469 #define FA__ERROR           0x80
00470 
00471 
00472 /* FAT sub type (FATFS.fs_type) */
00473 
00474 #define FS_FAT12    1
00475 #define FS_FAT16    2
00476 #define FS_FAT32    3
00477 
00478 
00479 /* File attribute bits for directory entry */
00480 
00481 #define AM_RDO  0x01    /* Read only */
00482 #define AM_HID  0x02    /* Hidden */
00483 #define AM_SYS  0x04    /* System */
00484 #define AM_VOL  0x08    /* Volume label */
00485 #define AM_LFN  0x0F    /* LFN entry */
00486 #define AM_DIR  0x10    /* Directory */
00487 #define AM_ARC  0x20    /* Archive */
00488 #define AM_MASK 0x3F    /* Mask of defined bits */
00489 
00490 
00491 /* FatFs refers the members in the FAT structures with byte offset instead
00492 / of structure member because there are incompatibility of the packing option
00493 / between various compilers. */
00494 
00495 #define BS_jmpBoot          0
00496 #define BS_OEMName          3
00497 #define BPB_BytsPerSec      11
00498 #define BPB_SecPerClus      13
00499 #define BPB_RsvdSecCnt      14
00500 #define BPB_NumFATs         16
00501 #define BPB_RootEntCnt      17
00502 #define BPB_TotSec16        19
00503 #define BPB_Media           21
00504 #define BPB_FATSz16         22
00505 #define BPB_SecPerTrk       24
00506 #define BPB_NumHeads        26
00507 #define BPB_HiddSec         28
00508 #define BPB_TotSec32        32
00509 #define BS_55AA             510
00510 
00511 #define BS_DrvNum           36
00512 #define BS_BootSig          38
00513 #define BS_VolID            39
00514 #define BS_VolLab           43
00515 #define BS_FilSysType       54
00516 
00517 #define BPB_FATSz32         36
00518 #define BPB_ExtFlags        40
00519 #define BPB_FSVer           42
00520 #define BPB_RootClus        44
00521 #define BPB_FSInfo          48
00522 #define BPB_BkBootSec       50
00523 #define BS_DrvNum32         64
00524 #define BS_BootSig32        66
00525 #define BS_VolID32          67
00526 #define BS_VolLab32         71
00527 #define BS_FilSysType32     82
00528 
00529 #define FSI_LeadSig         0
00530 #define FSI_StrucSig        484
00531 #define FSI_Free_Count      488
00532 #define FSI_Nxt_Free        492
00533 
00534 #define MBR_Table           446
00535 
00536 #define DIR_Name            0
00537 #define DIR_Attr            11
00538 #define DIR_NTres           12
00539 #define DIR_CrtTime         14
00540 #define DIR_CrtDate         16
00541 #define DIR_FstClusHI       20
00542 #define DIR_WrtTime         22
00543 #define DIR_WrtDate         24
00544 #define DIR_FstClusLO       26
00545 #define DIR_FileSize        28
00546 #define LDIR_Ord            0
00547 #define LDIR_Attr           11
00548 #define LDIR_Type           12
00549 #define LDIR_Chksum         13
00550 #define LDIR_FstClusLO      26
00551 
00552 
00553 
00554 /*--------------------------------*/
00555 /* Multi-byte word access macros  */
00556 
00557 #if _WORD_ACCESS == 1   /* Enable word access to the FAT structure */
00558 #define LD_WORD(ptr)        (WORD)(*(WORD*)(BYTE*)(ptr))
00559 #define LD_DWORD(ptr)       (DWORD)(*(DWORD*)(BYTE*)(ptr))
00560 #define ST_WORD(ptr,val)    *(WORD*)(BYTE*)(ptr)=(WORD)(val)
00561 #define ST_DWORD(ptr,val)   *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
00562 #else                   /* Use byte-by-byte access to the FAT structure */
00563 #define LD_WORD(ptr)        (WORD)(((WORD)*(BYTE*)((ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
00564 #define LD_DWORD(ptr)       (DWORD)(((DWORD)*(BYTE*)((ptr)+3)<<24)|((DWORD)*(BYTE*)((ptr)+2)<<16)|((WORD)*(BYTE*)((ptr)+1)<<8)|*(BYTE*)(ptr))
00565 #define ST_WORD(ptr,val)    *(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)
00566 #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)
00567 #endif
00568 
00569 
00570 #endif /* _FATFS */