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