Dieter Graef / Mbed 2 deprecated DISCO-F746NG_USB_Host

Dependencies:   USBHost_DISCO-F746NG mbed

Revision:
0:af2040964256
Child:
2:ca1b5b911ba8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jun 13 17:22:08 2016 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "rtos.h"
+#include "USBHostMouseKeyboard.h"
+#define FastSpeedInterface 0
+#define HighSpeedInterface 1
+DigitalOut led(LED1);
+
+void onMouseEventdev(uint8_t buttons, int8_t x, int8_t y, int8_t z) {
+    printf("m: %d, x: %d, y: %d, z: %d\r\n", buttons, x, y, z);
+}
+
+void onKeydev(uint8_t key) {
+    printf("Key: %c\r\n", key);
+}
+
+
+void mouse_task(void const *) {
+    // At the moment only one Interface can be used for the Host due to the use of
+    // USBHostMouseKb dev(FastSpeedInterface);
+    USBHostMouseKb dev(HighSpeedInterface);
+    while(1) {
+        // try to connect
+        while(!dev.connect())
+            Thread::wait(500);
+
+        // when connected, attach handler
+        dev.attachMouseEvent(onMouseEventdev);
+        dev.attachKb(onKeydev);
+
+        while(1)
+        {
+           dev.poll();
+           Thread::wait(50);
+        }
+
+    }
+}
+
+int main() {
+    Thread mouseTask(mouse_task, NULL, osPriorityNormal, 256 * 4);
+    while(1) {
+        led=!led;
+        Thread::wait(500);
+    }
+}
+