This program is an example of of using the MSCUSBHost code with a raw build of ELM Chan Fat Fs. This was done to add both Long File Name Support along with proper time/date stamps (assuming you have a battery hooked up to keep time). This code exposes the Chan API (see main.cpp) and is NOT a c++ class: http://elm-chan.org/fsw/ff/00index_e.html The diskio.c file has the mapping needed to link the filesystem to the MSC stuff

Dependencies:   mbed

Committer:
emh203
Date:
Sun Jan 23 18:35:43 2011 +0000
Revision:
0:2dbbafe1b1fb
1st test version.   Test with raw mbed and Samtec USB-RA type A connector wired directly to pins.

Who changed what in which revision?

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