Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FatFileSystemCpp SDHC_FileSystem mbed
Diff: main.cpp
- Revision:
- 1:2b18f6628bc1
- Parent:
- 0:58238bb83503
--- 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; }