USER PASS / Mbed 2 deprecated USBHost_TEST

Dependencies:   SDFileSystem USBHost_SAMPLE mbed

Fork of Production_ver1_0 by 幸隆 小森

Files at this revision

API Documentation at this revision

Comitter:
Login10
Date:
Thu Sep 28 01:24:22 2017 +0000
Child:
1:16b9397301c6
Commit message:
test

Changed in this revision

SDFileSystem.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.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Thu Sep 28 01:24:22 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBHost.lib	Thu Sep 28 01:24:22 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/USBHost/#18e91028dd16
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Sep 28 01:24:22 2017 +0000
@@ -0,0 +1,53 @@
+#include "mbed.h"
+#include "USBHostKeyboard.h"
+#include "SDFileSystem.h"
+
+DigitalOut led(LED1);
+SDFileSystem sd(p5, p6, p7, p8, "sd");
+int i=0;
+
+
+void onKey(uint8_t key) {
+    printf("Key: %c\r\n", key);
+    char log[8];
+    ++i;
+
+    FILE *fp;
+    sprintf(log, "log%03d.csv", i);
+    fp = fopen("log", "a");
+    fprintf(fp, "Keydata[%d],:,%c\r\n", i, key);
+    fclose(fp); 
+}
+
+void keyboard_task(void const *) {
+    
+    USBHostKeyboard keyboard;
+    
+    while(1) {
+        // try to connect a USB keyboard
+        while(!keyboard.connect())
+            Thread::wait(500);
+    
+        // when connected, attach handler called on keyboard event
+        keyboard.attach(onKey);
+        
+        // wait until the keyboard is disconnected
+        while(keyboard.connected())
+            Thread::wait(500);
+    }
+}
+
+int main() {
+    mkdir("/sd/keylog", 0777);
+    FILE *fp;
+    fp = fopen("/sd/keylog/log.csv","w");
+    fclose(fp);
+    
+    
+    Thread keyboardTask(keyboard_task, NULL, osPriorityNormal, 256 * 4);
+    
+     while(1) {
+        led=!led;
+        Thread::wait(500);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Sep 28 01:24:22 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b
\ No newline at end of file