sdcard.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*-----------------------------------------------------------------------
  2. / Low level disk interface modlue include file R0.04a (C)ChaN, 2007
  3. /-----------------------------------------------------------------------*/
  4. #ifndef __SDCARD_H__
  5. #define __SDCARD_H__
  6. #define _READONLY 0 /* 1: Read-only mode */
  7. #include <rtthread.h>
  8. /* Status of Disk Functions */
  9. typedef rt_uint8_t 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 (rt_uint8_t);
  21. DSTATUS disk_status (rt_uint8_t);
  22. DRESULT disk_read (rt_uint8_t, rt_uint8_t*, rt_uint32_t, rt_uint8_t);
  23. #if _READONLY == 0
  24. DRESULT disk_write (rt_uint8_t, const rt_uint8_t*, rt_uint32_t, rt_uint8_t);
  25. #endif
  26. DRESULT disk_ioctl (rt_uint8_t, rt_uint8_t, void*);
  27. void disk_timerproc (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() */
  33. #define GET_SECTOR_COUNT 1
  34. #define GET_SECTOR_SIZE 2
  35. #define CTRL_SYNC 3
  36. #define CTRL_POWER 4
  37. #define CTRL_LOCK 5
  38. #define CTRL_EJECT 6
  39. #define MMC_GET_CSD 10
  40. #define MMC_GET_CID 11
  41. #define MMC_GET_OCR 12
  42. #define ATA_GET_REV 20
  43. #define ATA_GET_MODEL 21
  44. #define ATA_GET_SN 22
  45. #endif