USB host library, support isochronous,bulk,interrupt and control.

Dependents:   BaseUsbHost_example BaseJpegDecode_example SimpleJpegDecode_example

Import programBaseUsbHost_example

BaseUsbHost example program

Revision:
3:ae77d63a1eda
Parent:
2:fe1e62051d88
Child:
4:d931d24c2f81
--- a/BaseUsbHostIntEp.cpp	Tue Dec 11 15:26:54 2012 +0000
+++ b/BaseUsbHostIntEp.cpp	Sun Jan 06 11:45:18 2013 +0000
@@ -1,4 +1,4 @@
-// BaseUsbHostIntEp.cpp 2012/12/11
+// BaseUsbHostIntEp.cpp 2012/12/24
 #include "mbed.h"
 #include "rtos.h"
 #include "BaseUsbHost.h"
@@ -11,8 +11,8 @@
     :BaseEp(addr, ep, size, lowSpeed)
 {
     HCTD* td = new_HCTD();
+    m_pED->HeadTd = td; 
     m_pED->TailTd = td;
-    m_pED->HeadTd = td; 
     TEST_ASSERT(td);
     if (td == NULL) {
         return;
@@ -25,42 +25,16 @@
     int n = 0;
     m_pED->Next = pHcca->InterruptTable[n];
     pHcca->InterruptTable[n] = reinterpret_cast<uint32_t>(m_pED);
+
+    DBG_ED(m_pED);
+}
+
+void InterruptEp::enable()
+{
     LPC_USB->HcControl |= OR_CONTROL_PLE;
 }
     
 int InterruptEp::interruptReceive(uint8_t* buf, int len, int millisec)
 {
-    if (m_td_queue_count == 0) {
-        HCTD* data_td = m_pED->TailTd;
-        TEST_ASSERT(data_td);
-        if (data_td == NULL) {
-            return USB_ERROR;
-        }
-        data_td->Control |= TD_IN;
-        data_td->CurrBufPtr = buf;
-        data_td->BufEnd = const_cast<uint8_t*>(buf)+len-1;
-        HCTD* blank_td = new_HCTD();
-        TEST_ASSERT(blank_td);
-        if (blank_td == NULL) {
-            return USB_ERROR_MEMORY;
-        }
-        data_td->Next = reinterpret_cast<uint32_t>(blank_td);
-        m_pED->TailTd = blank_td;
-        m_td_queue_count++;
-        DBG_ED(m_pED);
-        LPC_USB->HcControl |= OR_CONTROL_PLE; // Enable Periodic
-    }
-        
-    HCTD* td = get_queue_HCTD(millisec);
-    if (td == NULL) {
-        return USB_PROCESSING;
-    }
-    DBG_TD(td);
-    int ret = len;
-    if (td->CurrBufPtr) {
-        ret = td->CurrBufPtr - buf;
-    }
-    delete_HCTD(td); 
-    m_td_queue_count--;
-    return ret;
+    return send_receive(buf, len, millisec);
 }