diskio.h 2.6 KB

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