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
usb/UsbBaseClass.cpp@0:de03cbbcd0ff, 2015-11-30 (annotated)
- Committer:
- mbed_Cookbook_SE
- Date:
- Mon Nov 30 09:32:15 2015 +0000
- Revision:
- 0:de03cbbcd0ff
??
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 1 | #include "UsbBaseClass.h" | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 2 | //#define __DEBUG | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 3 | #include "mydbg.h" | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 4 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 5 | UsbBaseClass::UsbBaseClass() | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 6 | { | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 7 | if (m_pHost == NULL) { | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 8 | m_pHost = new UsbHostMgr; | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 9 | DBG_ASSERT(m_pHost); | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 10 | m_pHost->init(); | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 11 | } | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 12 | DBG("m_pHost=%p\n", m_pHost); | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 13 | } | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 14 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 15 | UsbErr UsbBaseClass::Usb_poll(int timeout, int timeout2) | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 16 | { | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 17 | DBG("%p %d %d\n", this, timeout, timeout2); | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 18 | Timer t; | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 19 | t.reset(); | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 20 | t.start(); | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 21 | Timer t2; | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 22 | t2.reset(); | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 23 | t2.start(); | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 24 | while(t.read_ms() < timeout) { | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 25 | UsbErr rc = m_pHost->poll(); | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 26 | if (rc == USBERR_PROCESSING) { | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 27 | t2.reset(); | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 28 | } | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 29 | if (t2.read_ms() > timeout2) { | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 30 | DBG("%p t=%d\n", this, t.read_ms()); | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 31 | return USBERR_OK; | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 32 | } | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 33 | wait_ms(50); | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 34 | } | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 35 | return USBERR_PROCESSING; | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 36 | } | 
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 37 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 38 | UsbHostMgr* UsbBaseClass::m_pHost = NULL; |