![](/media/cache/profiles/f095cedd23b99f1696fc8caecbcf257e.jpg.50x50_q85.jpg)
http://mbed.org/users/okini3939/notebook/sdhc-test/
Dependencies: FatFileSystemCpp SDHC_FileSystem mbed
Revision 1:2b18f6628bc1, committed 2013-02-08
- Comitter:
- okini3939
- Date:
- Fri Feb 08 03:12:56 2013 +0000
- Parent:
- 0:58238bb83503
- Commit message:
- fix;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 58238bb83503 -r 2b18f6628bc1 main.cpp --- a/main.cpp Fri Feb 08 01:42:33 2013 +0000 +++ b/main.cpp Fri Feb 08 03:12:56 2013 +0000 @@ -1,18 +1,18 @@ #include "mbed.h" #include "SDHCFileSystem.h" -#define SIZE 10240 // KB +#define SIZE 1024 // KB Serial pc(USBTX, USBRX); DigitalOut myled(LED1); SDFileSystem sd(p5, p6, p7, p8, "sd"); -Timer t; float wtest (int b, int d) { int i; int s = b / d; char buf[d]; FILE *fp; + Timer t; fp = fopen("/sd/sdhc_test.dat", "w"); if (!fp) return 0; @@ -33,8 +33,9 @@ int s = b / d; char buf[d]; FILE *fp; + Timer t; - fp = fopen("/sd/test.dat", "r"); + fp = fopen("/sd/sdhc_test.dat", "r"); if (!fp) return 0; myled = 1; t.reset(); @@ -53,12 +54,14 @@ pc.baud(115200); pc.printf("start\r\n"); - pc.printf("write 1: %f KB/sec\r\n", (float)SIZE / wtest(SIZE * 1024, 1)); - pc.printf("read 1: %f KB/sec\r\n", (float)SIZE / rtest(SIZE * 1024, 1)); - pc.printf("write 100: %f KB/sec\r\n", (float)SIZE / wtest(SIZE * 1024, 100)); - pc.printf("read 100: %f KB/sec\r\n", (float)SIZE / rtest(SIZE * 1024, 100)); - pc.printf("write 10k: %f KB/sec\r\n", (float)SIZE / wtest(SIZE * 1024, 10000)); - pc.printf("read 10k: %f KB/sec\r\n", (float)SIZE / rtest(SIZE * 1024, 10000)); + if (sd.disk_initialize()) return -1; + + pc.printf("write 1: %f KB/sec\r\n", (double)SIZE / wtest(SIZE * 1024, 1)); + pc.printf("read 1: %f KB/sec\r\n", (double)SIZE / rtest(SIZE * 1024, 1)); + pc.printf("write 100: %f KB/sec\r\n", (double)SIZE / wtest(SIZE * 1024, 100)); + pc.printf("read 100: %f KB/sec\r\n", (double)SIZE / rtest(SIZE * 1024, 100)); + pc.printf("write 10k: %f KB/sec\r\n", (double)SIZE / wtest(SIZE * 1024, 10000)); + pc.printf("read 10k: %f KB/sec\r\n", (double)SIZE / rtest(SIZE * 1024, 10000)); return 0; }