Example SDFileSystem in which FATDirHandle exposes the file info struct of the current file/directory.

Committer:
uci1
Date:
Fri Nov 28 05:12:38 2014 +0000
Revision:
1:a7d8fc28a863
Parent:
0:687056ba3278
change SD init so it won't stall on failed initialization

Who changed what in which revision?

UserRevisionLine numberNew contents of line
uci1 0:687056ba3278 1 //-----------------------------------------------------------------------
uci1 0:687056ba3278 2 // Low level disk interface modlue include file
uci1 0:687056ba3278 3 //-----------------------------------------------------------------------
uci1 0:687056ba3278 4
uci1 0:687056ba3278 5 #ifndef _DISKIO
uci1 0:687056ba3278 6
uci1 0:687056ba3278 7 #define _READONLY 0 // 1: Remove write functions
uci1 0:687056ba3278 8 #define _USE_IOCTL 1 // 1: Use disk_ioctl fucntion
uci1 0:687056ba3278 9
uci1 0:687056ba3278 10 #include "integer.h"
uci1 0:687056ba3278 11
uci1 0:687056ba3278 12
uci1 0:687056ba3278 13 // Status of Disk Functions
uci1 0:687056ba3278 14 typedef BYTE DSTATUS;
uci1 0:687056ba3278 15
uci1 0:687056ba3278 16 // Results of Disk Functions
uci1 0:687056ba3278 17 typedef enum {
uci1 0:687056ba3278 18 RES_OK = 0, // 0: Successful
uci1 0:687056ba3278 19 RES_ERROR, // 1: R/W Error
uci1 0:687056ba3278 20 RES_WRPRT, // 2: Write Protected
uci1 0:687056ba3278 21 RES_NOTRDY, // 3: Not Ready
uci1 0:687056ba3278 22 RES_PARERR // 4: Invalid Parameter
uci1 0:687056ba3278 23 } DRESULT;
uci1 0:687056ba3278 24
uci1 0:687056ba3278 25
uci1 0:687056ba3278 26 // Prototypes for disk control functions
uci1 0:687056ba3278 27
uci1 0:687056ba3278 28 int assign_drives (int, int);
uci1 0:687056ba3278 29 DSTATUS disk_initialize (BYTE);
uci1 0:687056ba3278 30 DSTATUS disk_status (BYTE);
uci1 0:687056ba3278 31 DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
uci1 0:687056ba3278 32 #if _READONLY == 0
uci1 0:687056ba3278 33 DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
uci1 0:687056ba3278 34 #endif
uci1 0:687056ba3278 35 DRESULT disk_ioctl (BYTE, BYTE, void*);
uci1 0:687056ba3278 36
uci1 0:687056ba3278 37
uci1 0:687056ba3278 38
uci1 0:687056ba3278 39 // Disk Status Bits (DSTATUS)
uci1 0:687056ba3278 40 #define STA_NOINIT 0x01 // Drive not initialized
uci1 0:687056ba3278 41 #define STA_NODISK 0x02 // No medium in the drive
uci1 0:687056ba3278 42 #define STA_PROTECT 0x04 // Write protected
uci1 0:687056ba3278 43
uci1 0:687056ba3278 44
uci1 0:687056ba3278 45 // Command code for disk_ioctrl fucntion
uci1 0:687056ba3278 46
uci1 0:687056ba3278 47 // Generic command (defined for FatFs)
uci1 0:687056ba3278 48 #define CTRL_SYNC 0 // Flush disk cache (for write functions)
uci1 0:687056ba3278 49 #define GET_SECTOR_COUNT 1 // Get media size (for only f_mkfs())
uci1 0:687056ba3278 50 #define GET_SECTOR_SIZE 2 // Get sector size (for multiple sector size (_MAX_SS >= 1024))
uci1 0:687056ba3278 51 #define GET_BLOCK_SIZE 3 // Get erase block size (for only f_mkfs())
uci1 0:687056ba3278 52 #define CTRL_ERASE_SECTOR 4 // Force erased a block of sectors (for only _USE_ERASE)
uci1 0:687056ba3278 53
uci1 0:687056ba3278 54 // Generic command
uci1 0:687056ba3278 55 #define CTRL_POWER 5 // Get/Set power status
uci1 0:687056ba3278 56 #define CTRL_LOCK 6 // Lock/Unlock media removal
uci1 0:687056ba3278 57 #define CTRL_EJECT 7 // Eject media
uci1 0:687056ba3278 58
uci1 0:687056ba3278 59 // MMC/SDC specific ioctl command
uci1 0:687056ba3278 60 #define MMC_GET_TYPE 10 // Get card type
uci1 0:687056ba3278 61 #define MMC_GET_CSD 11 // Get CSD
uci1 0:687056ba3278 62 #define MMC_GET_CID 12 // Get CID
uci1 0:687056ba3278 63 #define MMC_GET_OCR 13 // Get OCR
uci1 0:687056ba3278 64 #define MMC_GET_SDSTAT 14 // Get SD status
uci1 0:687056ba3278 65
uci1 0:687056ba3278 66 // ATA/CF specific ioctl command
uci1 0:687056ba3278 67 #define ATA_GET_REV 20 // Get F/W revision
uci1 0:687056ba3278 68 #define ATA_GET_MODEL 21 // Get model name
uci1 0:687056ba3278 69 #define ATA_GET_SN 22 // Get serial number
uci1 0:687056ba3278 70
uci1 0:687056ba3278 71 // NAND specific ioctl command
uci1 0:687056ba3278 72 #define NAND_FORMAT 30 // Create physical format
uci1 0:687056ba3278 73
uci1 0:687056ba3278 74
uci1 0:687056ba3278 75 #define _DISKIO
uci1 0:687056ba3278 76 #endif