First working version of a FATFileSystem compatible Chan FAT v0.8 implementation. This is intended to use with long file names and RTOS support. For now long file names work but RTOS support is still untested.

Dependents:   USB_MSC USB_CDC_MSD_Hello TFTPServerTest DMXStation ... more

Committer:
NeoBelerophon
Date:
Tue Feb 01 21:47:45 2011 +0000
Revision:
0:8ea634413549
Inital version

Who changed what in which revision?

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