Library for SD card

Dependents:   City_Game_JSON saver-noenvio-1 SNOCC_V2 lab7_prog1 ... more

Committer:
AlexVC97
Date:
Wed Mar 29 07:00:22 2017 +0000
Revision:
0:3bdfc1556537
SDFileSystem Library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AlexVC97 0:3bdfc1556537 1 /*-----------------------------------------------------------------------/
AlexVC97 0:3bdfc1556537 2 / Low level disk interface modlue include file (C)ChaN, 2014 /
AlexVC97 0:3bdfc1556537 3 /-----------------------------------------------------------------------*/
AlexVC97 0:3bdfc1556537 4
AlexVC97 0:3bdfc1556537 5 #ifndef _DISKIO_DEFINED
AlexVC97 0:3bdfc1556537 6 #define _DISKIO_DEFINED
AlexVC97 0:3bdfc1556537 7
AlexVC97 0:3bdfc1556537 8 #ifdef __cplusplus
AlexVC97 0:3bdfc1556537 9 extern "C" {
AlexVC97 0:3bdfc1556537 10 #endif
AlexVC97 0:3bdfc1556537 11
AlexVC97 0:3bdfc1556537 12 #define _USE_WRITE 1 /* 1: Enable disk_write function */
AlexVC97 0:3bdfc1556537 13 #define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
AlexVC97 0:3bdfc1556537 14
AlexVC97 0:3bdfc1556537 15 #include "integer.h"
AlexVC97 0:3bdfc1556537 16
AlexVC97 0:3bdfc1556537 17
AlexVC97 0:3bdfc1556537 18 /* Status of Disk Functions */
AlexVC97 0:3bdfc1556537 19 typedef BYTE DSTATUS;
AlexVC97 0:3bdfc1556537 20
AlexVC97 0:3bdfc1556537 21 /* Results of Disk Functions */
AlexVC97 0:3bdfc1556537 22 typedef enum {
AlexVC97 0:3bdfc1556537 23 RES_OK = 0, /* 0: Successful */
AlexVC97 0:3bdfc1556537 24 RES_ERROR, /* 1: R/W Error */
AlexVC97 0:3bdfc1556537 25 RES_WRPRT, /* 2: Write Protected */
AlexVC97 0:3bdfc1556537 26 RES_NOTRDY, /* 3: Not Ready */
AlexVC97 0:3bdfc1556537 27 RES_PARERR /* 4: Invalid Parameter */
AlexVC97 0:3bdfc1556537 28 } DRESULT;
AlexVC97 0:3bdfc1556537 29
AlexVC97 0:3bdfc1556537 30
AlexVC97 0:3bdfc1556537 31 /*---------------------------------------*/
AlexVC97 0:3bdfc1556537 32 /* Prototypes for disk control functions */
AlexVC97 0:3bdfc1556537 33
AlexVC97 0:3bdfc1556537 34
AlexVC97 0:3bdfc1556537 35 DSTATUS disk_initialize (BYTE pdrv);
AlexVC97 0:3bdfc1556537 36 DSTATUS disk_status (BYTE pdrv);
AlexVC97 0:3bdfc1556537 37 DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
AlexVC97 0:3bdfc1556537 38 DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
AlexVC97 0:3bdfc1556537 39 DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
AlexVC97 0:3bdfc1556537 40
AlexVC97 0:3bdfc1556537 41
AlexVC97 0:3bdfc1556537 42 /* Disk Status Bits (DSTATUS) */
AlexVC97 0:3bdfc1556537 43
AlexVC97 0:3bdfc1556537 44 #define STA_NOINIT 0x01 /* Drive not initialized */
AlexVC97 0:3bdfc1556537 45 #define STA_NODISK 0x02 /* No medium in the drive */
AlexVC97 0:3bdfc1556537 46 #define STA_PROTECT 0x04 /* Write protected */
AlexVC97 0:3bdfc1556537 47
AlexVC97 0:3bdfc1556537 48
AlexVC97 0:3bdfc1556537 49 /* Command code for disk_ioctrl fucntion */
AlexVC97 0:3bdfc1556537 50
AlexVC97 0:3bdfc1556537 51 /* Generic command (Used by FatFs) */
AlexVC97 0:3bdfc1556537 52 #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
AlexVC97 0:3bdfc1556537 53 #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
AlexVC97 0:3bdfc1556537 54 #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
AlexVC97 0:3bdfc1556537 55 #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
AlexVC97 0:3bdfc1556537 56 #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
AlexVC97 0:3bdfc1556537 57
AlexVC97 0:3bdfc1556537 58 /* Generic command (Not used by FatFs) */
AlexVC97 0:3bdfc1556537 59 #define CTRL_POWER 5 /* Get/Set power status */
AlexVC97 0:3bdfc1556537 60 #define CTRL_LOCK 6 /* Lock/Unlock media removal */
AlexVC97 0:3bdfc1556537 61 #define CTRL_EJECT 7 /* Eject media */
AlexVC97 0:3bdfc1556537 62 #define CTRL_FORMAT 8 /* Create physical format on the media */
AlexVC97 0:3bdfc1556537 63
AlexVC97 0:3bdfc1556537 64 /* MMC/SDC specific ioctl command */
AlexVC97 0:3bdfc1556537 65 #define MMC_GET_TYPE 10 /* Get card type */
AlexVC97 0:3bdfc1556537 66 #define MMC_GET_CSD 11 /* Get CSD */
AlexVC97 0:3bdfc1556537 67 #define MMC_GET_CID 12 /* Get CID */
AlexVC97 0:3bdfc1556537 68 #define MMC_GET_OCR 13 /* Get OCR */
AlexVC97 0:3bdfc1556537 69 #define MMC_GET_SDSTAT 14 /* Get SD status */
AlexVC97 0:3bdfc1556537 70
AlexVC97 0:3bdfc1556537 71 /* ATA/CF specific ioctl command */
AlexVC97 0:3bdfc1556537 72 #define ATA_GET_REV 20 /* Get F/W revision */
AlexVC97 0:3bdfc1556537 73 #define ATA_GET_MODEL 21 /* Get model name */
AlexVC97 0:3bdfc1556537 74 #define ATA_GET_SN 22 /* Get serial number */
AlexVC97 0:3bdfc1556537 75
AlexVC97 0:3bdfc1556537 76 #ifdef __cplusplus
AlexVC97 0:3bdfc1556537 77 }
AlexVC97 0:3bdfc1556537 78 #endif
AlexVC97 0:3bdfc1556537 79
AlexVC97 0:3bdfc1556537 80 #endif