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