您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

102 行
3.3 KiB

  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. #include "integer.h"
  10. #define _USE_WRITE 1
  11. #define _USE_IOCTL 1
  12. #define _USE
  13. /* Status of Disk Functions */
  14. typedef BYTE DSTATUS;
  15. /* Results of Disk Functions */
  16. typedef enum {
  17. RES_OK = 0, /* 0: Successful */
  18. RES_ERROR, /* 1: R/W Error */
  19. RES_WRPRT, /* 2: Write Protected */
  20. RES_NOTRDY, /* 3: Not Ready */
  21. RES_PARERR /* 4: Invalid Parameter */
  22. } DRESULT;
  23. /*---------------------------------------*/
  24. /* Prototypes for disk control functions */
  25. DSTATUS disk_initialize (BYTE pdrv);
  26. DSTATUS disk_status (BYTE pdrv);
  27. DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
  28. DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
  29. DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
  30. void disk_timerproc(void);
  31. /* Disk Status Bits (DSTATUS) */
  32. #define STA_NOINIT 0x01 /* Drive not initialized */
  33. #define STA_NODISK 0x02 /* No medium in the drive */
  34. #define STA_PROTECT 0x04 /* Write protected */
  35. /* Command code for disk_ioctrl fucntion */
  36. /* Generic command (Used by FatFs) */
  37. #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
  38. #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
  39. #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
  40. #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
  41. #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
  42. ///* Generic command (Not used by FatFs) */
  43. //#define CTRL_POWER 5 /* Get/Set power status */
  44. //#define CTRL_LOCK 6 /* Lock/Unlock media removal */
  45. //#define CTRL_EJECT 7 /* Eject media */
  46. //#define CTRL_FORMAT 8 /* Create physical format on the media */
  47. /* Generic command (Not used by FatFs) */
  48. #define CTRL_FORMAT 5 /* Create physical format on the media */
  49. #define CTRL_POWER_IDLE 6 /* Put the device idle state */
  50. #define CTRL_POWER_OFF 7 /* Put the device off state */
  51. #define CTRL_LOCK 8 /* Lock media removal */
  52. #define CTRL_UNLOCK 9 /* Unlock media removal */
  53. #define CTRL_EJECT 10 /* Eject media */
  54. /* MMC/SDC specific ioctl command */
  55. #define MMC_GET_TYPE 10 /* Get card type */
  56. #define MMC_GET_CSD 11 /* Get CSD */
  57. #define MMC_GET_CID 12 /* Get CID */
  58. #define MMC_GET_OCR 13 /* Get OCR */
  59. #define MMC_GET_SDSTAT 14 /* Get SD status */
  60. #define ISDIO_READ 55 /* Read data form SD iSDIO register */
  61. #define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
  62. #define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
  63. /* MMC card type flags (MMC_GET_TYPE) */
  64. #define CT_MMC 0x01 /* MMC ver 3 */
  65. #define CT_SD1 0x02 /* SD ver 1 */
  66. #define CT_SD2 0x04 /* SD ver 2 */
  67. #define CT_SDC (CT_SD1|CT_SD2) /* SD */
  68. #define CT_BLOCK 0x08 /* Block addressing */
  69. /* ATA/CF specific ioctl command */
  70. #define ATA_GET_REV 20 /* Get F/W revision */
  71. #define ATA_GET_MODEL 21 /* Get model name */
  72. #define ATA_GET_SN 22 /* Get serial number */
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #endif