replaced "integer.h" with stdint.h
This commit is contained in:
@@ -16,7 +16,7 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
/* Status of Disk Functions */
|
/* Status of Disk Functions */
|
||||||
typedef BYTE DSTATUS;
|
typedef uint8_t DSTATUS;
|
||||||
|
|
||||||
/* Results of Disk Functions */
|
/* Results of Disk Functions */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -32,13 +32,13 @@ typedef enum {
|
|||||||
/* Prototypes for disk control functions */
|
/* Prototypes for disk control functions */
|
||||||
|
|
||||||
|
|
||||||
DSTATUS disk_initialize (BYTE);
|
DSTATUS disk_initialize (uint8_t);
|
||||||
DSTATUS disk_status (BYTE);
|
DSTATUS disk_status (uint8_t);
|
||||||
DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
|
DRESULT disk_read (uint8_t, uint8_t*, uint32_t, uint8_t);
|
||||||
#if _READONLY == 0
|
#if _READONLY == 0
|
||||||
DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
|
DRESULT disk_write (uint8_t, const uint8_t*, uint32_t, uint8_t);
|
||||||
#endif
|
#endif
|
||||||
DRESULT disk_ioctl (BYTE, BYTE, void*);
|
DRESULT disk_ioctl (uint8_t, uint8_t, void*);
|
||||||
|
|
||||||
|
|
||||||
/* Disk Status Bits (DSTATUS) */
|
/* Disk Status Bits (DSTATUS) */
|
||||||
|
|||||||
@@ -34,15 +34,15 @@ extern "C" {
|
|||||||
|
|
||||||
#if _MULTI_PARTITION /* Multiple partition configuration */
|
#if _MULTI_PARTITION /* Multiple partition configuration */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
BYTE pd; /* Physical drive number */
|
uint8_t pd; /* Physical drive number */
|
||||||
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
uint8_t pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
||||||
} PARTITION;
|
} PARTITION;
|
||||||
extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
||||||
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */
|
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */
|
||||||
#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */
|
#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */
|
||||||
|
|
||||||
#else /* Single partition configuration */
|
#else /* Single partition configuration */
|
||||||
#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */
|
#define LD2PD(vol) (uint8_t)(vol) /* Each logical drive is bound to the same physical drive number */
|
||||||
#define LD2PT(vol) 0 /* Always mounts the 1st partition or in SFD */
|
#define LD2PT(vol) 0 /* Always mounts the 1st partition or in SFD */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -56,7 +56,7 @@ extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
|||||||
#error _LFN_UNICODE must be 0 in non-LFN cfg.
|
#error _LFN_UNICODE must be 0 in non-LFN cfg.
|
||||||
#endif
|
#endif
|
||||||
#ifndef _INC_TCHAR
|
#ifndef _INC_TCHAR
|
||||||
typedef WCHAR TCHAR;
|
typedef uint16_t TCHAR;
|
||||||
#define _T(x) L ## x
|
#define _T(x) L ## x
|
||||||
#define _TEXT(x) L ## x
|
#define _TEXT(x) L ## x
|
||||||
#endif
|
#endif
|
||||||
@@ -75,35 +75,35 @@ typedef char TCHAR;
|
|||||||
/* File system object structure (FATFS) */
|
/* File system object structure (FATFS) */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
|
uint8_t fs_type; /* FAT sub-type (0:Not mounted) */
|
||||||
BYTE drv; /* Physical drive number */
|
uint8_t drv; /* Physical drive number */
|
||||||
BYTE csize; /* Sectors per cluster (1,2,4...128) */
|
uint8_t csize; /* Sectors per cluster (1,2,4...128) */
|
||||||
BYTE n_fats; /* Number of FAT copies (1,2) */
|
uint8_t n_fats; /* Number of FAT copies (1,2) */
|
||||||
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
uint8_t wflag; /* win[] dirty flag (1:must be written back) */
|
||||||
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
uint8_t fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
||||||
WORD id; /* File system mount ID */
|
uint16_t id; /* File system mount ID */
|
||||||
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
uint16_t n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||||
#if _MAX_SS != 512
|
#if _MAX_SS != 512
|
||||||
WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
|
uint16_t ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
|
||||||
#endif
|
#endif
|
||||||
#if _FS_REENTRANT
|
#if _FS_REENTRANT
|
||||||
_SYNC_t sobj; /* Identifier of sync object */
|
_SYNC_t sobj; /* Identifier of sync object */
|
||||||
#endif
|
#endif
|
||||||
#if !_FS_READONLY
|
#if !_FS_READONLY
|
||||||
DWORD last_clust; /* Last allocated cluster */
|
uint32_t last_clust; /* Last allocated cluster */
|
||||||
DWORD free_clust; /* Number of free clusters */
|
uint32_t free_clust; /* Number of free clusters */
|
||||||
DWORD fsi_sector; /* fsinfo sector (FAT32) */
|
uint32_t fsi_sector; /* fsinfo sector (FAT32) */
|
||||||
#endif
|
#endif
|
||||||
#if _FS_RPATH
|
#if _FS_RPATH
|
||||||
DWORD cdir; /* Current directory start cluster (0:root) */
|
uint32_t cdir; /* Current directory start cluster (0:root) */
|
||||||
#endif
|
#endif
|
||||||
DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */
|
uint32_t n_fatent; /* Number of FAT entries (= number of clusters + 2) */
|
||||||
DWORD fsize; /* Sectors per FAT */
|
uint32_t fsize; /* Sectors per FAT */
|
||||||
DWORD fatbase; /* FAT start sector */
|
uint32_t fatbase; /* FAT start sector */
|
||||||
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
|
uint32_t dirbase; /* Root directory start sector (FAT32:Cluster#) */
|
||||||
DWORD database; /* Data start sector */
|
uint32_t database; /* Data start sector */
|
||||||
DWORD winsect; /* Current sector appearing in the win[] */
|
uint32_t winsect; /* Current sector appearing in the win[] */
|
||||||
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and Data on tiny cfg) */
|
uint8_t win[_MAX_SS]; /* Disk access window for Directory, FAT (and Data on tiny cfg) */
|
||||||
} FATFS;
|
} FATFS;
|
||||||
|
|
||||||
|
|
||||||
@@ -112,26 +112,26 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FATFS* fs; /* Pointer to the related file system object */
|
FATFS* fs; /* Pointer to the related file system object */
|
||||||
WORD id; /* File system mount ID of the related file system object */
|
uint16_t id; /* File system mount ID of the related file system object */
|
||||||
BYTE flag; /* File status flags */
|
uint8_t flag; /* File status flags */
|
||||||
BYTE pad1;
|
uint8_t pad1;
|
||||||
DWORD fptr; /* File read/write pointer (0ed on file open) */
|
uint32_t fptr; /* File read/write pointer (0ed on file open) */
|
||||||
DWORD fsize; /* File size */
|
uint32_t fsize; /* File size */
|
||||||
DWORD sclust; /* File data start cluster (0:no data cluster, always 0 when fsize is 0) */
|
uint32_t sclust; /* File data start cluster (0:no data cluster, always 0 when fsize is 0) */
|
||||||
DWORD clust; /* Current cluster of fpter */
|
uint32_t clust; /* Current cluster of fpter */
|
||||||
DWORD dsect; /* Current data sector of fpter */
|
uint32_t dsect; /* Current data sector of fpter */
|
||||||
#if !_FS_READONLY
|
#if !_FS_READONLY
|
||||||
DWORD dir_sect; /* Sector containing the directory entry */
|
uint32_t dir_sect; /* Sector containing the directory entry */
|
||||||
BYTE* dir_ptr; /* Pointer to the directory entry in the window */
|
uint8_t* dir_ptr; /* Pointer to the directory entry in the window */
|
||||||
#endif
|
#endif
|
||||||
#if _USE_FASTSEEK
|
#if _USE_FASTSEEK
|
||||||
DWORD* cltbl; /* Pointer to the cluster link map table (null on file open) */
|
uint32_t* cltbl; /* Pointer to the cluster link map table (null on file open) */
|
||||||
#endif
|
#endif
|
||||||
#if _FS_LOCK
|
#if _FS_LOCK
|
||||||
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
|
uint32_t lockid; /* File lock ID (index of file semaphore table Files[]) */
|
||||||
#endif
|
#endif
|
||||||
#if !_FS_TINY
|
#if !_FS_TINY
|
||||||
BYTE buf[_MAX_SS]; /* File data read/write buffer */
|
uint8_t buf[_MAX_SS]; /* File data read/write buffer */
|
||||||
#endif
|
#endif
|
||||||
} FIL;
|
} FIL;
|
||||||
|
|
||||||
@@ -141,16 +141,16 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FATFS* fs; /* Pointer to the owner file system object */
|
FATFS* fs; /* Pointer to the owner file system object */
|
||||||
WORD id; /* Owner file system mount ID */
|
uint16_t id; /* Owner file system mount ID */
|
||||||
WORD index; /* Current read/write index number */
|
uint16_t index; /* Current read/write index number */
|
||||||
DWORD sclust; /* Table start cluster (0:Root dir) */
|
uint32_t sclust; /* Table start cluster (0:Root dir) */
|
||||||
DWORD clust; /* Current cluster */
|
uint32_t clust; /* Current cluster */
|
||||||
DWORD sect; /* Current sector */
|
uint32_t sect; /* Current sector */
|
||||||
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
uint8_t* dir; /* Pointer to the current SFN entry in the win[] */
|
||||||
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
uint8_t* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||||
#if _USE_LFN
|
#if _USE_LFN
|
||||||
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
uint16_t* lfn; /* Pointer to the LFN working buffer */
|
||||||
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
|
uint16_t lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
|
||||||
#endif
|
#endif
|
||||||
} DIR;
|
} DIR;
|
||||||
|
|
||||||
@@ -159,14 +159,14 @@ typedef struct {
|
|||||||
/* File status structure (FILINFO) */
|
/* File status structure (FILINFO) */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DWORD fsize; /* File size */
|
uint32_t fsize; /* File size */
|
||||||
WORD fdate; /* Last modified date */
|
uint16_t fdate; /* Last modified date */
|
||||||
WORD ftime; /* Last modified time */
|
uint16_t ftime; /* Last modified time */
|
||||||
BYTE fattrib; /* Attribute */
|
uint8_t fattrib; /* Attribute */
|
||||||
TCHAR fname[13]; /* Short file name (8.3 format) */
|
TCHAR fname[13]; /* Short file name (8.3 format) */
|
||||||
#if _USE_LFN
|
#if _USE_LFN
|
||||||
TCHAR* lfname; /* Pointer to the LFN buffer */
|
TCHAR* lfname; /* Pointer to the LFN buffer */
|
||||||
UINT lfsize; /* Size of LFN buffer in TCHAR */
|
uint32_t lfsize; /* Size of LFN buffer in TCHAR */
|
||||||
#endif
|
#endif
|
||||||
} FILINFO;
|
} FILINFO;
|
||||||
|
|
||||||
@@ -202,29 +202,29 @@ typedef enum {
|
|||||||
/*--------------------------------------------------------------*/
|
/*--------------------------------------------------------------*/
|
||||||
/* FatFs module application interface */
|
/* FatFs module application interface */
|
||||||
|
|
||||||
FRESULT f_mount (BYTE, FATFS*); /* Mount/Unmount a logical drive */
|
FRESULT f_mount (uint8_t, FATFS*); /* Mount/Unmount a logical drive */
|
||||||
FRESULT f_open (FIL*, const TCHAR*, BYTE); /* Open or create a file */
|
FRESULT f_open (FIL*, const TCHAR*, uint8_t); /* Open or create a file */
|
||||||
FRESULT f_read (FIL*, void*, UINT, UINT*); /* Read data from a file */
|
FRESULT f_read (FIL*, void*, uint32_t, uint32_t*); /* Read data from a file */
|
||||||
FRESULT f_lseek (FIL*, DWORD); /* Move file pointer of a file object */
|
FRESULT f_lseek (FIL*, uint32_t); /* Move file pointer of a file object */
|
||||||
FRESULT f_close (FIL*); /* Close an open file object */
|
FRESULT f_close (FIL*); /* Close an open file object */
|
||||||
FRESULT f_opendir (DIR*, const TCHAR*); /* Open an existing directory */
|
FRESULT f_opendir (DIR*, const TCHAR*); /* Open an existing directory */
|
||||||
FRESULT f_readdir (DIR*, FILINFO*); /* Read a directory item */
|
FRESULT f_readdir (DIR*, FILINFO*); /* Read a directory item */
|
||||||
FRESULT f_stat (const TCHAR*, FILINFO*); /* Get file status */
|
FRESULT f_stat (const TCHAR*, FILINFO*); /* Get file status */
|
||||||
FRESULT f_write (FIL*, const void*, UINT, UINT*); /* Write data to a file */
|
FRESULT f_write (FIL*, const void*, uint32_t, uint32_t*); /* Write data to a file */
|
||||||
FRESULT f_getfree (const TCHAR*, DWORD*, FATFS**); /* Get number of free clusters on the drive */
|
FRESULT f_getfree (const TCHAR*, uint32_t*, FATFS**); /* Get number of free clusters on the drive */
|
||||||
FRESULT f_truncate (FIL*); /* Truncate file */
|
FRESULT f_truncate (FIL*); /* Truncate file */
|
||||||
FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
|
FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
|
||||||
FRESULT f_unlink (const TCHAR*); /* Delete an existing file or directory */
|
FRESULT f_unlink (const TCHAR*); /* Delete an existing file or directory */
|
||||||
FRESULT f_mkdir (const TCHAR*); /* Create a new directory */
|
FRESULT f_mkdir (const TCHAR*); /* Create a new directory */
|
||||||
FRESULT f_chmod (const TCHAR*, BYTE, BYTE); /* Change attribute of the file/dir */
|
FRESULT f_chmod (const TCHAR*, uint8_t, uint8_t); /* Change attribute of the file/dir */
|
||||||
FRESULT f_utime (const TCHAR*, const FILINFO*); /* Change times-tamp of the file/dir */
|
FRESULT f_utime (const TCHAR*, const FILINFO*); /* Change times-tamp of the file/dir */
|
||||||
FRESULT f_rename (const TCHAR*, const TCHAR*); /* Rename/Move a file or directory */
|
FRESULT f_rename (const TCHAR*, const TCHAR*); /* Rename/Move a file or directory */
|
||||||
FRESULT f_chdrive (BYTE); /* Change current drive */
|
FRESULT f_chdrive (uint8_t); /* Change current drive */
|
||||||
FRESULT f_chdir (const TCHAR*); /* Change current directory */
|
FRESULT f_chdir (const TCHAR*); /* Change current directory */
|
||||||
FRESULT f_getcwd (TCHAR*, UINT); /* Get current directory */
|
FRESULT f_getcwd (TCHAR*, uint32_t); /* Get current directory */
|
||||||
FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*); /* Forward data to the stream */
|
FRESULT f_forward (FIL*, uint32_t(*)(const uint8_t*,uint32_t), uint32_t, uint32_t*); /* Forward data to the stream */
|
||||||
FRESULT f_mkfs (BYTE, BYTE, UINT); /* Create a file system on the drive */
|
FRESULT f_mkfs (uint8_t, uint8_t, uint32_t); /* Create a file system on the drive */
|
||||||
FRESULT f_fdisk (BYTE, const DWORD[], void*); /* Divide a physical drive into some partitions */
|
FRESULT f_fdisk (uint8_t, const uint32_t[], void*); /* Divide a physical drive into some partitions */
|
||||||
int f_putc (TCHAR, FIL*); /* Put a character to the file */
|
int f_putc (TCHAR, FIL*); /* Put a character to the file */
|
||||||
int f_puts (const TCHAR*, FIL*); /* Put a string to the file */
|
int f_puts (const TCHAR*, FIL*); /* Put a string to the file */
|
||||||
int f_printf (FIL*, const TCHAR*, ...); /* Put a formatted string to the file */
|
int f_printf (FIL*, const TCHAR*, ...); /* Put a formatted string to the file */
|
||||||
@@ -247,22 +247,22 @@ TCHAR* f_gets (TCHAR*, int, FIL*); /* Get a string from the file */
|
|||||||
|
|
||||||
/* RTC function */
|
/* RTC function */
|
||||||
#if !_FS_READONLY
|
#if !_FS_READONLY
|
||||||
DWORD get_fattime (void);
|
uint32_t get_fattime (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Unicode support functions */
|
/* Unicode support functions */
|
||||||
#if _USE_LFN /* Unicode - OEM code conversion */
|
#if _USE_LFN /* Unicode - OEM code conversion */
|
||||||
WCHAR ff_convert (WCHAR, UINT); /* OEM-Unicode bidirectional conversion */
|
uint16_t ff_convert (uint16_t, uint32_t); /* OEM-Unicode bidirectional conversion */
|
||||||
WCHAR ff_wtoupper (WCHAR); /* Unicode upper-case conversion */
|
uint16_t ff_wtoupper (uint16_t); /* Unicode upper-case conversion */
|
||||||
#if _USE_LFN == 3 /* Memory functions */
|
#if _USE_LFN == 3 /* Memory functions */
|
||||||
void* ff_memalloc (UINT); /* Allocate memory block */
|
void* ff_memalloc (uint32_t); /* Allocate memory block */
|
||||||
void ff_memfree (void*); /* Free memory block */
|
void ff_memfree (void*); /* Free memory block */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Sync functions */
|
/* Sync functions */
|
||||||
#if _FS_REENTRANT
|
#if _FS_REENTRANT
|
||||||
int ff_cre_syncobj (BYTE, _SYNC_t*);/* Create a sync object */
|
int ff_cre_syncobj (uint8_t, _SYNC_t*);/* Create a sync object */
|
||||||
int ff_req_grant (_SYNC_t); /* Lock sync object */
|
int ff_req_grant (_SYNC_t); /* Lock sync object */
|
||||||
void ff_rel_grant (_SYNC_t); /* Unlock sync object */
|
void ff_rel_grant (_SYNC_t); /* Unlock sync object */
|
||||||
int ff_del_syncobj (_SYNC_t); /* Delete a sync object */
|
int ff_del_syncobj (_SYNC_t); /* Delete a sync object */
|
||||||
@@ -319,15 +319,15 @@ int ff_del_syncobj (_SYNC_t); /* Delete a sync object */
|
|||||||
/* Multi-byte word access macros */
|
/* Multi-byte word access macros */
|
||||||
|
|
||||||
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
|
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
|
||||||
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
|
#define LD_WORD(ptr) (uint16_t)(* (uint16_t *)(uint8_t *)(ptr))
|
||||||
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
|
#define LD_DWORD(ptr) (uint32_t)(* (uint32_t *)(uint8_t *)(ptr))
|
||||||
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
|
#define ST_WORD(ptr,val) *(uint16_t *)(uint8_t *)(ptr) = (uint16_t)(val)
|
||||||
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
|
#define ST_DWORD(ptr,val) *(uint32_t *)(uint8_t *)(ptr) = (uint32_t)(val)
|
||||||
#else /* Use byte-by-byte access to the FAT structure */
|
#else /* Use byte-by-byte access to the FAT structure */
|
||||||
#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
|
#define LD_WORD(ptr) (uint16_t)(((uint16_t)*((uint8_t *)(ptr) + 1) << 8)| (uint16_t) *(uint8_t *)(ptr))
|
||||||
#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))
|
#define LD_DWORD(ptr) (uint32_t)(((uint32_t)*((uint8_t *)(ptr) + 3) << 24) | ((uint32_t)*((uint8_t*)(ptr) + 2) << 16) | ((uint16_t) *((uint8_t*)(ptr) + 1) << 8) | *(uint8_t*)(ptr))
|
||||||
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
|
#define ST_WORD(ptr,val) *(uint8_t *)(ptr) = (uint8_t)(val); *((uint8_t *)(ptr)+1) = (uint8_t)((uint16_t)(val) >> 8)
|
||||||
#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)
|
#define ST_DWORD(ptr,val) *(uint8_t *)(ptr) = (uint8_t)(val); *((uint8_t *)(ptr) + 1) = (uint8_t)((uint16_t)(val) >> 8); *((uint8_t*)(ptr) + 2) = (uint8_t)((uint32_t)(val) >> 16); *((uint8_t *)(ptr) + 3) = (uint8_t)((uint32_t)(val) >> 24)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
/*-------------------------------------------*/
|
|
||||||
/* Integer type definitions for FatFs module */
|
|
||||||
/*-------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef _INTEGER
|
|
||||||
#define _INTEGER
|
|
||||||
|
|
||||||
#ifdef _WIN32 /* FatFs development platform */
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
|
|
||||||
#else /* Embedded platform */
|
|
||||||
|
|
||||||
/* These types must be 16-bit, 32-bit or larger integer */
|
|
||||||
typedef int INT;
|
|
||||||
typedef unsigned int UINT;
|
|
||||||
|
|
||||||
/* These types must be 8-bit integer */
|
|
||||||
typedef char CHAR;
|
|
||||||
typedef unsigned char UCHAR;
|
|
||||||
typedef unsigned char BYTE;
|
|
||||||
|
|
||||||
/* These types must be 16-bit integer */
|
|
||||||
typedef short SHORT;
|
|
||||||
typedef unsigned short USHORT;
|
|
||||||
typedef unsigned short WORD;
|
|
||||||
typedef unsigned short WCHAR;
|
|
||||||
|
|
||||||
/* These types must be 32-bit integer */
|
|
||||||
typedef long LONG;
|
|
||||||
typedef unsigned long ULONG;
|
|
||||||
typedef unsigned long DWORD;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
FATFS Fatfs; /* File system object */
|
FATFS Fatfs; /* File system object */
|
||||||
FIL Fil; /* File object */
|
FIL Fil; /* File object */
|
||||||
BYTE Buff[128]; /* File read buffer */
|
uint8_t Buff[128]; /* File read buffer */
|
||||||
|
|
||||||
|
|
||||||
void die ( /* Stop with dying message */
|
void die ( /* Stop with dying message */
|
||||||
@@ -29,7 +29,7 @@ int main (void)
|
|||||||
FRESULT rc; /* Result code */
|
FRESULT rc; /* Result code */
|
||||||
DIR dir; /* Directory object */
|
DIR dir; /* Directory object */
|
||||||
FILINFO fno; /* File information object */
|
FILINFO fno; /* File information object */
|
||||||
UINT bw, br, i;
|
uint32_t bw, br, i;
|
||||||
|
|
||||||
|
|
||||||
f_mount(0, &Fatfs); /* Register volume work area (never fails) */
|
f_mount(0, &Fatfs); /* Register volume work area (never fails) */
|
||||||
@@ -89,12 +89,12 @@ int main (void)
|
|||||||
/* User Provided Timer Function for FatFs module */
|
/* User Provided Timer Function for FatFs module */
|
||||||
/*---------------------------------------------------------*/
|
/*---------------------------------------------------------*/
|
||||||
|
|
||||||
DWORD get_fattime (void)
|
uint32_t get_fattime (void)
|
||||||
{
|
{
|
||||||
return ((DWORD)(2012 - 1980) << 25) /* Year = 2012 */
|
return ((uint32_t)(2012 - 1980) << 25) /* Year = 2012 */
|
||||||
| ((DWORD)1 << 21) /* Month = 1 */
|
| ((uint32_t)1 << 21) /* Month = 1 */
|
||||||
| ((DWORD)1 << 16) /* Day_m = 1*/
|
| ((uint32_t)1 << 16) /* Day_m = 1*/
|
||||||
| ((DWORD)0 << 11) /* Hour = 0 */
|
| ((uint32_t)0 << 11) /* Hour = 0 */
|
||||||
| ((DWORD)0 << 5) /* Min = 0 */
|
| ((uint32_t)0 << 5) /* Min = 0 */
|
||||||
| ((DWORD)0 >> 1); /* Sec = 0 */
|
| ((uint32_t)0 >> 1); /* Sec = 0 */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,10 +104,10 @@
|
|||||||
static volatile DSTATUS Stat = STA_NOINIT; /* Physical drive status */
|
static volatile DSTATUS Stat = STA_NOINIT; /* Physical drive status */
|
||||||
|
|
||||||
static volatile
|
static volatile
|
||||||
UINT Timer1, Timer2; /* 1kHz decrement timer stopped at zero (disk_timerproc()) */
|
uint32_t Timer1, Timer2; /* 1kHz decrement timer stopped at zero (disk_timerproc()) */
|
||||||
|
|
||||||
static
|
static
|
||||||
BYTE CardType; /* Card type flags */
|
uint8_t CardType; /* Card type flags */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ BYTE CardType; /* Card type flags */
|
|||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* Exchange a byte */
|
/* Exchange a byte */
|
||||||
static BYTE xchg_spi(BYTE byte)
|
static uint8_t xchg_spi(uint8_t byte)
|
||||||
{
|
{
|
||||||
* (volatile uint8_t *) (&MCF_DSPI_DTFR + 3) = byte;
|
* (volatile uint8_t *) (&MCF_DSPI_DTFR + 3) = byte;
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ static BYTE xchg_spi(BYTE byte)
|
|||||||
* buff: pointer to data buffer
|
* buff: pointer to data buffer
|
||||||
* btr: number of bytes to receive (16, 64 or 512)
|
* btr: number of bytes to receive (16, 64 or 512)
|
||||||
*/
|
*/
|
||||||
static void rcvr_spi_multi(BYTE *buff, UINT count)
|
static void rcvr_spi_multi(uint8_t *buff, uint32_t count)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ static void rcvr_spi_multi(BYTE *buff, UINT count)
|
|||||||
* buff: pointer to data
|
* buff: pointer to data
|
||||||
* btx: number of bytes to send
|
* btx: number of bytes to send
|
||||||
*/
|
*/
|
||||||
static void xmit_spi_multi(const BYTE *buff, UINT btx)
|
static void xmit_spi_multi(const uint8_t *buff, uint32_t btx)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ static int card_ready(void)
|
|||||||
* wt: timeout in ms
|
* wt: timeout in ms
|
||||||
* returns 1: ready, 0: timeout
|
* returns 1: ready, 0: timeout
|
||||||
*/
|
*/
|
||||||
static int wait_ready (UINT wt)
|
static int wait_ready (uint32_t wt)
|
||||||
{
|
{
|
||||||
return waitfor(wt, card_ready);
|
return waitfor(wt, card_ready);
|
||||||
}
|
}
|
||||||
@@ -250,11 +250,11 @@ void power_off (void) /* Disable SPI function */
|
|||||||
|
|
||||||
static
|
static
|
||||||
int rcvr_datablock ( /* 1:OK, 0:Error */
|
int rcvr_datablock ( /* 1:OK, 0:Error */
|
||||||
BYTE *buff, /* Data buffer */
|
uint8_t *buff, /* Data buffer */
|
||||||
UINT btr /* Data block length (byte) */
|
uint32_t btr /* Data block length (byte) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
BYTE token;
|
uint8_t token;
|
||||||
|
|
||||||
|
|
||||||
Timer1 = 200;
|
Timer1 = 200;
|
||||||
@@ -279,11 +279,11 @@ int rcvr_datablock ( /* 1:OK, 0:Error */
|
|||||||
#if _USE_WRITE
|
#if _USE_WRITE
|
||||||
static
|
static
|
||||||
int xmit_datablock ( /* 1:OK, 0:Failed */
|
int xmit_datablock ( /* 1:OK, 0:Failed */
|
||||||
const BYTE *buff, /* Ponter to 512 byte data to be sent */
|
const uint8_t *buff, /* Ponter to 512 byte data to be sent */
|
||||||
BYTE token /* Token */
|
uint8_t token /* Token */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
BYTE resp;
|
uint8_t resp;
|
||||||
|
|
||||||
|
|
||||||
if (!wait_ready(500)) return 0; /* Wait for card ready */
|
if (!wait_ready(500)) return 0; /* Wait for card ready */
|
||||||
@@ -306,12 +306,12 @@ int xmit_datablock ( /* 1:OK, 0:Failed */
|
|||||||
/* Send a command packet to the MMC */
|
/* Send a command packet to the MMC */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
static BYTE send_cmd ( /* Return value: R1 resp (bit7==1:Failed to send) */
|
static uint8_t send_cmd ( /* Return value: R1 resp (bit7==1:Failed to send) */
|
||||||
BYTE cmd, /* Command index */
|
uint8_t cmd, /* Command index */
|
||||||
DWORD arg /* Argument */
|
uint32_t arg /* Argument */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
BYTE n, res;
|
uint8_t n, res;
|
||||||
|
|
||||||
|
|
||||||
if (cmd & 0x80) { /* Send a CMD55 prior to ACMD<n> */
|
if (cmd & 0x80) { /* Send a CMD55 prior to ACMD<n> */
|
||||||
@@ -326,10 +326,10 @@ static BYTE send_cmd ( /* Return value: R1 resp (bit7==1:Failed to send) */
|
|||||||
|
|
||||||
/* Send command packet */
|
/* Send command packet */
|
||||||
xchg_spi(0x40 | cmd); /* Start + command index */
|
xchg_spi(0x40 | cmd); /* Start + command index */
|
||||||
xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */
|
xchg_spi((uint8_t)(arg >> 24)); /* Argument[31..24] */
|
||||||
xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */
|
xchg_spi((uint8_t)(arg >> 16)); /* Argument[23..16] */
|
||||||
xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */
|
xchg_spi((uint8_t)(arg >> 8)); /* Argument[15..8] */
|
||||||
xchg_spi((BYTE)arg); /* Argument[7..0] */
|
xchg_spi((uint8_t)arg); /* Argument[7..0] */
|
||||||
n = 0x01; /* Dummy CRC + Stop */
|
n = 0x01; /* Dummy CRC + Stop */
|
||||||
if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) */
|
if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) */
|
||||||
if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) */
|
if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) */
|
||||||
@@ -359,9 +359,9 @@ static BYTE send_cmd ( /* Return value: R1 resp (bit7==1:Failed to send) */
|
|||||||
*
|
*
|
||||||
* drv: physical drive number (0)
|
* drv: physical drive number (0)
|
||||||
*/
|
*/
|
||||||
DSTATUS disk_initialize(BYTE drv)
|
DSTATUS disk_initialize(uint8_t drv)
|
||||||
{
|
{
|
||||||
BYTE n, cmd, ty, ocr[4];
|
uint8_t n, cmd, ty, ocr[4];
|
||||||
|
|
||||||
|
|
||||||
if (drv) return STA_NOINIT; /* Supports only drive 0 */
|
if (drv) return STA_NOINIT; /* Supports only drive 0 */
|
||||||
@@ -416,7 +416,7 @@ DSTATUS disk_initialize(BYTE drv)
|
|||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
DSTATUS disk_status (
|
DSTATUS disk_status (
|
||||||
BYTE drv /* Physical drive number (0) */
|
uint8_t drv /* Physical drive number (0) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (drv) return STA_NOINIT; /* Supports only drive 0 */
|
if (drv) return STA_NOINIT; /* Supports only drive 0 */
|
||||||
@@ -431,10 +431,10 @@ DSTATUS disk_status (
|
|||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRESULT disk_read (
|
DRESULT disk_read (
|
||||||
BYTE drv, /* Physical drive number (0) */
|
uint8_t drv, /* Physical drive number (0) */
|
||||||
BYTE *buff, /* Pointer to the data buffer to store read data */
|
uint8_t *buff, /* Pointer to the data buffer to store read data */
|
||||||
DWORD sector, /* Start sector number (LBA) */
|
uint32_t sector, /* Start sector number (LBA) */
|
||||||
BYTE count /* Number of sectors to read (1..128) */
|
uint8_t count /* Number of sectors to read (1..128) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (drv || !count) return RES_PARERR; /* Check parameter */
|
if (drv || !count) return RES_PARERR; /* Check parameter */
|
||||||
@@ -469,10 +469,10 @@ DRESULT disk_read (
|
|||||||
|
|
||||||
#if _USE_WRITE
|
#if _USE_WRITE
|
||||||
DRESULT disk_write (
|
DRESULT disk_write (
|
||||||
BYTE drv, /* Physical drive number (0) */
|
uint8_t drv, /* Physical drive number (0) */
|
||||||
const BYTE *buff, /* Ponter to the data to write */
|
const uint8_t *buff, /* Ponter to the data to write */
|
||||||
DWORD sector, /* Start sector number (LBA) */
|
uint32_t sector, /* Start sector number (LBA) */
|
||||||
BYTE count /* Number of sectors to write (1..128) */
|
uint8_t count /* Number of sectors to write (1..128) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (drv || !count) return RES_PARERR; /* Check parameter */
|
if (drv || !count) return RES_PARERR; /* Check parameter */
|
||||||
@@ -510,14 +510,14 @@ DRESULT disk_write (
|
|||||||
|
|
||||||
#if _USE_IOCTL
|
#if _USE_IOCTL
|
||||||
DRESULT disk_ioctl (
|
DRESULT disk_ioctl (
|
||||||
BYTE drv, /* Physical drive number (0) */
|
uint8_t drv, /* Physical drive number (0) */
|
||||||
BYTE ctrl, /* Control command code */
|
uint8_t ctrl, /* Control command code */
|
||||||
void *buff /* Pointer to the conrtol data */
|
void *buff /* Pointer to the conrtol data */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DRESULT res;
|
DRESULT res;
|
||||||
BYTE n, csd[16], *ptr = buff;
|
uint8_t n, csd[16], *ptr = buff;
|
||||||
DWORD *dp, st, ed, csize;
|
uint32_t *dp, st, ed, csize;
|
||||||
|
|
||||||
|
|
||||||
if (drv) return RES_PARERR; /* Check parameter */
|
if (drv) return RES_PARERR; /* Check parameter */
|
||||||
@@ -536,19 +536,19 @@ DRESULT disk_ioctl (
|
|||||||
case GET_SECTOR_COUNT : /* Get drive capacity in unit of sector (DWORD) */
|
case GET_SECTOR_COUNT : /* Get drive capacity in unit of sector (DWORD) */
|
||||||
if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) {
|
if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) {
|
||||||
if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */
|
if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */
|
||||||
csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1;
|
csize = csd[9] + ((uint16_t)csd[8] << 8) + ((uint32_t)(csd[7] & 63) << 16) + 1;
|
||||||
*(DWORD*)buff = csize << 10;
|
*(uint32_t*)buff = csize << 10;
|
||||||
} else { /* SDC ver 1.XX or MMC ver 3 */
|
} else { /* SDC ver 1.XX or MMC ver 3 */
|
||||||
n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2;
|
n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2;
|
||||||
csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1;
|
csize = (csd[8] >> 6) + ((uint16_t)csd[7] << 2) + ((uint16_t)(csd[6] & 3) << 10) + 1;
|
||||||
*(DWORD*)buff = csize << (n - 9);
|
*(uint32_t*)buff = csize << (n - 9);
|
||||||
}
|
}
|
||||||
res = RES_OK;
|
res = RES_OK;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GET_SECTOR_SIZE : /* Get sector size in unit of byte (WORD) */
|
case GET_SECTOR_SIZE : /* Get sector size in unit of byte (WORD) */
|
||||||
*(WORD*)buff = 512;
|
*(uint16_t*)buff = 512;
|
||||||
res = RES_OK;
|
res = RES_OK;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -558,16 +558,16 @@ DRESULT disk_ioctl (
|
|||||||
xchg_spi(0xFF);
|
xchg_spi(0xFF);
|
||||||
if (rcvr_datablock(csd, 16)) { /* Read partial block */
|
if (rcvr_datablock(csd, 16)) { /* Read partial block */
|
||||||
for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */
|
for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */
|
||||||
*(DWORD*)buff = 16UL << (csd[10] >> 4);
|
*(uint32_t*)buff = 16UL << (csd[10] >> 4);
|
||||||
res = RES_OK;
|
res = RES_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { /* SDC ver 1.XX or MMC */
|
} else { /* SDC ver 1.XX or MMC */
|
||||||
if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */
|
if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */
|
||||||
if (CardType & CT_SD1) { /* SDC ver 1.XX */
|
if (CardType & CT_SD1) { /* SDC ver 1.XX */
|
||||||
*(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1);
|
*(uint32_t*)buff = (((csd[10] & 63) << 1) + ((uint16_t)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1);
|
||||||
} else { /* MMC */
|
} else { /* MMC */
|
||||||
*(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1);
|
*(uint32_t*)buff = ((uint16_t)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1);
|
||||||
}
|
}
|
||||||
res = RES_OK;
|
res = RES_OK;
|
||||||
}
|
}
|
||||||
@@ -641,8 +641,8 @@ DRESULT disk_ioctl (
|
|||||||
|
|
||||||
void disk_timerproc (void)
|
void disk_timerproc (void)
|
||||||
{
|
{
|
||||||
WORD n;
|
uint16_t n;
|
||||||
BYTE s;
|
uint8_t s;
|
||||||
|
|
||||||
|
|
||||||
n = Timer1; /* 1kHz decrement timer stopped at 0 */
|
n = Timer1; /* 1kHz decrement timer stopped at 0 */
|
||||||
|
|||||||
Reference in New Issue
Block a user