Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: SDFileSystem_Axelta
ChaN/diskio.h@0:6547fbc0f7c0, 2016-11-11 (annotated)
- Committer:
- gauthibit
- Date:
- Fri Nov 11 06:39:00 2016 +0000
- Revision:
- 0:6547fbc0f7c0
FAT
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gauthibit | 0:6547fbc0f7c0 | 1 | //----------------------------------------------------------------------- |
gauthibit | 0:6547fbc0f7c0 | 2 | // Low level disk interface modlue include file |
gauthibit | 0:6547fbc0f7c0 | 3 | //----------------------------------------------------------------------- |
gauthibit | 0:6547fbc0f7c0 | 4 | |
gauthibit | 0:6547fbc0f7c0 | 5 | #ifndef _DISKIO |
gauthibit | 0:6547fbc0f7c0 | 6 | |
gauthibit | 0:6547fbc0f7c0 | 7 | #define _READONLY 0 // 1: Remove write functions |
gauthibit | 0:6547fbc0f7c0 | 8 | #define _USE_IOCTL 1 // 1: Use disk_ioctl fucntion |
gauthibit | 0:6547fbc0f7c0 | 9 | |
gauthibit | 0:6547fbc0f7c0 | 10 | #include "integer.h" |
gauthibit | 0:6547fbc0f7c0 | 11 | |
gauthibit | 0:6547fbc0f7c0 | 12 | |
gauthibit | 0:6547fbc0f7c0 | 13 | // Status of Disk Functions |
gauthibit | 0:6547fbc0f7c0 | 14 | typedef BYTE DSTATUS; |
gauthibit | 0:6547fbc0f7c0 | 15 | |
gauthibit | 0:6547fbc0f7c0 | 16 | // Results of Disk Functions |
gauthibit | 0:6547fbc0f7c0 | 17 | typedef enum { |
gauthibit | 0:6547fbc0f7c0 | 18 | RES_OK = 0, // 0: Successful |
gauthibit | 0:6547fbc0f7c0 | 19 | RES_ERROR, // 1: R/W Error |
gauthibit | 0:6547fbc0f7c0 | 20 | RES_WRPRT, // 2: Write Protected |
gauthibit | 0:6547fbc0f7c0 | 21 | RES_NOTRDY, // 3: Not Ready |
gauthibit | 0:6547fbc0f7c0 | 22 | RES_PARERR // 4: Invalid Parameter |
gauthibit | 0:6547fbc0f7c0 | 23 | } DRESULT; |
gauthibit | 0:6547fbc0f7c0 | 24 | |
gauthibit | 0:6547fbc0f7c0 | 25 | |
gauthibit | 0:6547fbc0f7c0 | 26 | // Prototypes for disk control functions |
gauthibit | 0:6547fbc0f7c0 | 27 | |
gauthibit | 0:6547fbc0f7c0 | 28 | int assign_drives (int, int); |
gauthibit | 0:6547fbc0f7c0 | 29 | DSTATUS disk_initialize (BYTE); |
gauthibit | 0:6547fbc0f7c0 | 30 | DSTATUS disk_status (BYTE); |
gauthibit | 0:6547fbc0f7c0 | 31 | DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE); |
gauthibit | 0:6547fbc0f7c0 | 32 | #if _READONLY == 0 |
gauthibit | 0:6547fbc0f7c0 | 33 | DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); |
gauthibit | 0:6547fbc0f7c0 | 34 | #endif |
gauthibit | 0:6547fbc0f7c0 | 35 | DRESULT disk_ioctl (BYTE, BYTE, void*); |
gauthibit | 0:6547fbc0f7c0 | 36 | |
gauthibit | 0:6547fbc0f7c0 | 37 | |
gauthibit | 0:6547fbc0f7c0 | 38 | |
gauthibit | 0:6547fbc0f7c0 | 39 | // Disk Status Bits (DSTATUS) |
gauthibit | 0:6547fbc0f7c0 | 40 | #define STA_NOINIT 0x01 // Drive not initialized |
gauthibit | 0:6547fbc0f7c0 | 41 | #define STA_NODISK 0x02 // No medium in the drive |
gauthibit | 0:6547fbc0f7c0 | 42 | #define STA_PROTECT 0x04 // Write protected |
gauthibit | 0:6547fbc0f7c0 | 43 | |
gauthibit | 0:6547fbc0f7c0 | 44 | |
gauthibit | 0:6547fbc0f7c0 | 45 | // Command code for disk_ioctrl fucntion |
gauthibit | 0:6547fbc0f7c0 | 46 | |
gauthibit | 0:6547fbc0f7c0 | 47 | // Generic command (defined for FatFs) |
gauthibit | 0:6547fbc0f7c0 | 48 | #define CTRL_SYNC 0 // Flush disk cache (for write functions) |
gauthibit | 0:6547fbc0f7c0 | 49 | #define GET_SECTOR_COUNT 1 // Get media size (for only f_mkfs()) |
gauthibit | 0:6547fbc0f7c0 | 50 | #define GET_SECTOR_SIZE 2 // Get sector size (for multiple sector size (_MAX_SS >= 1024)) |
gauthibit | 0:6547fbc0f7c0 | 51 | #define GET_BLOCK_SIZE 3 // Get erase block size (for only f_mkfs()) |
gauthibit | 0:6547fbc0f7c0 | 52 | #define CTRL_ERASE_SECTOR 4 // Force erased a block of sectors (for only _USE_ERASE) |
gauthibit | 0:6547fbc0f7c0 | 53 | |
gauthibit | 0:6547fbc0f7c0 | 54 | // Generic command |
gauthibit | 0:6547fbc0f7c0 | 55 | #define CTRL_POWER 5 // Get/Set power status |
gauthibit | 0:6547fbc0f7c0 | 56 | #define CTRL_LOCK 6 // Lock/Unlock media removal |
gauthibit | 0:6547fbc0f7c0 | 57 | #define CTRL_EJECT 7 // Eject media |
gauthibit | 0:6547fbc0f7c0 | 58 | |
gauthibit | 0:6547fbc0f7c0 | 59 | // MMC/SDC specific ioctl command |
gauthibit | 0:6547fbc0f7c0 | 60 | #define MMC_GET_TYPE 10 // Get card type |
gauthibit | 0:6547fbc0f7c0 | 61 | #define MMC_GET_CSD 11 // Get CSD |
gauthibit | 0:6547fbc0f7c0 | 62 | #define MMC_GET_CID 12 // Get CID |
gauthibit | 0:6547fbc0f7c0 | 63 | #define MMC_GET_OCR 13 // Get OCR |
gauthibit | 0:6547fbc0f7c0 | 64 | #define MMC_GET_SDSTAT 14 // Get SD status |
gauthibit | 0:6547fbc0f7c0 | 65 | |
gauthibit | 0:6547fbc0f7c0 | 66 | // ATA/CF specific ioctl command |
gauthibit | 0:6547fbc0f7c0 | 67 | #define ATA_GET_REV 20 // Get F/W revision |
gauthibit | 0:6547fbc0f7c0 | 68 | #define ATA_GET_MODEL 21 // Get model name |
gauthibit | 0:6547fbc0f7c0 | 69 | #define ATA_GET_SN 22 // Get serial number |
gauthibit | 0:6547fbc0f7c0 | 70 | |
gauthibit | 0:6547fbc0f7c0 | 71 | // NAND specific ioctl command |
gauthibit | 0:6547fbc0f7c0 | 72 | #define NAND_FORMAT 30 // Create physical format |
gauthibit | 0:6547fbc0f7c0 | 73 | |
gauthibit | 0:6547fbc0f7c0 | 74 | |
gauthibit | 0:6547fbc0f7c0 | 75 | #define _DISKIO |
gauthibit | 0:6547fbc0f7c0 | 76 | #endif |