diskio.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*-----------------------------------------------------------------------
  2. / Low level disk interface modlue include file R0.06 (C)ChaN, 2007
  3. /-----------------------------------------------------------------------*/
  4. #ifndef _DISKIO
  5. #define _DISKIO
  6. #define _READONLY 1 /* 1: Read-only mode */
  7. #define _USE_IOCTL 1
  8. #include "integer.h"
  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);
  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. void disk_timerproc (void);
  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() */
  34. /* Generic command */
  35. #define CTRL_SYNC 0 /* Mandatory for read/write configuration */
  36. #define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */
  37. #define GET_SECTOR_SIZE 2
  38. #define GET_BLOCK_SIZE 3 /* Mandatory for only f_mkfs() */
  39. #define CTRL_POWER 4
  40. #define CTRL_LOCK 5
  41. #define CTRL_EJECT 6
  42. /* MMC/SDC command */
  43. #define MMC_GET_TYPE 10
  44. #define MMC_GET_CSD 11
  45. #define MMC_GET_CID 12
  46. #define MMC_GET_OCR 13
  47. #define MMC_GET_SDSTAT 14
  48. /* ATA/CF command */
  49. #define ATA_GET_REV 20
  50. #define ATA_GET_MODEL 21
  51. #define ATA_GET_SN 22
  52. #define SDMMC 0
  53. #define USB 1
  54. #define ATA 2
  55. int MMC_disk_initialize(void);
  56. int MMC_disk_read(void *buff, DWORD sector, BYTE count);
  57. int MMC_disk_ioctl(BYTE ctrl, void *buff);
  58. int USB_disk_initialize(void);
  59. int USB_disk_read(void *buff, DWORD sector, BYTE count);
  60. int USB_disk_ioctl(BYTE ctrl, void *buff);
  61. #endif