X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/5366852335044c1e68a5c32548d3051cc943552f..b4e3fab85fcd9f5b1502ec991c81302b910492d3:/fatfs/src/diskio.c?ds=sidebyside diff --git a/fatfs/src/diskio.c b/fatfs/src/diskio.c index 64194eb..25f5e53 100644 --- a/fatfs/src/diskio.c +++ b/fatfs/src/diskio.c @@ -1,51 +1,48 @@ /*-----------------------------------------------------------------------*/ -/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2013 */ +/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2016 */ /*-----------------------------------------------------------------------*/ /* If a working storage control module is available, it should be */ /* attached to the FatFs via a glue function rather than modifying it. */ /* This is an example of glue functions to attach various exsisting */ -/* storage control module to the FatFs module with a defined API. */ +/* storage control modules to the FatFs module with a defined API. */ /*-----------------------------------------------------------------------*/ #include "diskio.h" /* FatFs lower layer API */ -#include "usbdisk.h" /* Example: USB drive control */ -#include "atadrive.h" /* Example: ATA drive control */ -#include "sdcard.h" /* Example: MMC/SDC contorl */ -/* Definitions of physical drive number for each media */ -#define ATA 0 -#define MMC 1 -#define USB 2 +/* Definitions of physical drive number for each drive */ +#define DEV_RAM 0 /* Example: Map Ramdisk to physical drive 0 */ +#define DEV_MMC 1 /* Example: Map MMC/SD card to physical drive 1 */ +#define DEV_USB 2 /* Example: Map USB MSD to physical drive 2 */ /*-----------------------------------------------------------------------*/ -/* Inidialize a Drive */ +/* Get Drive Status */ /*-----------------------------------------------------------------------*/ -DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber (0..) */ +DSTATUS disk_status ( + BYTE pdrv /* Physical drive nmuber to identify the drive */ ) { DSTATUS stat; int result; switch (pdrv) { - case ATA : - result = ATA_disk_initialize(); + case DEV_RAM : + result = RAM_disk_status(); // translate the reslut code here return stat; - case MMC : - result = MMC_disk_initialize(); + case DEV_MMC : + result = MMC_disk_status(); // translate the reslut code here return stat; - case USB : - result = USB_disk_initialize(); + case DEV_USB : + result = USB_disk_status(); // translate the reslut code here @@ -57,33 +54,33 @@ DSTATUS disk_initialize ( /*-----------------------------------------------------------------------*/ -/* Get Disk Status */ +/* Inidialize a Drive */ /*-----------------------------------------------------------------------*/ -DSTATUS disk_status ( - BYTE pdrv /* Physical drive nmuber (0..) */ +DSTATUS disk_initialize ( + BYTE pdrv /* Physical drive nmuber to identify the drive */ ) { DSTATUS stat; int result; switch (pdrv) { - case ATA : - result = ATA_disk_status(); + case DEV_RAM : + result = RAM_disk_initialize(); // translate the reslut code here return stat; - case MMC : - result = MMC_disk_status(); + case DEV_MMC : + result = MMC_disk_initialize(); // translate the reslut code here return stat; - case USB : - result = USB_disk_status(); + case DEV_USB : + result = USB_disk_initialize(); // translate the reslut code here @@ -99,26 +96,26 @@ DSTATUS disk_status ( /*-----------------------------------------------------------------------*/ DRESULT disk_read ( - BYTE pdrv, /* Physical drive nmuber (0..) */ + BYTE pdrv, /* Physical drive nmuber to identify the drive */ BYTE *buff, /* Data buffer to store read data */ - DWORD sector, /* Sector address (LBA) */ - UINT count /* Number of sectors to read (1..128) */ + DWORD sector, /* Start sector in LBA */ + UINT count /* Number of sectors to read */ ) { DRESULT res; int result; switch (pdrv) { - case ATA : + case DEV_RAM : // translate the arguments here - result = ATA_disk_read(buff, sector, count); + result = RAM_disk_read(buff, sector, count); // translate the reslut code here return res; - case MMC : + case DEV_MMC : // translate the arguments here result = MMC_disk_read(buff, sector, count); @@ -127,7 +124,7 @@ DRESULT disk_read ( return res; - case USB : + case DEV_USB : // translate the arguments here result = USB_disk_read(buff, sector, count); @@ -136,6 +133,7 @@ DRESULT disk_read ( return res; } + return RES_PARERR; } @@ -145,28 +143,27 @@ DRESULT disk_read ( /* Write Sector(s) */ /*-----------------------------------------------------------------------*/ -#if _USE_WRITE DRESULT disk_write ( - BYTE pdrv, /* Physical drive nmuber (0..) */ + BYTE pdrv, /* Physical drive nmuber to identify the drive */ const BYTE *buff, /* Data to be written */ - DWORD sector, /* Sector address (LBA) */ - UINT count /* Number of sectors to write (1..128) */ + DWORD sector, /* Start sector in LBA */ + UINT count /* Number of sectors to write */ ) { DRESULT res; int result; switch (pdrv) { - case ATA : + case DEV_RAM : // translate the arguments here - result = ATA_disk_write(buff, sector, count); + result = RAM_disk_write(buff, sector, count); // translate the reslut code here return res; - case MMC : + case DEV_MMC : // translate the arguments here result = MMC_disk_write(buff, sector, count); @@ -175,7 +172,7 @@ DRESULT disk_write ( return res; - case USB : + case DEV_USB : // translate the arguments here result = USB_disk_write(buff, sector, count); @@ -184,16 +181,16 @@ DRESULT disk_write ( return res; } + return RES_PARERR; } -#endif + /*-----------------------------------------------------------------------*/ /* Miscellaneous Functions */ /*-----------------------------------------------------------------------*/ -#if _USE_IOCTL DRESULT disk_ioctl ( BYTE pdrv, /* Physical drive nmuber (0..) */ BYTE cmd, /* Control code */ @@ -204,33 +201,25 @@ DRESULT disk_ioctl ( int result; switch (pdrv) { - case ATA : - // pre-process here + case DEV_RAM : - result = ATA_disk_ioctl(cmd, buff); - - // post-process here + // Process of the command for the RAM drive return res; - case MMC : - // pre-process here - - result = MMC_disk_ioctl(cmd, buff); + case DEV_MMC : - // post-process here + // Process of the command for the MMC/SD card return res; - case USB : - // pre-process here - - result = USB_disk_ioctl(cmd, buff); + case DEV_USB : - // post-process here + // Process of the command the USB drive return res; } + return RES_PARERR; } -#endif +