FATFileSystem fork with fixes
Fork of FATFileSystem by
Diff: ChaN/diskio.cpp
- Revision:
- 6:a5fcdbf92056
- Parent:
- 5:b3b3370574cf
--- a/ChaN/diskio.cpp Thu Aug 13 10:15:39 2015 +0100 +++ b/ChaN/diskio.cpp Thu Nov 26 13:30:57 2015 +0000 @@ -1,38 +1,51 @@ /*-----------------------------------------------------------------------*/ -/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2007 */ +/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */ /*-----------------------------------------------------------------------*/ -/* This is a stub disk I/O module that acts as front end of the existing */ -/* disk I/O modules and attach it to FatFs module with common interface. */ +/* 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 modules to the FatFs module with a defined API. */ /*-----------------------------------------------------------------------*/ -#include "ffconf.h" + #include "diskio.h" - #include "mbed_debug.h" #include "FATFileSystem.h" using namespace mbed; +/*-----------------------------------------------------------------------*/ +/* Get Drive Status */ +/*-----------------------------------------------------------------------*/ + +DSTATUS disk_status ( + BYTE pdrv /* Physical drive nmuber to identify the drive */ +) +{ + debug_if(FFS_DBG, "disk_status on pdrv [%d]\n", pdrv); + return (DSTATUS)FATFileSystem::_ffs[pdrv]->disk_status(); +} + +/*-----------------------------------------------------------------------*/ +/* Inidialize a Drive */ +/*-----------------------------------------------------------------------*/ + DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive number (0..) */ + BYTE pdrv /* Physical drive nmuber to identify the drive */ ) { debug_if(FFS_DBG, "disk_initialize on pdrv [%d]\n", pdrv); return (DSTATUS)FATFileSystem::_ffs[pdrv]->disk_initialize(); } -DSTATUS disk_status ( - BYTE pdrv /* Physical drive number (0..) */ -) -{ - debug_if(FFS_DBG, "disk_status on pdrv [%d]\n", pdrv); - return (DSTATUS)FATFileSystem::_ffs[pdrv]->disk_status(); -} +/*-----------------------------------------------------------------------*/ +/* Read Sector(s) */ +/*-----------------------------------------------------------------------*/ DRESULT disk_read ( - BYTE pdrv, /* Physical drive number (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..) */ + DWORD sector, /* Sector address in LBA */ + UINT count /* Number of sectors to read */ ) { debug_if(FFS_DBG, "disk_read(sector %d, count %d) on pdrv [%d]\n", sector, count, pdrv); @@ -42,12 +55,16 @@ return RES_OK; } -#if _READONLY == 0 +/*-----------------------------------------------------------------------*/ +/* Write Sector(s) */ +/*-----------------------------------------------------------------------*/ + +#if _USE_WRITE DRESULT disk_write ( - BYTE pdrv, /* Physical drive number (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..) */ + DWORD sector, /* Sector address in LBA */ + UINT count /* Number of sectors to write */ ) { debug_if(FFS_DBG, "disk_write(sector %d, count %d) on pdrv [%d]\n", sector, count, pdrv); @@ -56,10 +73,15 @@ else return RES_OK; } -#endif /* _READONLY */ +#endif +/*-----------------------------------------------------------------------*/ +/* Miscellaneous Functions */ +/*-----------------------------------------------------------------------*/ + +#if _USE_IOCTL DRESULT disk_ioctl ( - BYTE pdrv, /* Physical drive number (0..) */ + BYTE pdrv, /* Physical drive nmuber (0..) */ BYTE cmd, /* Control code */ void* buff /* Buffer to send/receive control data */ ) @@ -92,3 +114,4 @@ } return RES_PARERR; } +#endif