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