Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
Diff: SDFileSystem/FATFileSystem/Core/diskio.c
- Revision:
- 0:826c6171fc1b
diff -r 000000000000 -r 826c6171fc1b SDFileSystem/FATFileSystem/Core/diskio.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem/FATFileSystem/Core/diskio.c Wed Jun 20 14:57:48 2012 +0000
@@ -0,0 +1,138 @@
+/*-----------------------------------------------------------------------*/
+/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2007 */
+/*-----------------------------------------------------------------------*/
+/* 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. */
+/*-----------------------------------------------------------------------*/
+
+//Modified by Thomas Hamilton, Copyright 2010
+
+#include "diskio.h"
+
+DSTATUS disk_initialize(BYTE drv)
+{
+ if (FATFileSystem::DriveArray[drv])
+ {
+ return (DSTATUS)FATFileSystem::DriveArray[drv]->disk_initialize();
+ }
+ else
+ {
+ return STA_NOINIT;
+ }
+}
+
+DSTATUS disk_status(BYTE drv)
+{
+ if (FATFileSystem::DriveArray[drv])
+ {
+ return (DSTATUS)FATFileSystem::DriveArray[drv]->disk_status();
+ }
+ else
+ {
+ return STA_NOINIT;
+ }
+}
+
+DRESULT disk_read(BYTE drv, BYTE* buff, DWORD sector, BYTE count)
+{
+ if (FATFileSystem::DriveArray[drv])
+ {
+ return (DRESULT)FATFileSystem::DriveArray[drv]->disk_read((unsigned char*)buff,
+ (unsigned long)sector, (unsigned char)count);
+ }
+ else
+ {
+ return RES_NOTRDY;
+ }
+}
+
+#if _READONLY == 0
+DRESULT disk_write(BYTE drv, const BYTE* buff, DWORD sector, BYTE count)
+{
+ if (FATFileSystem::DriveArray[drv])
+ {
+ return (DRESULT)FATFileSystem::DriveArray[drv]->disk_write((const unsigned char*)buff,
+ (unsigned long)sector, (unsigned char)count);
+ }
+ else
+ {
+ return RES_NOTRDY;
+ }
+}
+#endif
+
+DRESULT disk_ioctl(BYTE drv, BYTE ctrl, void* buff)
+{
+ switch (ctrl)
+ {
+ case CTRL_SYNC:
+ if (FATFileSystem::DriveArray[drv])
+ {
+ return (DRESULT)FATFileSystem::DriveArray[drv]->disk_sync();
+ }
+ else
+ {
+ return RES_NOTRDY;
+ }
+
+ case GET_SECTOR_SIZE:
+ if (FATFileSystem::DriveArray[drv])
+ {
+ WORD Result = FATFileSystem::DriveArray[drv]->disk_sector_size();
+ if (Result > 0)
+ {
+ *((WORD*)buff) = Result;
+ return RES_OK;
+ }
+ else
+ {
+ return RES_ERROR;
+ }
+ }
+ else
+ {
+ return RES_NOTRDY;
+ }
+
+ case GET_SECTOR_COUNT:
+ if (FATFileSystem::DriveArray[drv])
+ {
+ DWORD Result = FATFileSystem::DriveArray[drv]->disk_sector_count();
+ if (Result > 0)
+ {
+ *((DWORD*)buff) = Result;
+ return RES_OK;
+ }
+ else
+ {
+ return RES_ERROR;
+ }
+ }
+ else
+ {
+ return RES_NOTRDY;
+ }
+
+ case GET_BLOCK_SIZE:
+ if (FATFileSystem::DriveArray[drv])
+ {
+ DWORD Result = FATFileSystem::DriveArray[drv]->disk_block_size();
+ if (Result > 0)
+ {
+ *((DWORD*)buff) = Result;
+ return RES_OK;
+ }
+ else
+ {
+ return RES_ERROR;
+ }
+ }
+ else
+ {
+ return RES_NOTRDY;
+ }
+
+ default:
+ return RES_PARERR;
+ }
+}
\ No newline at end of file