]>
Commit | Line | Data |
---|---|---|
7f552300 L |
1 | /*----------------------------------------------------------------------- |
2 | / Low level disk interface modlue include file R0.07 (C)ChaN, 2009 | |
3 | /-----------------------------------------------------------------------*/ | |
4 | ||
5 | #ifndef _DISKIO_H | |
6 | #define _DISKIO_H | |
7 | ||
8 | #define _USE_WRITE 1 /* 1: Enable disk_write function */ | |
9 | #define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ | |
10 | ||
11 | #include "integer.h" | |
12 | ||
13 | ||
14 | /* Status of Disk Functions */ | |
15 | typedef BYTE DSTATUS; | |
16 | ||
17 | /* Results of Disk Functions */ | |
18 | typedef enum { | |
19 | RES_OK = 0, /* 0: Successful */ | |
20 | RES_ERROR, /* 1: R/W Error */ | |
21 | RES_WRPRT, /* 2: Write Protected */ | |
22 | RES_NOTRDY, /* 3: Not Ready */ | |
23 | RES_PARERR /* 4: Invalid Parameter */ | |
24 | } DRESULT; | |
25 | ||
26 | ||
27 | /*---------------------------------------*/ | |
28 | /* Prototypes for disk control functions */ | |
29 | ||
30 | DSTATUS disk_initialize (BYTE drv); | |
31 | DSTATUS disk_status (BYTE drv); | |
32 | DRESULT disk_read (BYTE drv, BYTE* buff, DWORD sector, UINT count); | |
33 | #if _USE_WRITE | |
34 | DRESULT disk_write (BYTE drv, const BYTE* buff, DWORD sector, UINT count); | |
35 | #endif | |
36 | #if _USE_IOCTL | |
37 | DRESULT disk_ioctl (BYTE drv, BYTE cmd, void* buff); | |
38 | #endif | |
39 | void disk_timerproc (void); | |
40 | ||
41 | ||
42 | ||
43 | /* Disk Status Bits (DSTATUS) */ | |
44 | ||
45 | #define STA_NOINIT 0x01 /* Drive not initialized */ | |
46 | #define STA_NODISK 0x02 /* No medium in the drive */ | |
47 | #define STA_PROTECT 0x04 /* Write protected */ | |
a870134a | 48 | #define STA_FAST 0x08 /* Fast SPI clock */ |
11b53d3f | 49 | #define STAT_MASK (STA_NOINIT | STA_NODISK | STA_PROTECT) |
7f552300 L |
50 | |
51 | ||
52 | /* Command code for disk_ioctrl() */ | |
53 | ||
54 | /* Generic command (Used by FatFs) */ | |
55 | #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ | |
56 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ | |
57 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ | |
58 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ | |
59 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ | |
60 | ||
61 | /* Generic command (Not used by FatFs) */ | |
62 | #define CTRL_FORMAT 5 /* Create physical format on the media */ | |
63 | #define CTRL_POWER_IDLE 6 /* Put the device idle state */ | |
64 | #define CTRL_POWER_OFF 7 /* Put the device off state */ | |
65 | #define CTRL_LOCK 8 /* Lock media removal */ | |
66 | #define CTRL_UNLOCK 9 /* Unlock media removal */ | |
67 | #define CTRL_EJECT 10 /* Eject media */ | |
68 | ||
69 | /* MMC/SDC specific command (Not used by FatFs) */ | |
70 | #define MMC_GET_TYPE 50 /* Get card type */ | |
71 | #define MMC_GET_CSD 51 /* Get CSD */ | |
72 | #define MMC_GET_CID 52 /* Get CID */ | |
73 | #define MMC_GET_OCR 53 /* Get OCR */ | |
74 | #define MMC_GET_SDSTAT 54 /* Get SD status */ | |
75 | ||
76 | /* ATA/CF specific command (Not used by FatFs) */ | |
77 | #define ATA_GET_REV 60 /* Get F/W revision */ | |
78 | #define ATA_GET_MODEL 61 /* Get model name */ | |
79 | #define ATA_GET_SN 62 /* Get serial number */ | |
80 | ||
81 | /* MMC card type flags (MMC_GET_TYPE) */ | |
82 | #define CT_MMC 0x01 /* MMC ver 3 */ | |
83 | #define CT_SD1 0x02 /* SD ver 1 */ | |
84 | #define CT_SD2 0x04 /* SD ver 2 */ | |
85 | #define CT_SDC (CT_SD1|CT_SD2) /* SD */ | |
86 | #define CT_BLOCK 0x08 /* Block addressing */ | |
87 | ||
88 | #endif /* _DISKIO_H */ |