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