pls work

Dependencies:   mbed WS2813 PixelArray SDFileSystem ds3231

Fork of SDFileSystem_HelloWorld by Neil Thiessen

Revision:
17:e5b7469082c8
Parent:
16:d68a6d4050f2
Child:
19:ae979143c796
--- a/main.cpp	Wed Jul 08 16:47:02 2015 +0000
+++ b/main.cpp	Thu Aug 27 21:51:58 2015 +0000
@@ -70,42 +70,54 @@
         buffer[i] = rand();
 
     while(1) {
+        //Simple button debouncing
+        wait(0.5);
+
         //Print the start message
         printf("\nPress the button to perform tests: ");
 
         //Wait for the button to be pressed
         while(button);
 
-        //Display the card type and capacity
+        //Display the card type
         printf("\nCard type: ");
-        if (sd.card_type() == SDFileSystem::CARD_NONE)
+        SDFileSystem::CardType cardType = sd.card_type();
+        if (cardType == SDFileSystem::CARD_NONE)
             printf("None\n");
-        else if (sd.card_type() == SDFileSystem::CARD_MMC)
+        else if (cardType == SDFileSystem::CARD_MMC)
             printf("MMC\n");
-        else if (sd.card_type() == SDFileSystem::CARD_SD)
+        else if (cardType == SDFileSystem::CARD_SD)
             printf("SD\n");
-        else if (sd.card_type() == SDFileSystem::CARD_SDHC)
+        else if (cardType == SDFileSystem::CARD_SDHC)
             printf("SDHC\n");
         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);
 
-        //Mount the filesystem
-        sd.mount();
+        /*//Format the card
+        printf("Formatting SD card...");
+        if (sd.format() != 0) {
+            printf("failed!\n");
+            continue;
+        }
+        printf("success!\n");*/
 
-        /*//Format the card
-        printf("Formatting card...");
-        if (sd.format() == 0)
-            printf("success!\n");
-        else
-            printf("failed!\n");*/
-
-        //Perform a read/write tests
+        //Perform a read/write test
         writeTest();
         readTest();
 
-        //Unmount the filesystem
+        //Unmount the SD card
         sd.unmount();
     }
 }