This is SDFileSystem which corrected the bug for MiMicSDK.
Dependents: MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more
Fork of SDFileSystem by
diskio.cpp
00001 /*-----------------------------------------------------------------------*/ 00002 /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2007 */ 00003 /*-----------------------------------------------------------------------*/ 00004 /* This is a stub disk I/O module that acts as front end of the existing */ 00005 /* disk I/O modules and attach it to FatFs module with common interface. */ 00006 /*-----------------------------------------------------------------------*/ 00007 #include "ffconf.h" 00008 #include "diskio.h" 00009 00010 #include "FATFileSystem.h" 00011 00012 00013 using namespace mbed; 00014 00015 DSTATUS disk_initialize ( 00016 BYTE drv /* Physical drive nmuber (0..) */ 00017 ) 00018 { 00019 return (DSTATUS)FATFileSystem::_ffs[drv]->disk_initialize(); 00020 } 00021 00022 DSTATUS disk_status ( 00023 BYTE drv /* Physical drive nmuber (0..) */ 00024 ) 00025 { 00026 return (DSTATUS)FATFileSystem::_ffs[drv]->disk_status(); 00027 } 00028 00029 DRESULT disk_read ( 00030 BYTE drv, /* Physical drive nmuber (0..) */ 00031 BYTE *buff, /* Data buffer to store read data */ 00032 DWORD sector, /* Sector address (LBA) */ 00033 BYTE count /* Number of sectors to read (1..255) */ 00034 ) 00035 { 00036 for(DWORD s=sector; s<sector+count; s++) { 00037 int res = FATFileSystem::_ffs[drv]->disk_read((uint8_t*)buff, s); 00038 if(res) { 00039 return RES_PARERR; 00040 } 00041 buff += 512; 00042 } 00043 return RES_OK; 00044 } 00045 00046 #if _READONLY == 0 00047 DRESULT disk_write ( 00048 BYTE drv, /* Physical drive nmuber (0..) */ 00049 const BYTE *buff, /* Data to be written */ 00050 DWORD sector, /* Sector address (LBA) */ 00051 BYTE count /* Number of sectors to write (1..255) */ 00052 ) 00053 { 00054 for(DWORD s = sector; s < sector + count; s++) { 00055 int res = FATFileSystem::_ffs[drv]->disk_write((uint8_t*)buff, s); 00056 if(res) { 00057 return RES_PARERR; 00058 } 00059 buff += 512; 00060 } 00061 return RES_OK; 00062 } 00063 #endif /* _READONLY */ 00064 00065 DRESULT disk_ioctl ( 00066 BYTE drv, /* Physical drive nmuber (0..) */ 00067 BYTE ctrl, /* Control code */ 00068 void *buff /* Buffer to send/receive control data */ 00069 ) 00070 { 00071 switch(ctrl) { 00072 case CTRL_SYNC: 00073 if(FATFileSystem::_ffs[drv] == NULL) { 00074 return RES_NOTRDY; 00075 } else if(FATFileSystem::_ffs[drv]->disk_sync()) { 00076 return RES_ERROR; 00077 } 00078 return RES_OK; 00079 case GET_SECTOR_COUNT: 00080 if(FATFileSystem::_ffs[drv] == NULL) { 00081 return RES_NOTRDY; 00082 } else { 00083 DWORD res = FATFileSystem::_ffs[drv]->disk_sectors(); 00084 if(res > 0) { 00085 *((DWORD*)buff) = res; // minimum allowed 00086 return RES_OK; 00087 } else { 00088 return RES_ERROR; 00089 } 00090 } 00091 case GET_BLOCK_SIZE: 00092 *((DWORD*)buff) = 1; // default when not known 00093 return RES_OK; 00094 00095 } 00096 return RES_PARERR; 00097 }
Generated on Wed Jul 13 2022 08:47:33 by 1.7.2