]>
cloudbase.mooo.com Git - z180-stamp.git/blob - fatfs/src/diskio.c
1 /*-----------------------------------------------------------------------*/
2 /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */
3 /*-----------------------------------------------------------------------*/
4 /* If a working storage control module is available, it should be */
5 /* attached to the FatFs via a glue function rather than modifying it. */
6 /* This is an example of glue functions to attach various exsisting */
7 /* storage control modules to the FatFs module with a defined API. */
8 /*-----------------------------------------------------------------------*/
10 #include "diskio.h" /* FatFs lower layer API */
11 #include "usbdisk.h" /* Example: USB drive control */
12 #include "atadrive.h" /* Example: ATA drive control */
13 #include "sdcard.h" /* Example: MMC/SDC contorl */
15 /* Definitions of physical drive number for each drive */
16 #define ATA 0 /* Example: Map ATA drive to drive number 0 */
17 #define MMC 1 /* Example: Map MMC/SD card to drive number 1 */
18 #define USB 2 /* Example: Map USB drive to drive number 2 */
21 /*-----------------------------------------------------------------------*/
22 /* Get Drive Status */
23 /*-----------------------------------------------------------------------*/
26 BYTE pdrv
/* Physical drive nmuber to identify the drive */
34 result
= ATA_disk_status();
36 // translate the reslut code here
41 result
= MMC_disk_status();
43 // translate the reslut code here
48 result
= USB_disk_status();
50 // translate the reslut code here
59 /*-----------------------------------------------------------------------*/
60 /* Inidialize a Drive */
61 /*-----------------------------------------------------------------------*/
63 DSTATUS
disk_initialize (
64 BYTE pdrv
/* Physical drive nmuber to identify the drive */
72 result
= ATA_disk_initialize();
74 // translate the reslut code here
79 result
= MMC_disk_initialize();
81 // translate the reslut code here
86 result
= USB_disk_initialize();
88 // translate the reslut code here
97 /*-----------------------------------------------------------------------*/
99 /*-----------------------------------------------------------------------*/
102 BYTE pdrv
, /* Physical drive nmuber to identify the drive */
103 BYTE
*buff
, /* Data buffer to store read data */
104 DWORD sector
, /* Sector address in LBA */
105 UINT count
/* Number of sectors to read */
113 // translate the arguments here
115 result
= ATA_disk_read(buff
, sector
, count
);
117 // translate the reslut code here
122 // translate the arguments here
124 result
= MMC_disk_read(buff
, sector
, count
);
126 // translate the reslut code here
131 // translate the arguments here
133 result
= USB_disk_read(buff
, sector
, count
);
135 // translate the reslut code here
145 /*-----------------------------------------------------------------------*/
146 /* Write Sector(s) */
147 /*-----------------------------------------------------------------------*/
151 BYTE pdrv
, /* Physical drive nmuber to identify the drive */
152 const BYTE
*buff
, /* Data to be written */
153 DWORD sector
, /* Sector address in LBA */
154 UINT count
/* Number of sectors to write */
162 // translate the arguments here
164 result
= ATA_disk_write(buff
, sector
, count
);
166 // translate the reslut code here
171 // translate the arguments here
173 result
= MMC_disk_write(buff
, sector
, count
);
175 // translate the reslut code here
180 // translate the arguments here
182 result
= USB_disk_write(buff
, sector
, count
);
184 // translate the reslut code here
194 /*-----------------------------------------------------------------------*/
195 /* Miscellaneous Functions */
196 /*-----------------------------------------------------------------------*/
200 BYTE pdrv
, /* Physical drive nmuber (0..) */
201 BYTE cmd
, /* Control code */
202 void *buff
/* Buffer to send/receive control data */
211 // Process of the command for the ATA drive
217 // Process of the command for the MMC/SD card
223 // Process of the command the USB drive