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

Dependents:   BaseUsbHost_example BaseJpegDecode_example SimpleJpegDecode_example

Import programBaseUsbHost_example

BaseUsbHost example program

Revision:
2:fe1e62051d88
Parent:
1:3b7bc4f87a61
Child:
3:ae77d63a1eda
--- a/BaseUsbHostIntEp.cpp	Wed Dec 05 13:23:06 2012 +0000
+++ b/BaseUsbHostIntEp.cpp	Tue Dec 11 15:26:54 2012 +0000
@@ -1,4 +1,4 @@
-// BaseUsbHostIntEp.cpp 2012/12/5
+// BaseUsbHostIntEp.cpp 2012/12/11
 #include "mbed.h"
 #include "rtos.h"
 #include "BaseUsbHost.h"
@@ -11,12 +11,17 @@
     :BaseEp(addr, ep, size, lowSpeed)
 {
     HCTD* td = new_HCTD();
-    TEST_ASSERT(td);
     m_pED->TailTd = td;
     m_pED->HeadTd = td; 
-
+    TEST_ASSERT(td);
+    if (td == NULL) {
+        return;
+    }
     HCCA* pHcca = reinterpret_cast<HCCA*>(LPC_USB->HcHCCA);
     TEST_ASSERT(pHcca);
+    if (pHcca == NULL) {
+        return;
+    }
     int n = 0;
     m_pED->Next = pHcca->InterruptTable[n];
     pHcca->InterruptTable[n] = reinterpret_cast<uint32_t>(m_pED);
@@ -28,11 +33,17 @@
     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++;
@@ -41,15 +52,15 @@
     }
         
     HCTD* td = get_queue_HCTD(millisec);
-    if (td) {
-        DBG_TD(td);
-        int ret = len;
-        if (td->CurrBufPtr) {
-            ret = td->CurrBufPtr - buf;
-        }
-        delete_HCTD(td); 
-        m_td_queue_count--;
-        return ret;
+    if (td == NULL) {
+        return USB_PROCESSING;
     }
-    return USB_TIMEOUT;
+    DBG_TD(td);
+    int ret = len;
+    if (td->CurrBufPtr) {
+        ret = td->CurrBufPtr - buf;
+    }
+    delete_HCTD(td); 
+    m_td_queue_count--;
+    return ret;
 }