USB BARCODE READER

Dependencies:   USBHOST

Files at this revision

API Documentation at this revision

Comitter:
jamike
Date:
Wed Feb 15 13:07:06 2017 +0000
Child:
1:a12f904713ed
Commit message:
MSD example running on NUCLEO_F411RE

Changed in this revision

FATFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
USBHOST.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-rtos.lib 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/FATFileSystem.lib	Wed Feb 15 13:07:06 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/mbed-official/code/FATFileSystem/#e2ab678eb692
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBHOST.lib	Wed Feb 15 13:07:06 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/USBHOST/#ab240722d7ef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 15 13:07:06 2017 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+#include "USBHostMSD.h"
+DigitalOut led(LED1);
+void msd_task(void const *) {
+    printf("init msd\n");
+    USBHostMSD msd("usb");
+    int i = 0;
+    printf("wait for usb memory stick insertion\n");
+    while(1) {
+
+        // try to connect a MSD device
+        while(!msd.connect()) {
+            Thread::wait(500);
+        }
+
+        // in a loop, append a file
+        // if the device is disconnected, we try to connect it again
+
+        // append a file
+        FILE * fp = fopen("/usb/test1.txt", "a");
+
+        if (fp != NULL) {
+            fprintf(fp, "Hello fun SD Card World: %d!\r\n", i++);
+            printf("Goodbye World!\r\n");
+            fclose(fp);
+        } else {
+            printf("FILE == NULL\r\n");
+        }
+        Thread::wait(500);
+        printf("again\n");
+        // if device disconnected, try to connect again
+        while (msd.connected()) {
+            Thread::wait(500);
+        }
+    }
+}
+
+int main() {
+    Thread msdTask(msd_task, NULL, osPriorityNormal, 1024 * 4);
+    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-rtos.lib	Wed Feb 15 13:07:06 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#58563e6cba1e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Feb 15 13:07:06 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ef9c61f8c49f
\ No newline at end of file