Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:54:50 2016 +0000
Revision:
1:d96dbedaebdb
Parent:
0:6c56fb4bc5f0
Removed extra directories for other platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:6c56fb4bc5f0 1 #include "mbed.h"
nexpaq 0:6c56fb4bc5f0 2
nexpaq 0:6c56fb4bc5f0 3 #if !DEVICE_LOCALFILESYSTEM
nexpaq 0:6c56fb4bc5f0 4 #error [NOT_SUPPORTED] LocalFileSystem not supported
nexpaq 0:6c56fb4bc5f0 5 #endif
nexpaq 0:6c56fb4bc5f0 6
nexpaq 0:6c56fb4bc5f0 7 #define TEST_STDIO 0
nexpaq 0:6c56fb4bc5f0 8
nexpaq 0:6c56fb4bc5f0 9 int main() {
nexpaq 0:6c56fb4bc5f0 10 printf("\r\n\r\n*** Start of memory write test (2K bytes) ***\r\n");
nexpaq 0:6c56fb4bc5f0 11
nexpaq 0:6c56fb4bc5f0 12 // dummy data
nexpaq 0:6c56fb4bc5f0 13 char buf[2048];
nexpaq 0:6c56fb4bc5f0 14 int index = 0;
nexpaq 0:6c56fb4bc5f0 15 for (index = 0; index < 2048; index++) {
nexpaq 0:6c56fb4bc5f0 16 buf[index] = ~index & 0xFF;
nexpaq 0:6c56fb4bc5f0 17 }
nexpaq 0:6c56fb4bc5f0 18
nexpaq 0:6c56fb4bc5f0 19 // Run the timed write test
nexpaq 0:6c56fb4bc5f0 20 float starttime, duration;
nexpaq 0:6c56fb4bc5f0 21 Timer t;
nexpaq 0:6c56fb4bc5f0 22 t.start();
nexpaq 0:6c56fb4bc5f0 23 starttime = t.read();
nexpaq 0:6c56fb4bc5f0 24
nexpaq 0:6c56fb4bc5f0 25 #if TEST_STDIO
nexpaq 0:6c56fb4bc5f0 26 LocalFileSystem local("local");
nexpaq 0:6c56fb4bc5f0 27 FILE *fp = fopen("/local/test.dat", "w");
nexpaq 0:6c56fb4bc5f0 28 fwrite(buf, sizeof(buf[0]), sizeof(buf)/sizeof(buf[0]), fp);
nexpaq 0:6c56fb4bc5f0 29 fclose(fp);
nexpaq 0:6c56fb4bc5f0 30 #else
nexpaq 0:6c56fb4bc5f0 31 FILEHANDLE fh = local_file_open("test.dat", O_WRONLY);
nexpaq 0:6c56fb4bc5f0 32 LocalFileHandle lfh(fh);
nexpaq 0:6c56fb4bc5f0 33 lfh.write(buf, sizeof(buf));
nexpaq 0:6c56fb4bc5f0 34 lfh.close();
nexpaq 0:6c56fb4bc5f0 35 #endif
nexpaq 0:6c56fb4bc5f0 36
nexpaq 0:6c56fb4bc5f0 37 duration = t.read() - starttime;
nexpaq 0:6c56fb4bc5f0 38 printf("Write completed in %.2f seconds. Average throughput = %.0f bytes/second.\r\n", duration, 2048/duration);
nexpaq 0:6c56fb4bc5f0 39 }