diskio.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*-----------------------------------------------------------------------
  2. / Low level disk interface modlue include file (C)ChaN, 2010
  3. /-----------------------------------------------------------------------*/
  4. #ifndef _DISKIO
  5. #define _READONLY 0 /* 1: Remove write functions */
  6. #define _USE_IOCTL 1 /* 1: Use disk_ioctl fucntion */
  7. #include <arm/NXP/LPC17xx/LPC17xx.h>
  8. #include "integer.h"
  9. /* Status of Disk Functions */
  10. typedef BYTE DSTATUS;
  11. /* Results of Disk Functions */
  12. typedef enum
  13. {
  14. RES_OK = 0, /* 0: Successful */
  15. RES_ERROR, /* 1: R/W Error */
  16. RES_WRPRT, /* 2: Write Protected */
  17. RES_NOTRDY, /* 3: Not Ready */
  18. RES_PARERR /* 4: Invalid Parameter */
  19. } DRESULT;
  20. /**
  21. * struct diskinfo0_t - disk info data structure for page 0
  22. * @validbytes : Number of valid bytes in this struct
  23. * @maxpage : Highest diskinfo page supported
  24. * @disktype : type of the disk (DISK_TYPE_* values)
  25. * @sectorsize : sector size divided by 256
  26. * @sectorcount: number of sectors on the disk
  27. *
  28. * This is the struct returned in the data buffer when disk_getinfo
  29. * is called with page=0.
  30. */
  31. typedef struct
  32. {
  33. uint8_t validbytes;
  34. uint8_t maxpage;
  35. uint8_t disktype;
  36. uint8_t sectorsize; /* divided by 256 */
  37. uint32_t sectorcount; /* 2 TB should be enough... (512 byte sectors) */
  38. } diskinfo0_t;
  39. /*---------------------------------------*/
  40. /* Prototypes for disk control functions */
  41. int assign_drives ( int, int );
  42. DSTATUS disk_initialize ( BYTE );
  43. DSTATUS disk_status ( BYTE );
  44. DRESULT disk_read ( BYTE, BYTE *, DWORD, BYTE );
  45. #if _READONLY == 0
  46. DRESULT disk_write ( BYTE, const BYTE *, DWORD, BYTE );
  47. #endif
  48. #define disk_ioctl(a,b,c) RES_OK
  49. #define get_fattime() (0)
  50. void disk_init( void );
  51. /* Will be set to DISK_ERROR if any access on the card fails */
  52. enum diskstates { DISK_CHANGED = 0, DISK_REMOVED, DISK_OK, DISK_ERROR };
  53. extern int sd_offload, ff_sd_offload, sd_offload_tgt, newcard;
  54. extern int sd_offload_partial;
  55. extern uint16_t sd_offload_partial_start;
  56. extern uint16_t sd_offload_partial_end;
  57. extern volatile enum diskstates disk_state;
  58. /* Disk type - part of the external API except for ATA2! */
  59. #define DISK_TYPE_ATA 0
  60. #define DISK_TYPE_ATA2 1
  61. #define DISK_TYPE_SD 2
  62. #define DISK_TYPE_DF 3
  63. #define DISK_TYPE_NONE 7
  64. /* Disk Status Bits (DSTATUS) */
  65. #define STA_NOINIT 0x01 /* Drive not initialized */
  66. #define STA_NODISK 0x02 /* No medium in the drive */
  67. #define STA_PROTECT 0x04 /* Write protected */
  68. /* Command code for disk_ioctrl fucntion */
  69. /* Generic command (defined for FatFs) */
  70. #define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
  71. #define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
  72. #define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
  73. #define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
  74. #define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
  75. /* Generic command */
  76. #define CTRL_POWER 5 /* Get/Set power status */
  77. #define CTRL_LOCK 6 /* Lock/Unlock media removal */
  78. #define CTRL_EJECT 7 /* Eject media */
  79. /* MMC/SDC specific ioctl command */
  80. #define MMC_GET_TYPE 10 /* Get card type */
  81. #define MMC_GET_CSD 11 /* Get CSD */
  82. #define MMC_GET_CID 12 /* Get CID */
  83. #define MMC_GET_OCR 13 /* Get OCR */
  84. #define MMC_GET_SDSTAT 14 /* Get SD status */
  85. /* ATA/CF specific ioctl command */
  86. #define ATA_GET_REV 20 /* Get F/W revision */
  87. #define ATA_GET_MODEL 21 /* Get model name */
  88. #define ATA_GET_SN 22 /* Get serial number */
  89. /* NAND specific ioctl command */
  90. #define NAND_FORMAT 30 /* Create physical format */
  91. #define _DISKIO
  92. #endif