1 /*-----------------------------------------------------------------------*/
2 /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2007 */
3 /*-----------------------------------------------------------------------*/
4 /* This is a stub disk I/O module that acts as front end of the existing */
5 /* disk I/O modules and attach it to FatFs module with common interface. */
6 /*-----------------------------------------------------------------------*/
10 #include "mbed_debug.h"
11 #include "FATFileSystem.h"
15 DSTATUS disk_initialize (
16 BYTE drv /* Physical drive nmuber (0..) */
19 debug_if(FFS_DBG, "disk_initialize on drv [%d]\n", drv);
20 return (DSTATUS)FATFileSystem::_ffs[drv]->disk_initialize();
24 BYTE drv /* Physical drive nmuber (0..) */
27 debug_if(FFS_DBG, "disk_status on drv [%d]\n", drv);
28 return (DSTATUS)FATFileSystem::_ffs[drv]->disk_status();
32 BYTE drv, /* Physical drive nmuber (0..) */
33 BYTE *buff, /* Data buffer to store read data */
34 DWORD sector, /* Sector address (LBA) */
35 BYTE count /* Number of sectors to read (1..255) */
38 debug_if(FFS_DBG, "disk_read(sector %d, count %d) on drv [%d]\n", sector, count, drv);
39 if (FATFileSystem::_ffs[drv]->disk_read((uint8_t*)buff, sector, count))
47 BYTE drv, /* Physical drive nmuber (0..) */
48 const BYTE *buff, /* Data to be written */
49 DWORD sector, /* Sector address (LBA) */
50 BYTE count /* Number of sectors to write (1..255) */
53 debug_if(FFS_DBG, "disk_write(sector %d, count %d) on drv [%d]\n", sector, count, drv);
54 if (FATFileSystem::_ffs[drv]->disk_write((uint8_t*)buff, sector, count))
59 #endif /* _READONLY */
62 BYTE drv, /* Physical drive nmuber (0..) */
63 BYTE ctrl, /* Control code */
64 void *buff /* Buffer to send/receive control data */
67 debug_if(FFS_DBG, "disk_ioctl(%d)\n", ctrl);
70 if(FATFileSystem::_ffs[drv] == NULL) {
72 } else if(FATFileSystem::_ffs[drv]->disk_sync()) {
76 case GET_SECTOR_COUNT:
77 if(FATFileSystem::_ffs[drv] == NULL) {
80 DWORD res = FATFileSystem::_ffs[drv]->disk_sectors();
82 *((DWORD*)buff) = res; // minimum allowed
89 *((DWORD*)buff) = 1; // default when not known