diskio.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*-----------------------------------------------------------------------
  2. / Low level disk interface modlue include file
  3. /-----------------------------------------------------------------------*/
  4. #ifndef _DISKIO
  5. #define _READONLY 0 /* 1: Remove write functions */
  6. #define _USE_IOCTL 1 /* 1: Use disk_ioctl fucntion */
  7. #include "integer.h"
  8. /* Status of Disk Functions */
  9. typedef BYTE DSTATUS;
  10. /* Results of Disk Functions */
  11. typedef enum {
  12. RES_OK = 0, /* 0: Successful */
  13. RES_ERROR, /* 1: R/W Error */
  14. RES_WRPRT, /* 2: Write Protected */
  15. RES_NOTRDY, /* 3: Not Ready */
  16. RES_PARERR /* 4: Invalid Parameter */
  17. } DRESULT;
  18. /*---------------------------------------*/
  19. /* Prototypes for disk control functions */
  20. int assign_drives (int, int);
  21. DSTATUS disk_initialize (BYTE);
  22. DSTATUS disk_status (BYTE);
  23. DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
  24. #if _READONLY == 0
  25. DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
  26. #endif
  27. DRESULT disk_ioctl (BYTE, BYTE, void*);
  28. /* Disk Status Bits (DSTATUS) */
  29. #define STA_NOINIT 0x01 /* Drive not initialized */
  30. #define STA_NODISK 0x02 /* No medium in the drive */
  31. #define STA_PROTECT 0x04 /* Write protected */
  32. /* Command code for disk_ioctrl fucntion */
  33. /* Generic command (defined for FatFs) */
  34. #define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
  35. #define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
  36. #define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
  37. #define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
  38. #define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
  39. /* Generic command */
  40. #define CTRL_POWER 5 /* Get/Set power status */
  41. #define CTRL_LOCK 6 /* Lock/Unlock media removal */
  42. #define CTRL_EJECT 7 /* Eject media */
  43. /* MMC/SDC specific ioctl command */
  44. #define MMC_GET_TYPE 10 /* Get card type */
  45. #define MMC_GET_CSD 11 /* Get CSD */
  46. #define MMC_GET_CID 12 /* Get CID */
  47. #define MMC_GET_OCR 13 /* Get OCR */
  48. #define MMC_GET_SDSTAT 14 /* Get SD status */
  49. /* ATA/CF specific ioctl command */
  50. #define ATA_GET_REV 20 /* Get F/W revision */
  51. #define ATA_GET_MODEL 21 /* Get model name */
  52. #define ATA_GET_SN 22 /* Get serial number */
  53. /* NAND specific ioctl command */
  54. #define NAND_FORMAT 30 /* Create physical format */
  55. #define _DISKIO
  56. #endif