]>
cloudbase.mooo.com Git - z180-stamp.git/blob - fatfs/source/diskio.c
1 /*-----------------------------------------------------------------------*/
2 /* Low level disk I/O module SKELETON for FatFs (C)ChaN, 2019 */
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 "ff.h" /* Obtains integer types */
11 #include "diskio.h" /* Declarations of disk functions */
13 /* Definitions of physical drive number for each drive */
14 #define DEV_RAM 0 /* Example: Map Ramdisk to physical drive 0 */
15 #define DEV_MMC 1 /* Example: Map MMC/SD card to physical drive 1 */
16 #define DEV_USB 2 /* Example: Map USB MSD to physical drive 2 */
19 /*-----------------------------------------------------------------------*/
20 /* Get Drive Status */
21 /*-----------------------------------------------------------------------*/
24 BYTE pdrv
/* Physical drive nmuber to identify the drive */
32 result
= RAM_disk_status();
34 // translate the reslut code here
39 result
= MMC_disk_status();
41 // translate the reslut code here
46 result
= USB_disk_status();
48 // translate the reslut code here
57 /*-----------------------------------------------------------------------*/
58 /* Inidialize a Drive */
59 /*-----------------------------------------------------------------------*/
61 DSTATUS
disk_initialize (
62 BYTE pdrv
/* Physical drive nmuber to identify the drive */
70 result
= RAM_disk_initialize();
72 // translate the reslut code here
77 result
= MMC_disk_initialize();
79 // translate the reslut code here
84 result
= USB_disk_initialize();
86 // translate the reslut code here
95 /*-----------------------------------------------------------------------*/
97 /*-----------------------------------------------------------------------*/
100 BYTE pdrv
, /* Physical drive nmuber to identify the drive */
101 BYTE
*buff
, /* Data buffer to store read data */
102 LBA_t sector
, /* Start sector in LBA */
103 UINT count
/* Number of sectors to read */
111 // translate the arguments here
113 result
= RAM_disk_read(buff
, sector
, count
);
115 // translate the reslut code here
120 // translate the arguments here
122 result
= MMC_disk_read(buff
, sector
, count
);
124 // translate the reslut code here
129 // translate the arguments here
131 result
= USB_disk_read(buff
, sector
, count
);
133 // translate the reslut code here
143 /*-----------------------------------------------------------------------*/
144 /* Write Sector(s) */
145 /*-----------------------------------------------------------------------*/
147 #if FF_FS_READONLY == 0
150 BYTE pdrv
, /* Physical drive nmuber to identify the drive */
151 const BYTE
*buff
, /* Data to be written */
152 LBA_t sector
, /* Start sector in LBA */
153 UINT count
/* Number of sectors to write */
161 // translate the arguments here
163 result
= RAM_disk_write(buff
, sector
, count
);
165 // translate the reslut code here
170 // translate the arguments here
172 result
= MMC_disk_write(buff
, sector
, count
);
174 // translate the reslut code here
179 // translate the arguments here
181 result
= USB_disk_write(buff
, sector
, count
);
183 // translate the reslut code here
194 /*-----------------------------------------------------------------------*/
195 /* Miscellaneous Functions */
196 /*-----------------------------------------------------------------------*/
199 BYTE pdrv
, /* Physical drive nmuber (0..) */
200 BYTE cmd
, /* Control code */
201 void *buff
/* Buffer to send/receive control data */
210 // Process of the command for the RAM drive
216 // Process of the command for the MMC/SD card
222 // Process of the command the USB drive