CARME-M4 BSP  V1.5
diskio.h
1 #ifndef _DISKIO_DEFINED
2 #define _DISKIO_DEFINED
3 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif /* __cplusplus */
47 
48 /*----- Header-Files -------------------------------------------------------*/
49 #include "integer.h"
50 
51 /*----- Macros -------------------------------------------------------------*/
52 #define _USE_WRITE 1
53 #define _USE_IOCTL 1
55 /* Disk Status Bits (DSTATUS) */
56 #define STA_NOINIT 0x01
57 #define STA_NODISK 0x02
58 #define STA_PROTECT 0x04
60 /* Command code for disk_ioctrl fucntion */
61 
62 /* Generic command (used by FatFs) */
63 #define CTRL_SYNC 0
64 #define GET_SECTOR_COUNT 1
65 #define GET_SECTOR_SIZE 2
67 #define GET_BLOCK_SIZE 3
69 #define CTRL_ERASE_SECTOR 4
72 /* Generic command (not used by FatFs) */
73 #define CTRL_POWER 5
74 #define CTRL_LOCK 6
75 #define CTRL_EJECT 7
76 #define CTRL_FORMAT 8
78 /* MMC/SDC specific ioctl command */
79 #define MMC_GET_TYPE 10
80 #define MMC_GET_CSD 11
81 #define MMC_GET_CID 12
82 #define MMC_GET_OCR 13
83 #define MMC_GET_SDSTAT 14
85 /* ATA/CF specific ioctl command */
86 #define ATA_GET_REV 20
87 #define ATA_GET_MODEL 21
88 #define ATA_GET_SN 22
91 /* MMC card type flags (MMC_GET_TYPE) */
92 #define CT_MMC 0x01
93 #define CT_SD1 0x02
94 #define CT_SD2 0x04
95 #define CT_SDC (CT_SD1|CT_SD2)
96 #define CT_BLOCK 0x08
98 /*----- Data types ---------------------------------------------------------*/
99 
103 typedef BYTE DSTATUS;
104 
109 typedef enum {
110  RES_OK = 0,
111  RES_ERROR,
117 /*----- Function prototypes ------------------------------------------------*/
118 DSTATUS disk_initialize (BYTE drv);
119 DSTATUS disk_status (BYTE drv);
120 DRESULT disk_read (BYTE drv, BYTE*buff, DWORD sector, UINT count);
121 #if _USE_WRITE
122 DRESULT disk_write(BYTE drv, const BYTE *buff, DWORD sector, BYTE count);
123 #endif /* _USE_WRITE */
124 #if _USE_IOCTL
125 DRESULT disk_ioctl (BYTE drv, BYTE cmd, void* buff);
126 #endif /* _USE_IOCTL */
127 
128 /*----- Data ---------------------------------------------------------------*/
129 
130 /*----- Implementation -----------------------------------------------------*/
131 
132 #ifdef __cplusplus
133 }
134 #endif /* __cplusplus */
135 
141 #endif /* _DISKIO_DEFINED */
DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, UINT count)
Read from the SD Card.
Definition: diskio.c:127
DRESULT
Results of Disk Functions.
Definition: diskio.h:112
Definition: diskio.h:113
BYTE DSTATUS
Status of Disk Functions.
Definition: diskio.h:106
DSTATUS disk_status(BYTE drv)
Return disk status.
Definition: diskio.c:103
DSTATUS disk_initialize(BYTE drv)
Initialize the SD Card Returns the disk status.
Definition: diskio.c:71