1 /*-----------------------------------------------------------------------/ 2 / Low level disk interface modlue include file (C)ChaN, 2014 / 3 /-----------------------------------------------------------------------*/ 4 5 #ifndef _DISKIO_DEFINED 6 #define _DISKIO_DEFINED 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 #include "integer.h" 13 14 15 /* Status of Disk Functions */ 16 typedef BYTE DSTATUS; 17 18 /* Results of Disk Functions */ 19 typedef enum { 20 RES_OK = 0, /* 0: Successful */ 21 RES_ERROR, /* 1: R/W Error */ 22 RES_WRPRT, /* 2: Write Protected */ 23 RES_NOTRDY, /* 3: Not Ready */ 24 RES_PARERR /* 4: Invalid Parameter */ 25 } DRESULT; 26 27 28 /*---------------------------------------*/ 29 /* Prototypes for disk control functions */ 30 31 /* Redefine names of disk IO functions to prevent name collisions */ 32 #define disk_initialize ff_disk_initialize 33 #define disk_status ff_disk_status 34 #define disk_read ff_disk_read 35 #define disk_write ff_disk_write 36 #define disk_ioctl ff_disk_ioctl 37 38 DSTATUS disk_initialize (BYTE pdrv); 39 DSTATUS disk_status (BYTE pdrv); 40 DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); 41 DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); 42 DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); 43 44 45 /* Disk Status Bits (DSTATUS) */ 46 47 #define STA_NOINIT 0x01 /* Drive not initialized */ 48 #define STA_NODISK 0x02 /* No medium in the drive */ 49 #define STA_PROTECT 0x04 /* Write protected */ 50 51 52 /* Command code for disk_ioctrl fucntion */ 53 54 /* Generic command (Used by FatFs) */ 55 #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ 56 #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ 57 #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ 58 #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ 59 #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ 60 #define GET_FORMAT_OPTION 9 /* Get media format option (need at _USE_MKFS == 1) */ 61 62 /* Generic command (Not used by FatFs) */ 63 #define CTRL_POWER 5 /* Get/Set power status */ 64 #define CTRL_LOCK 6 /* Lock/Unlock media removal */ 65 #define CTRL_EJECT 7 /* Eject media */ 66 #define CTRL_FORMAT 8 /* Create physical format on the media */ 67 68 /* MMC/SDC specific ioctl command */ 69 #define MMC_GET_TYPE 10 /* Get card type */ 70 #define MMC_GET_CSD 11 /* Get CSD */ 71 #define MMC_GET_CID 12 /* Get CID */ 72 #define MMC_GET_OCR 13 /* Get OCR */ 73 #define MMC_GET_SDSTAT 14 /* Get SD status */ 74 #define ISDIO_READ 55 /* Read data form SD iSDIO register */ 75 #define ISDIO_WRITE 56 /* Write data to SD iSDIO register */ 76 #define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */ 77 78 /* ATA/CF specific ioctl command */ 79 #define ATA_GET_REV 20 /* Get F/W revision */ 80 #define ATA_GET_MODEL 21 /* Get model name */ 81 #define ATA_GET_SN 22 /* Get serial number */ 82 83 #ifdef __cplusplus 84 } 85 #endif 86 87 #endif 88