+/*-----------------------------------------------------------------------*/\r
+/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2016 */\r
+/*-----------------------------------------------------------------------*/\r
+/* If a working storage control module is available, it should be */\r
+/* attached to the FatFs via a glue function rather than modifying it. */\r
+/* This is an example of glue functions to attach various exsisting */\r
+/* storage control modules to the FatFs module with a defined API. */\r
+/*-----------------------------------------------------------------------*/\r
+\r
+#include "diskio.h" /* FatFs lower layer API */\r
+\r
+/* Definitions of physical drive number for each drive */\r
+#define DEV_RAM 0 /* Example: Map Ramdisk to physical drive 0 */\r
+#define DEV_MMC 1 /* Example: Map MMC/SD card to physical drive 1 */\r
+#define DEV_USB 2 /* Example: Map USB MSD to physical drive 2 */\r
+\r
+\r
+/*-----------------------------------------------------------------------*/\r
+/* Get Drive Status */\r
+/*-----------------------------------------------------------------------*/\r
+\r
+DSTATUS disk_status (\r
+ BYTE pdrv /* Physical drive nmuber to identify the drive */\r
+)\r
+{\r
+ DSTATUS stat;\r
+ int result;\r
+\r
+ switch (pdrv) {\r
+ case DEV_RAM :\r
+ result = RAM_disk_status();\r
+\r
+ // translate the reslut code here\r
+\r
+ return stat;\r
+\r
+ case DEV_MMC :\r
+ result = MMC_disk_status();\r
+\r
+ // translate the reslut code here\r
+\r
+ return stat;\r
+\r
+ case DEV_USB :\r
+ result = USB_disk_status();\r
+\r
+ // translate the reslut code here\r
+\r
+ return stat;\r
+ }\r
+ return STA_NOINIT;\r
+}\r
+\r
+\r
+\r
+/*-----------------------------------------------------------------------*/\r
+/* Inidialize a Drive */\r
+/*-----------------------------------------------------------------------*/\r
+\r
+DSTATUS disk_initialize (\r
+ BYTE pdrv /* Physical drive nmuber to identify the drive */\r
+)\r
+{\r
+ DSTATUS stat;\r
+ int result;\r
+\r
+ switch (pdrv) {\r
+ case DEV_RAM :\r
+ result = RAM_disk_initialize();\r
+\r
+ // translate the reslut code here\r
+\r
+ return stat;\r
+\r
+ case DEV_MMC :\r
+ result = MMC_disk_initialize();\r
+\r
+ // translate the reslut code here\r
+\r
+ return stat;\r
+\r
+ case DEV_USB :\r
+ result = USB_disk_initialize();\r
+\r
+ // translate the reslut code here\r
+\r
+ return stat;\r
+ }\r
+ return STA_NOINIT;\r
+}\r
+\r
+\r
+\r
+/*-----------------------------------------------------------------------*/\r
+/* Read Sector(s) */\r
+/*-----------------------------------------------------------------------*/\r
+\r
+DRESULT disk_read (\r
+ BYTE pdrv, /* Physical drive nmuber to identify the drive */\r
+ BYTE *buff, /* Data buffer to store read data */\r
+ DWORD sector, /* Start sector in LBA */\r
+ UINT count /* Number of sectors to read */\r
+)\r
+{\r
+ DRESULT res;\r
+ int result;\r
+\r
+ switch (pdrv) {\r
+ case DEV_RAM :\r
+ // translate the arguments here\r
+\r
+ result = RAM_disk_read(buff, sector, count);\r
+\r
+ // translate the reslut code here\r
+\r
+ return res;\r
+\r
+ case DEV_MMC :\r
+ // translate the arguments here\r
+\r
+ result = MMC_disk_read(buff, sector, count);\r
+\r
+ // translate the reslut code here\r
+\r
+ return res;\r
+\r
+ case DEV_USB :\r
+ // translate the arguments here\r
+\r
+ result = USB_disk_read(buff, sector, count);\r
+\r
+ // translate the reslut code here\r
+\r
+ return res;\r
+ }\r
+\r
+ return RES_PARERR;\r
+}\r
+\r
+\r
+\r
+/*-----------------------------------------------------------------------*/\r
+/* Write Sector(s) */\r
+/*-----------------------------------------------------------------------*/\r
+\r
+DRESULT disk_write (\r
+ BYTE pdrv, /* Physical drive nmuber to identify the drive */\r
+ const BYTE *buff, /* Data to be written */\r
+ DWORD sector, /* Start sector in LBA */\r
+ UINT count /* Number of sectors to write */\r
+)\r
+{\r
+ DRESULT res;\r
+ int result;\r
+\r
+ switch (pdrv) {\r
+ case DEV_RAM :\r
+ // translate the arguments here\r
+\r
+ result = RAM_disk_write(buff, sector, count);\r
+\r
+ // translate the reslut code here\r
+\r
+ return res;\r
+\r
+ case DEV_MMC :\r
+ // translate the arguments here\r
+\r
+ result = MMC_disk_write(buff, sector, count);\r
+\r
+ // translate the reslut code here\r
+\r
+ return res;\r
+\r
+ case DEV_USB :\r
+ // translate the arguments here\r
+\r
+ result = USB_disk_write(buff, sector, count);\r
+\r
+ // translate the reslut code here\r
+\r
+ return res;\r
+ }\r
+\r
+ return RES_PARERR;\r
+}\r
+\r
+\r
+\r
+/*-----------------------------------------------------------------------*/\r
+/* Miscellaneous Functions */\r
+/*-----------------------------------------------------------------------*/\r
+\r
+DRESULT disk_ioctl (\r
+ BYTE pdrv, /* Physical drive nmuber (0..) */\r
+ BYTE cmd, /* Control code */\r
+ void *buff /* Buffer to send/receive control data */\r
+)\r
+{\r
+ DRESULT res;\r
+ int result;\r
+\r
+ switch (pdrv) {\r
+ case DEV_RAM :\r
+\r
+ // Process of the command for the RAM drive\r
+\r
+ return res;\r
+\r
+ case DEV_MMC :\r
+\r
+ // Process of the command for the MMC/SD card\r
+\r
+ return res;\r
+\r
+ case DEV_USB :\r
+\r
+ // Process of the command the USB drive\r
+\r
+ return res;\r
+ }\r
+\r
+ return RES_PARERR;\r
+}\r
+\r