BTstack Bluetooth stack

Dependencies:   mbed USBHost

USBホストライブラリを変更しました。

  • Bluetoothマウス(VGP-BMS33)での動作を確認しました。mouse_demo.cpp
Revision:
0:1ed23ab1345f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usb/UsbBaseClass.cpp	Tue Jun 26 14:27:45 2012 +0000
@@ -0,0 +1,38 @@
+#include "UsbBaseClass.h"
+//#define __DEBUG
+#include "mydbg.h"
+
+UsbBaseClass::UsbBaseClass()
+{
+    if (m_pHost == NULL) {
+        m_pHost = new UsbHostMgr;
+        DBG_ASSERT(m_pHost);
+        m_pHost->init();
+    }
+    DBG("m_pHost=%p\n", m_pHost);
+}
+
+UsbErr UsbBaseClass::Usb_poll(int timeout, int timeout2)
+{
+    DBG("%p %d %d\n", this, timeout, timeout2);
+    Timer t;
+    t.reset();
+    t.start();
+    Timer t2;
+    t2.reset();
+    t2.start();
+    while(t.read_ms() < timeout) {
+        UsbErr rc = m_pHost->poll();
+        if (rc == USBERR_PROCESSING) {
+            t2.reset();
+        }
+        if (t2.read_ms() > timeout2) {
+            DBG("%p t=%d\n", this, t.read_ms());
+            return USBERR_OK;
+        }
+        wait_ms(50);
+    }
+    return USBERR_PROCESSING;
+}
+
+UsbHostMgr* UsbBaseClass::m_pHost = NULL;