A simple serial test program for the re-written SDFileSystem library.
Dependencies: SDFileSystem mbed
Revision 17:e5b7469082c8, committed 2015-08-27
- Comitter:
- neilt6
- Date:
- Thu Aug 27 21:51:58 2015 +0000
- Parent:
- 16:d68a6d4050f2
- Child:
- 18:0999ca8699d8
- Commit message:
- Updated libraries and implemented minor improvements
Changed in this revision
--- a/SDFileSystem.lib Wed Jul 08 16:47:02 2015 +0000 +++ b/SDFileSystem.lib Thu Aug 27 21:51:58 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/neilt6/code/SDFileSystem/#a47f74caa04e +http://mbed.org/users/neilt6/code/SDFileSystem/#2286a4e7fa31
--- 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(); } }
--- a/mbed.bld Wed Jul 08 16:47:02 2015 +0000 +++ b/mbed.bld Thu Aug 27 21:51:58 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/8ed44a420e5c \ No newline at end of file