1 | /*-----------------------------------------------------------------------
|
---|
2 | / Low level disk interface modlue include file R0.07 (C)ChaN, 2009
|
---|
3 | /-----------------------------------------------------------------------*/
|
---|
4 |
|
---|
5 | #ifndef _DISKIO
|
---|
6 |
|
---|
7 | #define _READONLY 0 /* 1: Read-only mode */
|
---|
8 | #define _USE_IOCTL 1
|
---|
9 |
|
---|
10 | #include "integer.h"
|
---|
11 |
|
---|
12 |
|
---|
13 | /* Status of Disk Functions */
|
---|
14 | typedef BYTE DSTATUS;
|
---|
15 |
|
---|
16 | /* Results of Disk Functions */
|
---|
17 | typedef enum {
|
---|
18 | RES_OK = 0, /* 0: Successful */
|
---|
19 | RES_ERROR, /* 1: R/W Error */
|
---|
20 | RES_WRPRT, /* 2: Write Protected */
|
---|
21 | RES_NOTRDY, /* 3: Not Ready */
|
---|
22 | RES_PARERR /* 4: Invalid Parameter */
|
---|
23 | } DRESULT;
|
---|
24 |
|
---|
25 |
|
---|
26 | /*---------------------------------------*/
|
---|
27 | /* Prototypes for disk control functions */
|
---|
28 |
|
---|
29 | BOOL assign_drives (int argc, char *argv[]);
|
---|
30 | DSTATUS disk_initialize (BYTE);
|
---|
31 | DSTATUS disk_status (BYTE);
|
---|
32 | DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
|
---|
33 | #if _READONLY == 0
|
---|
34 | DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
|
---|
35 | #endif
|
---|
36 | DRESULT disk_ioctl (BYTE, BYTE, void*);
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 | /* Disk Status Bits (DSTATUS) */
|
---|
41 |
|
---|
42 | #define STA_NOINIT 0x01 /* Drive not initialized */
|
---|
43 | #define STA_NODISK 0x02 /* No medium in the drive */
|
---|
44 | #define STA_PROTECT 0x04 /* Write protected */
|
---|
45 |
|
---|
46 |
|
---|
47 | /* Command code for disk_ioctrl() */
|
---|
48 |
|
---|
49 | /* Generic command */
|
---|
50 | #define CTRL_SYNC 0 /* Mandatory for write functions */
|
---|
51 | #define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */
|
---|
52 | #define GET_SECTOR_SIZE 2
|
---|
53 | #define GET_BLOCK_SIZE 3 /* Mandatory for only f_mkfs() */
|
---|
54 | #define CTRL_POWER 4
|
---|
55 | #define CTRL_LOCK 5
|
---|
56 | #define CTRL_EJECT 6
|
---|
57 | /* MMC/SDC command */
|
---|
58 | #define MMC_GET_TYPE 10
|
---|
59 | #define MMC_GET_CSD 11
|
---|
60 | #define MMC_GET_CID 12
|
---|
61 | #define MMC_GET_OCR 13
|
---|
62 | #define MMC_GET_SDSTAT 14
|
---|
63 | /* ATA/CF command */
|
---|
64 | #define ATA_GET_REV 20
|
---|
65 | #define ATA_GET_MODEL 21
|
---|
66 | #define ATA_GET_SN 22
|
---|
67 |
|
---|
68 |
|
---|
69 | #define _DISKIO
|
---|
70 | #endif
|
---|