Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FatFileSystem TB6612FNG2 mbed
Diff: usb/UsbBaseClass.cpp
- Revision:
- 0:de03cbbcd0ff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usb/UsbBaseClass.cpp Mon Nov 30 09:32:15 2015 +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;