USBHostMouse Hello World for ST-Nucleo-F446RE

Dependencies:   F401RE-USBHost mbed

Fork of USBHostMouse_HelloWorld by Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
va009039
Date:
Sun May 01 05:05:48 2016 +0000
Parent:
6:4b404612bc9a
Commit message:
USBHostMouse for F446RE

Changed in this revision

F401RE-USBHost.lib Show annotated file Show diff for this revision Revisions of this file
USBHost.lib 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 4b404612bc9a -r 26cbee9ef684 F401RE-USBHost.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/F401RE-USBHost.lib	Sun May 01 05:05:48 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/va009039/code/F401RE-USBHost/#4ab8bc835303
diff -r 4b404612bc9a -r 26cbee9ef684 USBHost.lib
--- a/USBHost.lib	Thu Mar 14 14:23:16 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://mbed.org/users/mbed_official/code/USBHost/#7671b6a8c363
diff -r 4b404612bc9a -r 26cbee9ef684 main.cpp
--- a/main.cpp	Thu Mar 14 14:23:16 2013 +0000
+++ b/main.cpp	Sun May 01 05:05:48 2016 +0000
@@ -7,28 +7,22 @@
     printf("buttons: %d, x: %d, y: %d, z: %d\r\n", buttons, x, y, z);
 }
 
-void mouse_task(void const *) {
-    
+int main() {
     USBHostMouse mouse;
-    
-    while(1) {
-        // try to connect a USB mouse
-        while(!mouse.connect())
-            Thread::wait(500);
-    
-        // when connected, attach handler called on mouse event
-        mouse.attachEvent(onMouseEvent);
-        
-        // wait until the mouse is disconnected
-        while(mouse.connected())
-            Thread::wait(500);
+    // connect a USB mouse
+    if (!mouse.connect()) {
+        error("USB mouse not found.\n");
+    }
+    // when connected, attach handler called on mouse event
+    mouse.attachEvent(onMouseEvent);
+    Timer t;
+    t.reset();
+    t.start();
+    for(;;) {
+        if (t.read_ms() > 500) {
+            led = !led;
+            t.reset();
+        }
+        USBHost::poll();
     }
 }
-
-int main() {
-    Thread mouseTask(mouse_task, NULL, osPriorityNormal, 256 * 4);
-    while(1) {
-        led=!led;
-        Thread::wait(500);
-    }
-}
\ No newline at end of file
diff -r 4b404612bc9a -r 26cbee9ef684 mbed.bld
--- a/mbed.bld	Thu Mar 14 14:23:16 2013 +0000
+++ b/mbed.bld	Sun May 01 05:05:48 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/aae6fcc7d9bb
\ No newline at end of file