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.
FATFileSystem/ChaN/diskio.h@0:83e8ad3d9a65, 2020-11-12 (annotated)
- Committer:
- alekboving
- Date:
- Thu Nov 12 15:20:15 2020 +0000
- Revision:
- 0:83e8ad3d9a65
initial commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| alekboving | 0:83e8ad3d9a65 | 1 | /*-----------------------------------------------------------------------/ | 
| alekboving | 0:83e8ad3d9a65 | 2 | / Low level disk interface modlue include file (C)ChaN, 2014 / | 
| alekboving | 0:83e8ad3d9a65 | 3 | /-----------------------------------------------------------------------*/ | 
| alekboving | 0:83e8ad3d9a65 | 4 | |
| alekboving | 0:83e8ad3d9a65 | 5 | #ifndef _DISKIO_DEFINED | 
| alekboving | 0:83e8ad3d9a65 | 6 | #define _DISKIO_DEFINED | 
| alekboving | 0:83e8ad3d9a65 | 7 | |
| alekboving | 0:83e8ad3d9a65 | 8 | #ifdef __cplusplus | 
| alekboving | 0:83e8ad3d9a65 | 9 | extern "C" { | 
| alekboving | 0:83e8ad3d9a65 | 10 | #endif | 
| alekboving | 0:83e8ad3d9a65 | 11 | |
| alekboving | 0:83e8ad3d9a65 | 12 | #define _USE_WRITE 1 /* 1: Enable disk_write function */ | 
| alekboving | 0:83e8ad3d9a65 | 13 | #define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ | 
| alekboving | 0:83e8ad3d9a65 | 14 | |
| alekboving | 0:83e8ad3d9a65 | 15 | #include "integer.h" | 
| alekboving | 0:83e8ad3d9a65 | 16 | |
| alekboving | 0:83e8ad3d9a65 | 17 | |
| alekboving | 0:83e8ad3d9a65 | 18 | /* Status of Disk Functions */ | 
| alekboving | 0:83e8ad3d9a65 | 19 | typedef BYTE DSTATUS; | 
| alekboving | 0:83e8ad3d9a65 | 20 | |
| alekboving | 0:83e8ad3d9a65 | 21 | /* Results of Disk Functions */ | 
| alekboving | 0:83e8ad3d9a65 | 22 | typedef enum { | 
| alekboving | 0:83e8ad3d9a65 | 23 | RES_OK = 0, /* 0: Successful */ | 
| alekboving | 0:83e8ad3d9a65 | 24 | RES_ERROR, /* 1: R/W Error */ | 
| alekboving | 0:83e8ad3d9a65 | 25 | RES_WRPRT, /* 2: Write Protected */ | 
| alekboving | 0:83e8ad3d9a65 | 26 | RES_NOTRDY, /* 3: Not Ready */ | 
| alekboving | 0:83e8ad3d9a65 | 27 | RES_PARERR /* 4: Invalid Parameter */ | 
| alekboving | 0:83e8ad3d9a65 | 28 | } DRESULT; | 
| alekboving | 0:83e8ad3d9a65 | 29 | |
| alekboving | 0:83e8ad3d9a65 | 30 | |
| alekboving | 0:83e8ad3d9a65 | 31 | /*---------------------------------------*/ | 
| alekboving | 0:83e8ad3d9a65 | 32 | /* Prototypes for disk control functions */ | 
| alekboving | 0:83e8ad3d9a65 | 33 | |
| alekboving | 0:83e8ad3d9a65 | 34 | |
| alekboving | 0:83e8ad3d9a65 | 35 | DSTATUS disk_initialize (BYTE pdrv); | 
| alekboving | 0:83e8ad3d9a65 | 36 | DSTATUS disk_status (BYTE pdrv); | 
| alekboving | 0:83e8ad3d9a65 | 37 | DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); | 
| alekboving | 0:83e8ad3d9a65 | 38 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); | 
| alekboving | 0:83e8ad3d9a65 | 39 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); | 
| alekboving | 0:83e8ad3d9a65 | 40 | |
| alekboving | 0:83e8ad3d9a65 | 41 | |
| alekboving | 0:83e8ad3d9a65 | 42 | /* Disk Status Bits (DSTATUS) */ | 
| alekboving | 0:83e8ad3d9a65 | 43 | |
| alekboving | 0:83e8ad3d9a65 | 44 | #define STA_NOINIT 0x01 /* Drive not initialized */ | 
| alekboving | 0:83e8ad3d9a65 | 45 | #define STA_NODISK 0x02 /* No medium in the drive */ | 
| alekboving | 0:83e8ad3d9a65 | 46 | #define STA_PROTECT 0x04 /* Write protected */ | 
| alekboving | 0:83e8ad3d9a65 | 47 | |
| alekboving | 0:83e8ad3d9a65 | 48 | |
| alekboving | 0:83e8ad3d9a65 | 49 | /* Command code for disk_ioctrl fucntion */ | 
| alekboving | 0:83e8ad3d9a65 | 50 | |
| alekboving | 0:83e8ad3d9a65 | 51 | /* Generic command (Used by FatFs) */ | 
| alekboving | 0:83e8ad3d9a65 | 52 | #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ | 
| alekboving | 0:83e8ad3d9a65 | 53 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ | 
| alekboving | 0:83e8ad3d9a65 | 54 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ | 
| alekboving | 0:83e8ad3d9a65 | 55 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ | 
| alekboving | 0:83e8ad3d9a65 | 56 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ | 
| alekboving | 0:83e8ad3d9a65 | 57 | |
| alekboving | 0:83e8ad3d9a65 | 58 | /* Generic command (Not used by FatFs) */ | 
| alekboving | 0:83e8ad3d9a65 | 59 | #define CTRL_POWER 5 /* Get/Set power status */ | 
| alekboving | 0:83e8ad3d9a65 | 60 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */ | 
| alekboving | 0:83e8ad3d9a65 | 61 | #define CTRL_EJECT 7 /* Eject media */ | 
| alekboving | 0:83e8ad3d9a65 | 62 | #define CTRL_FORMAT 8 /* Create physical format on the media */ | 
| alekboving | 0:83e8ad3d9a65 | 63 | |
| alekboving | 0:83e8ad3d9a65 | 64 | /* MMC/SDC specific ioctl command */ | 
| alekboving | 0:83e8ad3d9a65 | 65 | #define MMC_GET_TYPE 10 /* Get card type */ | 
| alekboving | 0:83e8ad3d9a65 | 66 | #define MMC_GET_CSD 11 /* Get CSD */ | 
| alekboving | 0:83e8ad3d9a65 | 67 | #define MMC_GET_CID 12 /* Get CID */ | 
| alekboving | 0:83e8ad3d9a65 | 68 | #define MMC_GET_OCR 13 /* Get OCR */ | 
| alekboving | 0:83e8ad3d9a65 | 69 | #define MMC_GET_SDSTAT 14 /* Get SD status */ | 
| alekboving | 0:83e8ad3d9a65 | 70 | |
| alekboving | 0:83e8ad3d9a65 | 71 | /* ATA/CF specific ioctl command */ | 
| alekboving | 0:83e8ad3d9a65 | 72 | #define ATA_GET_REV 20 /* Get F/W revision */ | 
| alekboving | 0:83e8ad3d9a65 | 73 | #define ATA_GET_MODEL 21 /* Get model name */ | 
| alekboving | 0:83e8ad3d9a65 | 74 | #define ATA_GET_SN 22 /* Get serial number */ | 
| alekboving | 0:83e8ad3d9a65 | 75 | |
| alekboving | 0:83e8ad3d9a65 | 76 | #ifdef __cplusplus | 
| alekboving | 0:83e8ad3d9a65 | 77 | } | 
| alekboving | 0:83e8ad3d9a65 | 78 | #endif | 
| alekboving | 0:83e8ad3d9a65 | 79 | |
| alekboving | 0:83e8ad3d9a65 | 80 | #endif |