]> cloudbase.mooo.com Git - z180-stamp.git/blame_incremental - fatfs/source/diskio.c
Import fatfs R0.13b
[z180-stamp.git] / fatfs / source / diskio.c
... / ...
CommitLineData
1/*-----------------------------------------------------------------------*/\r
2/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2016 */\r
3/*-----------------------------------------------------------------------*/\r
4/* If a working storage control module is available, it should be */\r
5/* attached to the FatFs via a glue function rather than modifying it. */\r
6/* This is an example of glue functions to attach various exsisting */\r
7/* storage control modules to the FatFs module with a defined API. */\r
8/*-----------------------------------------------------------------------*/\r
9\r
10#include "diskio.h" /* FatFs lower layer API */\r
11\r
12/* Definitions of physical drive number for each drive */\r
13#define DEV_RAM 0 /* Example: Map Ramdisk to physical drive 0 */\r
14#define DEV_MMC 1 /* Example: Map MMC/SD card to physical drive 1 */\r
15#define DEV_USB 2 /* Example: Map USB MSD to physical drive 2 */\r
16\r
17\r
18/*-----------------------------------------------------------------------*/\r
19/* Get Drive Status */\r
20/*-----------------------------------------------------------------------*/\r
21\r
22DSTATUS disk_status (\r
23 BYTE pdrv /* Physical drive nmuber to identify the drive */\r
24)\r
25{\r
26 DSTATUS stat;\r
27 int result;\r
28\r
29 switch (pdrv) {\r
30 case DEV_RAM :\r
31 result = RAM_disk_status();\r
32\r
33 // translate the reslut code here\r
34\r
35 return stat;\r
36\r
37 case DEV_MMC :\r
38 result = MMC_disk_status();\r
39\r
40 // translate the reslut code here\r
41\r
42 return stat;\r
43\r
44 case DEV_USB :\r
45 result = USB_disk_status();\r
46\r
47 // translate the reslut code here\r
48\r
49 return stat;\r
50 }\r
51 return STA_NOINIT;\r
52}\r
53\r
54\r
55\r
56/*-----------------------------------------------------------------------*/\r
57/* Inidialize a Drive */\r
58/*-----------------------------------------------------------------------*/\r
59\r
60DSTATUS disk_initialize (\r
61 BYTE pdrv /* Physical drive nmuber to identify the drive */\r
62)\r
63{\r
64 DSTATUS stat;\r
65 int result;\r
66\r
67 switch (pdrv) {\r
68 case DEV_RAM :\r
69 result = RAM_disk_initialize();\r
70\r
71 // translate the reslut code here\r
72\r
73 return stat;\r
74\r
75 case DEV_MMC :\r
76 result = MMC_disk_initialize();\r
77\r
78 // translate the reslut code here\r
79\r
80 return stat;\r
81\r
82 case DEV_USB :\r
83 result = USB_disk_initialize();\r
84\r
85 // translate the reslut code here\r
86\r
87 return stat;\r
88 }\r
89 return STA_NOINIT;\r
90}\r
91\r
92\r
93\r
94/*-----------------------------------------------------------------------*/\r
95/* Read Sector(s) */\r
96/*-----------------------------------------------------------------------*/\r
97\r
98DRESULT disk_read (\r
99 BYTE pdrv, /* Physical drive nmuber to identify the drive */\r
100 BYTE *buff, /* Data buffer to store read data */\r
101 DWORD sector, /* Start sector in LBA */\r
102 UINT count /* Number of sectors to read */\r
103)\r
104{\r
105 DRESULT res;\r
106 int result;\r
107\r
108 switch (pdrv) {\r
109 case DEV_RAM :\r
110 // translate the arguments here\r
111\r
112 result = RAM_disk_read(buff, sector, count);\r
113\r
114 // translate the reslut code here\r
115\r
116 return res;\r
117\r
118 case DEV_MMC :\r
119 // translate the arguments here\r
120\r
121 result = MMC_disk_read(buff, sector, count);\r
122\r
123 // translate the reslut code here\r
124\r
125 return res;\r
126\r
127 case DEV_USB :\r
128 // translate the arguments here\r
129\r
130 result = USB_disk_read(buff, sector, count);\r
131\r
132 // translate the reslut code here\r
133\r
134 return res;\r
135 }\r
136\r
137 return RES_PARERR;\r
138}\r
139\r
140\r
141\r
142/*-----------------------------------------------------------------------*/\r
143/* Write Sector(s) */\r
144/*-----------------------------------------------------------------------*/\r
145\r
146DRESULT disk_write (\r
147 BYTE pdrv, /* Physical drive nmuber to identify the drive */\r
148 const BYTE *buff, /* Data to be written */\r
149 DWORD sector, /* Start sector in LBA */\r
150 UINT count /* Number of sectors to write */\r
151)\r
152{\r
153 DRESULT res;\r
154 int result;\r
155\r
156 switch (pdrv) {\r
157 case DEV_RAM :\r
158 // translate the arguments here\r
159\r
160 result = RAM_disk_write(buff, sector, count);\r
161\r
162 // translate the reslut code here\r
163\r
164 return res;\r
165\r
166 case DEV_MMC :\r
167 // translate the arguments here\r
168\r
169 result = MMC_disk_write(buff, sector, count);\r
170\r
171 // translate the reslut code here\r
172\r
173 return res;\r
174\r
175 case DEV_USB :\r
176 // translate the arguments here\r
177\r
178 result = USB_disk_write(buff, sector, count);\r
179\r
180 // translate the reslut code here\r
181\r
182 return res;\r
183 }\r
184\r
185 return RES_PARERR;\r
186}\r
187\r
188\r
189\r
190/*-----------------------------------------------------------------------*/\r
191/* Miscellaneous Functions */\r
192/*-----------------------------------------------------------------------*/\r
193\r
194DRESULT disk_ioctl (\r
195 BYTE pdrv, /* Physical drive nmuber (0..) */\r
196 BYTE cmd, /* Control code */\r
197 void *buff /* Buffer to send/receive control data */\r
198)\r
199{\r
200 DRESULT res;\r
201 int result;\r
202\r
203 switch (pdrv) {\r
204 case DEV_RAM :\r
205\r
206 // Process of the command for the RAM drive\r
207\r
208 return res;\r
209\r
210 case DEV_MMC :\r
211\r
212 // Process of the command for the MMC/SD card\r
213\r
214 return res;\r
215\r
216 case DEV_USB :\r
217\r
218 // Process of the command the USB drive\r
219\r
220 return res;\r
221 }\r
222\r
223 return RES_PARERR;\r
224}\r
225\r