Eli Hughes
/
COMPACT_FLASH
Compact Flash I/O test
FAT_FS/diskio.h@1:dc171f34db9b, 2011-12-30 (annotated)
- Committer:
- emh203
- Date:
- Fri Dec 30 21:02:16 2011 +0000
- Revision:
- 1:dc171f34db9b
- Parent:
- 0:6b1e6c9e48ba
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emh203 | 0:6b1e6c9e48ba | 1 | /*----------------------------------------------------------------------- |
emh203 | 0:6b1e6c9e48ba | 2 | / Low level disk interface modlue include file |
emh203 | 0:6b1e6c9e48ba | 3 | /-----------------------------------------------------------------------*/ |
emh203 | 0:6b1e6c9e48ba | 4 | #include "integer.h" |
emh203 | 0:6b1e6c9e48ba | 5 | |
emh203 | 0:6b1e6c9e48ba | 6 | #ifndef _DISKIO |
emh203 | 0:6b1e6c9e48ba | 7 | #define _READONLY 0 /* 1: Remove write functions */ |
emh203 | 0:6b1e6c9e48ba | 8 | #define _USE_IOCTL 1 /* 1: Use disk_ioctl fucntion */ |
emh203 | 0:6b1e6c9e48ba | 9 | |
emh203 | 0:6b1e6c9e48ba | 10 | |
emh203 | 0:6b1e6c9e48ba | 11 | void InitCompactFlashInterface(); |
emh203 | 0:6b1e6c9e48ba | 12 | void CompactFlashIO_Test(); |
emh203 | 0:6b1e6c9e48ba | 13 | |
emh203 | 0:6b1e6c9e48ba | 14 | /* Status of Disk Functions */ |
emh203 | 0:6b1e6c9e48ba | 15 | typedef BYTE DSTATUS; |
emh203 | 0:6b1e6c9e48ba | 16 | |
emh203 | 0:6b1e6c9e48ba | 17 | /* Results of Disk Functions */ |
emh203 | 0:6b1e6c9e48ba | 18 | typedef enum { |
emh203 | 0:6b1e6c9e48ba | 19 | RES_OK = 0, /* 0: Successful */ |
emh203 | 0:6b1e6c9e48ba | 20 | RES_ERROR, /* 1: R/W Error */ |
emh203 | 0:6b1e6c9e48ba | 21 | RES_WRPRT, /* 2: Write Protected */ |
emh203 | 0:6b1e6c9e48ba | 22 | RES_NOTRDY, /* 3: Not Ready */ |
emh203 | 0:6b1e6c9e48ba | 23 | RES_PARERR /* 4: Invalid Parameter */ |
emh203 | 0:6b1e6c9e48ba | 24 | } DRESULT; |
emh203 | 0:6b1e6c9e48ba | 25 | |
emh203 | 0:6b1e6c9e48ba | 26 | |
emh203 | 0:6b1e6c9e48ba | 27 | /*---------------------------------------*/ |
emh203 | 0:6b1e6c9e48ba | 28 | /* Prototypes for disk control functions */ |
emh203 | 0:6b1e6c9e48ba | 29 | |
emh203 | 0:6b1e6c9e48ba | 30 | int assign_drives (int, int); |
emh203 | 0:6b1e6c9e48ba | 31 | |
emh203 | 0:6b1e6c9e48ba | 32 | |
emh203 | 0:6b1e6c9e48ba | 33 | DSTATUS disk_initialize (BYTE); |
emh203 | 0:6b1e6c9e48ba | 34 | DSTATUS disk_status (BYTE); |
emh203 | 0:6b1e6c9e48ba | 35 | DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE); |
emh203 | 0:6b1e6c9e48ba | 36 | #if _READONLY == 0 |
emh203 | 0:6b1e6c9e48ba | 37 | DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); |
emh203 | 0:6b1e6c9e48ba | 38 | #endif |
emh203 | 0:6b1e6c9e48ba | 39 | DRESULT disk_ioctl (BYTE, BYTE, void*); |
emh203 | 0:6b1e6c9e48ba | 40 | |
emh203 | 0:6b1e6c9e48ba | 41 | DWORD get_fattime(); |
emh203 | 0:6b1e6c9e48ba | 42 | |
emh203 | 0:6b1e6c9e48ba | 43 | /* Disk Status Bits (DSTATUS) */ |
emh203 | 0:6b1e6c9e48ba | 44 | |
emh203 | 0:6b1e6c9e48ba | 45 | #define STA_NOINIT 0x01 /* Drive not initialized */ |
emh203 | 0:6b1e6c9e48ba | 46 | #define STA_NODISK 0x02 /* No medium in the drive */ |
emh203 | 0:6b1e6c9e48ba | 47 | #define STA_PROTECT 0x04 /* Write protected */ |
emh203 | 0:6b1e6c9e48ba | 48 | |
emh203 | 0:6b1e6c9e48ba | 49 | |
emh203 | 0:6b1e6c9e48ba | 50 | /* Command code for disk_ioctrl fucntion */ |
emh203 | 0:6b1e6c9e48ba | 51 | |
emh203 | 0:6b1e6c9e48ba | 52 | /* Generic command (defined for FatFs) */ |
emh203 | 0:6b1e6c9e48ba | 53 | #define CTRL_SYNC 0 /* Flush disk cache (for write functions) */ |
emh203 | 0:6b1e6c9e48ba | 54 | #define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */ |
emh203 | 0:6b1e6c9e48ba | 55 | #define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */ |
emh203 | 0:6b1e6c9e48ba | 56 | #define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */ |
emh203 | 0:6b1e6c9e48ba | 57 | #define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */ |
emh203 | 0:6b1e6c9e48ba | 58 | |
emh203 | 0:6b1e6c9e48ba | 59 | /* Generic command */ |
emh203 | 0:6b1e6c9e48ba | 60 | #define CTRL_POWER 5 /* Get/Set power status */ |
emh203 | 0:6b1e6c9e48ba | 61 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */ |
emh203 | 0:6b1e6c9e48ba | 62 | #define CTRL_EJECT 7 /* Eject media */ |
emh203 | 0:6b1e6c9e48ba | 63 | |
emh203 | 0:6b1e6c9e48ba | 64 | /* MMC/SDC specific ioctl command */ |
emh203 | 0:6b1e6c9e48ba | 65 | #define MMC_GET_TYPE 10 /* Get card type */ |
emh203 | 0:6b1e6c9e48ba | 66 | #define MMC_GET_CSD 11 /* Get CSD */ |
emh203 | 0:6b1e6c9e48ba | 67 | #define MMC_GET_CID 12 /* Get CID */ |
emh203 | 0:6b1e6c9e48ba | 68 | #define MMC_GET_OCR 13 /* Get OCR */ |
emh203 | 0:6b1e6c9e48ba | 69 | #define MMC_GET_SDSTAT 14 /* Get SD status */ |
emh203 | 0:6b1e6c9e48ba | 70 | |
emh203 | 0:6b1e6c9e48ba | 71 | /* ATA/CF specific ioctl command */ |
emh203 | 0:6b1e6c9e48ba | 72 | #define ATA_GET_REV 20 /* Get F/W revision */ |
emh203 | 0:6b1e6c9e48ba | 73 | #define ATA_GET_MODEL 21 /* Get model name */ |
emh203 | 0:6b1e6c9e48ba | 74 | #define ATA_GET_SN 22 /* Get serial number */ |
emh203 | 0:6b1e6c9e48ba | 75 | |
emh203 | 0:6b1e6c9e48ba | 76 | /* NAND specific ioctl command */ |
emh203 | 0:6b1e6c9e48ba | 77 | #define NAND_FORMAT 30 /* Create physical format */ |
emh203 | 0:6b1e6c9e48ba | 78 | |
emh203 | 0:6b1e6c9e48ba | 79 | |
emh203 | 1:dc171f34db9b | 80 | //Available Drives |
emh203 | 1:dc171f34db9b | 81 | #define CF 0 |
emh203 | 1:dc171f34db9b | 82 | #define COMPACT_FLASH CF |
emh203 | 1:dc171f34db9b | 83 | #define USB 1 |
emh203 | 1:dc171f34db9b | 84 | #define RAM 2 |
emh203 | 1:dc171f34db9b | 85 | |
emh203 | 0:6b1e6c9e48ba | 86 | #define _DISKIO |
emh203 | 0:6b1e6c9e48ba | 87 | #endif |