diskio.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*-----------------------------------------------------------------------
  2. / Low level disk interface modlue include file R0.06 (C)ChaN, 2007
  3. /-----------------------------------------------------------------------*/
  4. #ifndef _DISKIO
  5. #define _READONLY 0 /* 1: Read-only mode */
  6. #define _USE_IOCTL 1
  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. DSTATUS disk_initialize (BYTE);
  21. DSTATUS disk_status (BYTE);
  22. DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
  23. #if _READONLY == 0
  24. DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
  25. #endif
  26. DRESULT disk_ioctl (BYTE, BYTE, void*);
  27. void disk_timerproc (void);
  28. DWORD get_fattime (void);
  29. /* 得到文件Calendar格式的建立文件日期 */
  30. struct tm get_Calendarfattime (DWORD date,DWORD time);
  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() */
  36. /* Generic command */
  37. #define CTRL_SYNC 0 /* Mandatory for read/write configuration */
  38. #define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */
  39. #define GET_SECTOR_SIZE 2
  40. #define GET_BLOCK_SIZE 3 /* Mandatory for only f_mkfs() */
  41. #define CTRL_POWER 4
  42. #define CTRL_LOCK 5
  43. #define CTRL_EJECT 6
  44. /* MMC/SDC command */
  45. #define MMC_GET_TYPE 10
  46. #define MMC_GET_CSD 11
  47. #define MMC_GET_CID 12
  48. #define MMC_GET_OCR 13
  49. #define MMC_GET_SDSTAT 14
  50. /* ATA/CF command */
  51. #define ATA_GET_REV 20
  52. #define ATA_GET_MODEL 21
  53. #define ATA_GET_SN 22
  54. #define _DISKIO
  55. #endif