Working version on STM32F411. Test for CLI

Dependencies:   FATFileSystem mbed-rtos mbed

Fork of USBHost by mbed official

Files at this revision

API Documentation at this revision

Comitter:
stema
Date:
Fri Sep 29 12:47:27 2017 +0000
Parent:
40:7c3b59bb364e
Commit message:
Working version. Test for CLI

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Sep 29 12:47:27 2017 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+#include "USBHostMSD.h"
+
+DigitalOut led(LED1);
+DigitalOut debug_pin(A5);
+
+void msd_task(void const*)
+{
+    USBHostMSD msd("usb");
+    int i = 0;
+
+    debug_pin = 0;
+
+    while(1)
+    {
+        // try to connect a MSD device
+        while(!msd.connect())
+        {
+            Thread::wait(500);
+            printf("Waiting for USB stick..\n");
+        }
+       
+        FILE* fp = fopen("/usb/my_test.txt", "w");
+       
+        while(1)
+        {
+            if(fp != NULL)
+            {
+                debug_pin = 1;
+                
+                fprintf(fp, "Hello, SD Card World: that's the string number %d!\r\n", i++);
+                //printf("Goodbye World!\r\n");
+                //fclose(fp);
+                
+                debug_pin = 0;
+            }
+            else 
+            {
+                printf("FILE == NULL\r\n");
+            }
+
+            Thread::wait(10);
+
+            // if device disconnected, try to connect again
+            //if(!msd.connected())
+            //    break;
+        }
+    }
+}
+
+
+int main()
+{
+    Thread msdTask(msd_task, NULL, osPriorityNormal, 1024*8);
+    
+    while(1)
+    {
+        led=!led;
+        Thread::wait(500);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Sep 29 12:47:27 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/675da3299148
\ No newline at end of file