nkjnm

Dependencies:   MAX44000 nexpaq_mdk

Fork of LED_Demo by Maxim nexpaq

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 #if !DEVICE_LOCALFILESYSTEM
00004   #error [NOT_SUPPORTED] LocalFileSystem not supported
00005 #endif
00006 
00007 #define TEST_STDIO 0
00008 
00009 int main() {
00010     printf("\r\n\r\n*** Start of memory write test (2K bytes) ***\r\n");
00011 
00012     // dummy data
00013     char buf[2048];
00014     int index = 0;
00015     for (index = 0; index < 2048; index++) {
00016         buf[index] = ~index & 0xFF;
00017     }
00018 
00019     // Run the timed write test
00020     float starttime, duration;
00021     Timer t;
00022     t.start();
00023     starttime = t.read();
00024 
00025 #if TEST_STDIO
00026     LocalFileSystem local("local");
00027     FILE *fp = fopen("/local/test.dat", "w");
00028     fwrite(buf, sizeof(buf[0]), sizeof(buf)/sizeof(buf[0]), fp);
00029     fclose(fp);
00030 #else
00031     FILEHANDLE fh = local_file_open("test.dat", O_WRONLY);
00032     LocalFileHandle lfh(fh);
00033     lfh.write(buf, sizeof(buf));
00034     lfh.close();
00035 #endif
00036 
00037     duration = t.read() - starttime;
00038     printf("Write completed in %.2f seconds. Average throughput = %.0f bytes/second.\r\n", duration, 2048/duration);
00039 }