A simple serial test program for the re-written SDFileSystem library.

Dependencies:   SDFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
neilt6
Date:
Tue Dec 08 16:14:07 2015 +0000
Parent:
18:0999ca8699d8
Child:
20:ec1c4f02d50e
Commit message:
Updated SDFileSystem, and improved test sequence

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/SDFileSystem.lib	Thu Nov 26 16:25:46 2015 +0000
+++ b/SDFileSystem.lib	Tue Dec 08 16:14:07 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/neilt6/code/SDFileSystem/#84b2958bbcae
+http://mbed.org/users/neilt6/code/SDFileSystem/#2c1e8d442f68
--- a/main.cpp	Thu Nov 26 16:25:46 2015 +0000
+++ b/main.cpp	Tue Dec 08 16:14:07 2015 +0000
@@ -79,8 +79,22 @@
         //Wait for the button to be pressed
         while(button);
 
+        //Make sure a card is present
+        if (!sd.card_present()) {
+            printf("\nNo card present!\n");
+            continue;
+        }
+
+        //Try to mount the SD card
+        printf("\nMounting SD card...");
+        if (sd.mount() != 0) {
+            printf("failed!\n");
+            continue;
+        }
+        printf("success!\n");
+
         //Display the card type
-        printf("\nCard type: ");
+        printf("\tCard type: ");
         SDFileSystem::CardType cardType = sd.card_type();
         if (cardType == SDFileSystem::CARD_NONE)
             printf("None\n");
@@ -93,17 +107,9 @@
         else
             printf("Unknown\n");
 
-        //Try to mount the SD card
-        printf("Mounting SD card...");
-        if (sd.mount() != 0) {
-            printf("failed!\n");
-            continue;
-        }
-        printf("success!\n");
-
         //Display the card capacity
-        printf("Sectors: %llu\n", sd.disk_sectors());
-        printf("Capacity: %.1fMB\n", sd.disk_sectors() / 2048.0);
+        printf("\tSectors: %llu\n", sd.disk_sectors());
+        printf("\tCapacity: %.1fMB\n", sd.disk_sectors() / 2048.0);
 
         /*//Format the card
         printf("Formatting SD card...");