CodeShare

Dependencies:   FatFileSystem mbed

Fork of 4180_Lab2_USB by Jeremy Cai

Files at this revision

API Documentation at this revision

Comitter:
jeremycai3721
Date:
Sun Sep 25 19:04:39 2016 +0000
Parent:
0:4e756c4c88a7
Commit message:
CodeShare

Changed in this revision

FATFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 4e756c4c88a7 -r fca955be2a5b FATFileSystem.lib
--- a/FATFileSystem.lib	Mon Sep 13 14:20:21 2010 +0000
+++ b/FATFileSystem.lib	Sun Sep 25 19:04:39 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_unsupported/code/fatfilesystem/
\ No newline at end of file
+http://mbed.org/users/mbed_unsupported/code/fatfilesystem/#333d6e93e58f
diff -r 4e756c4c88a7 -r fca955be2a5b main.cpp
--- a/main.cpp	Mon Sep 13 14:20:21 2010 +0000
+++ b/main.cpp	Sun Sep 25 19:04:39 2016 +0000
@@ -6,7 +6,26 @@
 int main () {
 
     FILE *fp = fopen("/fs/hello.txt","w");
-    fprintf(fp,"Hello world!\n");
+    if ( fp == NULL )
+    {
+        error("Could not open file for write\n");
+    }
+    fprintf(fp, "Hello mass storage!\n\r");
     fclose (fp);
+    printf("Goodbye World!\n\r");
+    
+    
+    // example of reading a file one byte at a time
+   // // and display it in hex format on the terminal
 
+    unsigned char c;                          // a single byte buffer
+
+    fp = fopen("/fs/hello.txt", "r");  // open the file in 'read' mode
+
+    while (!feof(fp)) {                       // while not end of file
+        c=fgetc(fp);                         // get a character/byte from the file
+        printf("%c\r",c);                  //
+    }
+    printf("\n\r");
+    fclose(fp);                               // close the file
 }
\ No newline at end of file