ADAFRUIT CLD & SD lib

Dependents:   TDEMNucleo

Committer:
willybayot
Date:
Mon Jan 05 16:07:19 2015 +0000
Revision:
3:d685bfd3ba5f
Parent:
0:4db361f2e6d5
v

Who changed what in which revision?

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