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