SD Card Interface class. Log raw data bytes to memory addresses of your choice, or format the card and use the FAT file system to write files.

Dependencies:   mbed

Revision:
6:ddf09d859ed7
Parent:
3:210eb67b260c
diff -r d85e20b6b904 -r ddf09d859ed7 FATFileSystem/Core/diskio.c
--- a/FATFileSystem/Core/diskio.c	Sat Jan 15 05:58:22 2011 +0000
+++ b/FATFileSystem/Core/diskio.c	Sun Jan 16 09:20:30 2011 +0000
@@ -1,138 +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;
-    }
+/*-----------------------------------------------------------------------*/
+/* 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