diskio.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* This file is part of ooFatFs, a customised version of FatFs
  2. * See https://github.com/micropython/oofatfs for details
  3. */
  4. /*-----------------------------------------------------------------------/
  5. / Low level disk interface modlue include file (C)ChaN, 2014 /
  6. /-----------------------------------------------------------------------*/
  7. #ifndef _DISKIO_DEFINED
  8. #define _DISKIO_DEFINED
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. /* Status of Disk Functions */
  13. typedef BYTE DSTATUS;
  14. /* Results of Disk Functions */
  15. typedef enum {
  16. RES_OK = 0, /* 0: Successful */
  17. RES_ERROR, /* 1: R/W Error */
  18. RES_WRPRT, /* 2: Write Protected */
  19. RES_NOTRDY, /* 3: Not Ready */
  20. RES_PARERR /* 4: Invalid Parameter */
  21. } DRESULT;
  22. /*---------------------------------------*/
  23. /* Prototypes for disk control functions */
  24. DRESULT disk_read (void *drv, BYTE* buff, DWORD sector, UINT count);
  25. DRESULT disk_write (void *drv, const BYTE* buff, DWORD sector, UINT count);
  26. DRESULT disk_ioctl (void *drv, BYTE cmd, void* buff);
  27. /* Disk Status Bits (DSTATUS) */
  28. #define STA_NOINIT 0x01 /* Drive not initialized */
  29. #define STA_NODISK 0x02 /* No medium in the drive */
  30. #define STA_PROTECT 0x04 /* Write protected */
  31. /* Command code for disk_ioctrl fucntion */
  32. /* Generic command (Used by FatFs) */
  33. #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
  34. #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
  35. #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
  36. #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
  37. #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
  38. #define IOCTL_INIT 5
  39. #define IOCTL_STATUS 6
  40. /* Generic command (Not used by FatFs) */
  41. #define CTRL_POWER 5 /* Get/Set power status */
  42. #define CTRL_LOCK 6 /* Lock/Unlock media removal */
  43. #define CTRL_EJECT 7 /* Eject media */
  44. #define CTRL_FORMAT 8 /* Create physical format on the media */
  45. /* MMC/SDC specific ioctl command */
  46. #define MMC_GET_TYPE 10 /* Get card type */
  47. #define MMC_GET_CSD 11 /* Get CSD */
  48. #define MMC_GET_CID 12 /* Get CID */
  49. #define MMC_GET_OCR 13 /* Get OCR */
  50. #define MMC_GET_SDSTAT 14 /* Get SD status */
  51. #define ISDIO_READ 55 /* Read data form SD iSDIO register */
  52. #define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
  53. #define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
  54. /* ATA/CF specific ioctl command */
  55. #define ATA_GET_REV 20 /* Get F/W revision */
  56. #define ATA_GET_MODEL 21 /* Get model name */
  57. #define ATA_GET_SN 22 /* Get serial number */
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #endif