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