An example program for the S25FL216K flash memory

Dependencies:   S25FL216K_FATFileSystem mbed

Fork of S25FL216K_HelloWorld by Erik -

Files at this revision

API Documentation at this revision

Comitter:
mkilivan
Date:
Fri Dec 19 14:41:55 2014 +0000
Parent:
3:321618d7c9a5
Child:
5:1a2c6c946686
Commit message:
Tried to create two files

Changed in this revision

S25FL216K_USBFileSystem.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
--- a/S25FL216K_USBFileSystem.lib	Tue Nov 19 21:09:35 2013 +0000
+++ b/S25FL216K_USBFileSystem.lib	Fri Dec 19 14:41:55 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Sissors/code/S25FL216K_USBFileSystem/#ec125501d68f
+http://mbed.org/users/Sissors/code/S25FL216K_USBFileSystem/#46b3321201c8
--- a/main.cpp	Tue Nov 19 21:09:35 2013 +0000
+++ b/main.cpp	Fri Dec 19 14:41:55 2014 +0000
@@ -2,27 +2,16 @@
 #include "Flash_USBFileSystem.h"
 
 DigitalOut myled(LED1);
-FlashUSB flash(PTD6, PTD7, PTB11, PTE4);
+//FlashUSB flash(PTD6, PTD7, PTB11, PTE4);
+FlashUSB flash(P0_9, P0_8, P0_7, P0_6);
 
-void usbCallback(bool available)
-{
-    if (available) {
-        FILE *fp = fopen("/USB/in.txt", "r");
-        char buffer[100];
-        fgets (buffer, 100, fp);
-        printf("%s\r\n", buffer);
-        fclose(fp);
-    }
-}
 
 int main()
 {
-    flash.attachUSB(&usbCallback);
-    
     wait(0.1);
     printf("Hello World!\r\n");
 
-    FILE *fp = fopen("/USB/in.txt", "w");
+    FILE *fp = fopen("/USB/in1.txt", "w");
 
     if(fp == NULL) {
         printf("Could not open file, assuming unformatted disk!\r\n");
@@ -36,27 +25,13 @@
         fprintf(fp, "Type your text here!");
         fclose(fp);
     }
-
-    //Connect USB
-    flash.connect();
-    flash.usbMode(1);       //Disconnect USB when files are locally written
     
-    char buffer[101];
-    printf("Type your text here! (100 max length)\n");
-    while(1) {
-        gets(buffer);
-        myled = !myled;
-        
-        //Open file for write, keep trying until we succeed
-        //This is needed because if USB happens to be writing it will fail
-        while(1) {
-            fp = fopen("/USB/out.txt", "w");
-            if (fp != NULL)
-                break;
-            }
-        fprintf(fp, buffer);
+    fp = fopen("/USB/in2.txt", "w");
+    if (fp == NULL) {
+        printf("out.txt can't created.\r\n");
+    } else {
+        fprintf(fp, "Hello World!\r\n");
         fclose(fp);
-        
     }
 
 }