diskio.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*-----------------------------------------------------------------------
  2. / Low level disk interface modlue include file (C)ChaN, 2013
  3. /-----------------------------------------------------------------------*/
  4. #ifndef _DISKIO_DEFINED
  5. #define _DISKIO_DEFINED
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #define _USE_WRITE 1 /* 1: Enable disk_write function */
  10. #define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
  11. #include "integer.h"
  12. /* Status of Disk Functions */
  13. typedef BYTE DSTATUS;
  14. /* Results of Disk Functions */
  15. typedef enum {
  16. RES_OK = 0, /* 0: Successful */
  17. RES_ERROR, /* 1: R/W Error */
  18. RES_WRPRT, /* 2: Write Protected */
  19. RES_NOTRDY, /* 3: Not Ready */
  20. RES_PARERR /* 4: Invalid Parameter */
  21. } DRESULT;
  22. /*---------------------------------------*/
  23. /* Prototypes for disk control functions */
  24. DSTATUS disk_initialize (BYTE pdrv);
  25. DSTATUS disk_status (BYTE pdrv);
  26. DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count);
  27. DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count);
  28. DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
  29. /* Disk Status Bits (DSTATUS) */
  30. #define STA_NOINIT 0x01 /* Drive not initialized */
  31. #define STA_NODISK 0x02 /* No medium in the drive */
  32. #define STA_PROTECT 0x04 /* Write protected */
  33. /* Command code for disk_ioctrl fucntion */
  34. /* Generic command (used by FatFs) */
  35. #define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
  36. #define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
  37. #define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
  38. #define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
  39. #define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
  40. /* Generic command (not used by FatFs) */
  41. #define CTRL_POWER 5 /* Get/Set power status */
  42. #define CTRL_LOCK 6 /* Lock/Unlock media removal */
  43. #define CTRL_EJECT 7 /* Eject media */
  44. #define CTRL_FORMAT 8 /* Create physical format on the media */
  45. /* MMC/SDC specific ioctl command */
  46. #define MMC_GET_TYPE 10 /* Get card type */
  47. #define MMC_GET_CSD 11 /* Get CSD */
  48. #define MMC_GET_CID 12 /* Get CID */
  49. #define MMC_GET_OCR 13 /* Get OCR */
  50. #define MMC_GET_SDSTAT 14 /* Get SD status */
  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. /* MMC card type flags (MMC_GET_TYPE) */
  56. #define CT_MMC 0x01 /* MMC ver 3 */
  57. #define CT_SD1 0x02 /* SD ver 1 */
  58. #define CT_SD2 0x04 /* SD ver 2 */
  59. #define CT_SDC (CT_SD1|CT_SD2) /* SD */
  60. #define CT_BLOCK 0x08 /* Block addressing */
  61. #ifdef __cplusplus
  62. }
  63. #endif
  64. #endif