Example program of using USB mass storage device (USB flash disk) with STM32F407VET6 boards (compatible with Seed Arch Max). This is a fork of https://os.mbed.com/users/va009039/code/F401RE-USBHostMSD_HelloWorld/

Dependencies:   mbed FATFileSystem USBHost-STM32F4

Files at this revision

API Documentation at this revision

Comitter:
hudakz
Date:
Tue Feb 19 21:35:40 2019 +0000
Commit message:
Initial release.

Changed in this revision

FATFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
USBHost-STM32F4.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 4ea663e6aa00 FATFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FATFileSystem.lib	Tue Feb 19 21:35:40 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/mbed-official/code/FATFileSystem/#28e685e5ff7f
diff -r 000000000000 -r 4ea663e6aa00 USBHost-STM32F4.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBHost-STM32F4.lib	Tue Feb 19 21:35:40 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/hudakz/code/USBHost-STM32F4/#458bf947f46f
diff -r 000000000000 -r 4ea663e6aa00 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Feb 19 21:35:40 2019 +0000
@@ -0,0 +1,51 @@
+#include "USBHostMSD.h"
+
+DigitalOut  led1(LED1);
+
+int main()
+{
+    printf("Starting..\r\n");
+
+    USBHostMSD  msd("usb");
+    
+    printf("Connecting the device\r\n");
+    
+    if (!msd.connect()) {
+        error("USB mass storage device not found.\n");
+    }
+    
+    FILE*   fp = fopen("/usb/test1.txt", "a");
+    if (fp) {
+        fprintf(fp, "Hello from mbed.\n");
+        for (int i = 0; i < 21; i++) {
+            fprintf(fp, " %d", i);
+            led1 = !led1;
+        }
+
+        fprintf(fp, "\n");
+        fclose(fp);
+    }
+
+    fp = fopen("/usb/test1.txt", "r");
+    if (fp) {
+        int n = 0;
+        while (1) {
+            int c = fgetc(fp);
+            if (c == EOF) {
+                break;
+            }
+
+            printf("%c", c);
+            n++;
+            led1 = !led1;
+        }
+
+        fclose(fp);
+        printf("%d bytes\n", n);
+    }
+
+    while (1) {
+        led1 = !led1;
+        wait_ms(200);
+    }
+}
diff -r 000000000000 -r 4ea663e6aa00 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Feb 19 21:35:40 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file