WILLY BAYOT / stm32_adafruit

Dependents:   TDEMNucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers diskio.h Source File

diskio.h

00001 /*-----------------------------------------------------------------------
00002 /  Low level disk interface modlue include file   (C)ChaN, 2013
00003 /-----------------------------------------------------------------------*/
00004 
00005 #ifndef _DISKIO_DEFINED
00006 #define _DISKIO_DEFINED
00007 
00008 #ifdef __cplusplus
00009 extern "C" {
00010 #endif
00011 
00012 #define _USE_WRITE  1   /* 1: Enable disk_write function */
00013 #define _USE_IOCTL  1   /* 1: Enable disk_ioctl fucntion */
00014 
00015 #include "integer.h"
00016 
00017 
00018 /* Status of Disk Functions */
00019 typedef BYTE    DSTATUS;
00020 
00021 /* Results of Disk Functions */
00022 typedef enum {
00023     RES_OK = 0,     /* 0: Successful */
00024     RES_ERROR,      /* 1: R/W Error */
00025     RES_WRPRT,      /* 2: Write Protected */
00026     RES_NOTRDY,     /* 3: Not Ready */
00027     RES_PARERR      /* 4: Invalid Parameter */
00028 } DRESULT;
00029 
00030 
00031 /*---------------------------------------*/
00032 /* Prototypes for disk control functions */
00033 
00034 
00035 DSTATUS disk_initialize (BYTE pdrv);
00036 DSTATUS disk_status (BYTE pdrv);
00037 DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count);
00038 DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count);
00039 DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
00040 
00041 
00042 /* Disk Status Bits (DSTATUS) */
00043 #define STA_NOINIT      0x01    /* Drive not initialized */
00044 #define STA_NODISK      0x02    /* No medium in the drive */
00045 #define STA_PROTECT     0x04    /* Write protected */
00046 
00047 
00048 /* Command code for disk_ioctrl fucntion */
00049 
00050 /* Generic command (used by FatFs) */
00051 #define CTRL_SYNC           0   /* Flush disk cache (for write functions) */
00052 #define GET_SECTOR_COUNT    1   /* Get media size (for only f_mkfs()) */
00053 #define GET_SECTOR_SIZE     2   /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
00054 #define GET_BLOCK_SIZE      3   /* Get erase block size (for only f_mkfs()) */
00055 #define CTRL_ERASE_SECTOR   4   /* Force erased a block of sectors (for only _USE_ERASE) */
00056 
00057 /* Generic command (not used by FatFs) */
00058 #define CTRL_POWER          5   /* Get/Set power status */
00059 #define CTRL_LOCK           6   /* Lock/Unlock media removal */
00060 #define CTRL_EJECT          7   /* Eject media */
00061 #define CTRL_FORMAT         8   /* Create physical format on the media */
00062 
00063 /* MMC/SDC specific ioctl command */
00064 #define MMC_GET_TYPE        10  /* Get card type */
00065 #define MMC_GET_CSD         11  /* Get CSD */
00066 #define MMC_GET_CID         12  /* Get CID */
00067 #define MMC_GET_OCR         13  /* Get OCR */
00068 #define MMC_GET_SDSTAT      14  /* Get SD status */
00069 
00070 /* ATA/CF specific ioctl command */
00071 #define ATA_GET_REV         20  /* Get F/W revision */
00072 #define ATA_GET_MODEL       21  /* Get model name */
00073 #define ATA_GET_SN          22  /* Get serial number */
00074 
00075 
00076 /* MMC card type flags (MMC_GET_TYPE) */
00077 #define CT_MMC      0x01        /* MMC ver 3 */
00078 #define CT_SD1      0x02        /* SD ver 1 */
00079 #define CT_SD2      0x04        /* SD ver 2 */
00080 #define CT_SDC      (CT_SD1|CT_SD2) /* SD */
00081 #define CT_BLOCK    0x08        /* Block addressing */
00082 
00083 
00084 #ifdef __cplusplus
00085 }
00086 #endif
00087 
00088 #endif
00089