USBHost library. NOTE: This library is only officially supported on the LPC1768 platform. For more information, please see the handbook page.

Dependencies:   FATFileSystem mbed-rtos

Dependents:   BTstack WallbotWii SD to Flash Data Transfer USBHost-MSD_HelloWorld ... more

Legacy Warning

This is an mbed 2 library. To learn more about mbed OS 5, visit the docs.

Pull requests against this repository are no longer supported. Please raise against mbed OS 5 as documented above.

Revision:
27:4206883f4cb7
Parent:
24:868cbfe611a7
Child:
37:f1e388e7b752
--- a/USBHostHID/USBHostMouse.cpp	Mon Aug 18 13:45:26 2014 +0100
+++ b/USBHostHID/USBHostMouse.cpp	Mon Jan 19 14:30:37 2015 +0000
@@ -47,6 +47,7 @@
 }
 
 bool USBHostMouse::connect() {
+    int len_listen;
 
     if (dev_connected) {
         return true;
@@ -69,7 +70,11 @@
                 host->registerDriver(dev, mouse_intf, this, &USBHostMouse::init);
 
                 int_in->attach(this, &USBHostMouse::rxHandler);
-                host->interruptRead(dev, int_in, report, int_in->getSize(), false);
+                len_listen = int_in->getSize();
+                if (len_listen > sizeof(report)) {
+                    len_listen = sizeof(report);
+                }
+                host->interruptRead(dev, int_in, report, len_listen, false);
 
                 dev_connected = true;
                 return true;
@@ -109,6 +114,10 @@
     y = report[2];
     z = report[3];
 
+    if (len_listen > sizeof(report)) {
+        len_listen = sizeof(report);
+    }
+
     if (dev)
         host->interruptRead(dev, int_in, report, len_listen, false);
 }