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