I have a problem getting this to work. Server only recieves half of the data being sent. Whats wrong

Dependencies:   mbed

Committer:
tax
Date:
Tue Mar 29 13:20:15 2011 +0000
Revision:
0:66300c77c6e9

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tax 0:66300c77c6e9 1
tax 0:66300c77c6e9 2 /*
tax 0:66300c77c6e9 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
tax 0:66300c77c6e9 4
tax 0:66300c77c6e9 5 Permission is hereby granted, free of charge, to any person obtaining a copy
tax 0:66300c77c6e9 6 of this software and associated documentation files (the "Software"), to deal
tax 0:66300c77c6e9 7 in the Software without restriction, including without limitation the rights
tax 0:66300c77c6e9 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
tax 0:66300c77c6e9 9 copies of the Software, and to permit persons to whom the Software is
tax 0:66300c77c6e9 10 furnished to do so, subject to the following conditions:
tax 0:66300c77c6e9 11
tax 0:66300c77c6e9 12 The above copyright notice and this permission notice shall be included in
tax 0:66300c77c6e9 13 all copies or substantial portions of the Software.
tax 0:66300c77c6e9 14
tax 0:66300c77c6e9 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
tax 0:66300c77c6e9 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
tax 0:66300c77c6e9 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
tax 0:66300c77c6e9 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
tax 0:66300c77c6e9 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tax 0:66300c77c6e9 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
tax 0:66300c77c6e9 21 THE SOFTWARE.
tax 0:66300c77c6e9 22 */
tax 0:66300c77c6e9 23
tax 0:66300c77c6e9 24 #include "UsbEndpoint.h"
tax 0:66300c77c6e9 25
tax 0:66300c77c6e9 26 #include "UsbDevice.h"
tax 0:66300c77c6e9 27
tax 0:66300c77c6e9 28 #include "usb_mem.h"
tax 0:66300c77c6e9 29
tax 0:66300c77c6e9 30 #include "netCfg.h"
tax 0:66300c77c6e9 31 #if NET_USB
tax 0:66300c77c6e9 32
tax 0:66300c77c6e9 33 //#define __DEBUG
tax 0:66300c77c6e9 34 #include "dbg/dbg.h"
tax 0:66300c77c6e9 35
tax 0:66300c77c6e9 36 UsbEndpoint::UsbEndpoint( UsbDevice* pDevice, uint8_t ep, bool dir, UsbEndpointType type, uint16_t size, int addr /*= -1*/ ) : m_pDevice(pDevice), m_result(true), m_status((int)USBERR_OK), m_len(0), m_pBufStartPtr(NULL),
tax 0:66300c77c6e9 37 m_pCbItem(NULL), m_pCbMeth(NULL), m_pNextEp(NULL)
tax 0:66300c77c6e9 38 {
tax 0:66300c77c6e9 39 //Insert into Eps list
tax 0:66300c77c6e9 40 //FIXME: Assert that no USB interrupt is triggered meanwhile
tax 0:66300c77c6e9 41 if(m_pHeadEp)
tax 0:66300c77c6e9 42 {
tax 0:66300c77c6e9 43 m_pNextEp = m_pHeadEp;
tax 0:66300c77c6e9 44 m_pHeadEp = this;
tax 0:66300c77c6e9 45 }
tax 0:66300c77c6e9 46 else
tax 0:66300c77c6e9 47 {
tax 0:66300c77c6e9 48 m_pNextEp = NULL;
tax 0:66300c77c6e9 49 m_pHeadEp = this;
tax 0:66300c77c6e9 50 }
tax 0:66300c77c6e9 51
tax 0:66300c77c6e9 52 m_pEd = (volatile HCED*)usb_get_ed();
tax 0:66300c77c6e9 53
tax 0:66300c77c6e9 54 m_pTdHead = (volatile HCTD*)usb_get_td();
tax 0:66300c77c6e9 55 m_pTdTail = (volatile HCTD*)usb_get_td();
tax 0:66300c77c6e9 56
tax 0:66300c77c6e9 57 //printf("\r\n--m_pEd = %p--\r\n", m_pEd);
tax 0:66300c77c6e9 58 DBG("m_pEd = %p\n", m_pEd);
tax 0:66300c77c6e9 59 DBG("m_pTdHead = %p\n", m_pTdHead);
tax 0:66300c77c6e9 60 DBG("m_pTdTail = %p\n", m_pTdTail);
tax 0:66300c77c6e9 61
tax 0:66300c77c6e9 62 //Init Ed & Td
tax 0:66300c77c6e9 63 //printf("\r\n--Ep Init--\r\n");
tax 0:66300c77c6e9 64 memset((void*)m_pEd, 0, sizeof(HCED));
tax 0:66300c77c6e9 65 //printf("\r\n--Td Init--\r\n");
tax 0:66300c77c6e9 66
tax 0:66300c77c6e9 67 memset((void*)m_pTdHead, 0, sizeof(HCTD));
tax 0:66300c77c6e9 68 memset((void*)m_pTdTail, 0, sizeof(HCTD));
tax 0:66300c77c6e9 69
tax 0:66300c77c6e9 70 if(addr == -1)
tax 0:66300c77c6e9 71 addr = pDevice->m_addr;
tax 0:66300c77c6e9 72
tax 0:66300c77c6e9 73 //Setup Ed
tax 0:66300c77c6e9 74 //printf("\r\n--Ep Setup--\r\n");
tax 0:66300c77c6e9 75 m_pEd->Control = addr | /* USB address */
tax 0:66300c77c6e9 76 ((ep & 0x7F) << 7) | /* Endpoint address */
tax 0:66300c77c6e9 77 (type!=USB_CONTROL?((dir?2:1) << 11):0) | /* direction : Out = 1, 2 = In */
tax 0:66300c77c6e9 78 (size << 16); /* MaxPkt Size */
tax 0:66300c77c6e9 79
tax 0:66300c77c6e9 80 m_dir = dir;
tax 0:66300c77c6e9 81 m_setup = false;
tax 0:66300c77c6e9 82 m_type = type;
tax 0:66300c77c6e9 83
tax 0:66300c77c6e9 84 m_pEd->TailTd = m_pEd->HeadTd = (uint32_t) m_pTdTail; //Empty TD list
tax 0:66300c77c6e9 85
tax 0:66300c77c6e9 86 DBG("Before link\n");
tax 0:66300c77c6e9 87
tax 0:66300c77c6e9 88 //printf("\r\n--Ep Reg--\r\n");
tax 0:66300c77c6e9 89 //Append Ed to Ed list
tax 0:66300c77c6e9 90 volatile HCED* prevEd;
tax 0:66300c77c6e9 91 switch( m_type )
tax 0:66300c77c6e9 92 {
tax 0:66300c77c6e9 93 case USB_CONTROL:
tax 0:66300c77c6e9 94 prevEd = (volatile HCED*) LPC_USB->HcControlHeadED;
tax 0:66300c77c6e9 95 break;
tax 0:66300c77c6e9 96 case USB_BULK:
tax 0:66300c77c6e9 97 default:
tax 0:66300c77c6e9 98 prevEd = (volatile HCED*) LPC_USB->HcBulkHeadED;
tax 0:66300c77c6e9 99 break;
tax 0:66300c77c6e9 100 }
tax 0:66300c77c6e9 101
tax 0:66300c77c6e9 102 DBG("prevEd is %p\n", prevEd);
tax 0:66300c77c6e9 103
tax 0:66300c77c6e9 104 if(prevEd)
tax 0:66300c77c6e9 105 {
tax 0:66300c77c6e9 106 DBG("prevEd set\n")
tax 0:66300c77c6e9 107
tax 0:66300c77c6e9 108 while(prevEd->Next)
tax 0:66300c77c6e9 109 {
tax 0:66300c77c6e9 110 DBG("prevEd->Next = %08x\n", prevEd->Next);
tax 0:66300c77c6e9 111 prevEd = (volatile HCED*) prevEd->Next;
tax 0:66300c77c6e9 112 }
tax 0:66300c77c6e9 113 prevEd->Next = (uint32_t) m_pEd;
tax 0:66300c77c6e9 114
tax 0:66300c77c6e9 115 }
tax 0:66300c77c6e9 116 else
tax 0:66300c77c6e9 117 {
tax 0:66300c77c6e9 118 switch( m_type )
tax 0:66300c77c6e9 119 {
tax 0:66300c77c6e9 120 case USB_CONTROL:
tax 0:66300c77c6e9 121 LPC_USB->HcControlHeadED = (uint32_t) m_pEd;
tax 0:66300c77c6e9 122 break;
tax 0:66300c77c6e9 123 case USB_BULK:
tax 0:66300c77c6e9 124 default:
tax 0:66300c77c6e9 125 LPC_USB->HcBulkHeadED = (uint32_t) m_pEd;
tax 0:66300c77c6e9 126 break;
tax 0:66300c77c6e9 127 }
tax 0:66300c77c6e9 128 }
tax 0:66300c77c6e9 129
tax 0:66300c77c6e9 130 DBG("Ep init\n");
tax 0:66300c77c6e9 131 }
tax 0:66300c77c6e9 132
tax 0:66300c77c6e9 133 UsbEndpoint::~UsbEndpoint()
tax 0:66300c77c6e9 134 {
tax 0:66300c77c6e9 135 //Remove from Eps list
tax 0:66300c77c6e9 136 //FIXME: Assert that no USB interrupt is triggered meanwhile
tax 0:66300c77c6e9 137 if(m_pHeadEp != this)
tax 0:66300c77c6e9 138 {
tax 0:66300c77c6e9 139 UsbEndpoint* prevEp = m_pHeadEp;
tax 0:66300c77c6e9 140 while(prevEp->m_pNextEp != this)
tax 0:66300c77c6e9 141 prevEp = prevEp->m_pNextEp;
tax 0:66300c77c6e9 142 prevEp->m_pNextEp = m_pNextEp;
tax 0:66300c77c6e9 143 }
tax 0:66300c77c6e9 144 else
tax 0:66300c77c6e9 145 {
tax 0:66300c77c6e9 146 m_pHeadEp = m_pNextEp;
tax 0:66300c77c6e9 147 }
tax 0:66300c77c6e9 148
tax 0:66300c77c6e9 149 m_pEd->Control |= ED_SKIP; //Skip this Ep in queue
tax 0:66300c77c6e9 150
tax 0:66300c77c6e9 151 //Remove from queue
tax 0:66300c77c6e9 152 volatile HCED* prevEd;
tax 0:66300c77c6e9 153 switch( m_type )
tax 0:66300c77c6e9 154 {
tax 0:66300c77c6e9 155 case USB_CONTROL:
tax 0:66300c77c6e9 156 prevEd = (volatile HCED*) LPC_USB->HcControlHeadED;
tax 0:66300c77c6e9 157 break;
tax 0:66300c77c6e9 158 case USB_BULK:
tax 0:66300c77c6e9 159 default:
tax 0:66300c77c6e9 160 prevEd = (volatile HCED*) LPC_USB->HcBulkHeadED;
tax 0:66300c77c6e9 161 break;
tax 0:66300c77c6e9 162 }
tax 0:66300c77c6e9 163 if( m_pEd == prevEd )
tax 0:66300c77c6e9 164 {
tax 0:66300c77c6e9 165 switch( m_type )
tax 0:66300c77c6e9 166 {
tax 0:66300c77c6e9 167 case USB_CONTROL:
tax 0:66300c77c6e9 168 LPC_USB->HcControlHeadED = m_pEd->Next;
tax 0:66300c77c6e9 169 break;
tax 0:66300c77c6e9 170 case USB_BULK:
tax 0:66300c77c6e9 171 default:
tax 0:66300c77c6e9 172 LPC_USB->HcBulkHeadED = m_pEd->Next;
tax 0:66300c77c6e9 173 break;
tax 0:66300c77c6e9 174 }
tax 0:66300c77c6e9 175 LPC_USB->HcBulkHeadED = m_pEd->Next;
tax 0:66300c77c6e9 176 }
tax 0:66300c77c6e9 177 else
tax 0:66300c77c6e9 178 {
tax 0:66300c77c6e9 179 while( prevEd->Next != (uint32_t) m_pEd )
tax 0:66300c77c6e9 180 {
tax 0:66300c77c6e9 181 prevEd = (volatile HCED*) prevEd->Next;
tax 0:66300c77c6e9 182 }
tax 0:66300c77c6e9 183 prevEd->Next = m_pEd->Next;
tax 0:66300c77c6e9 184 }
tax 0:66300c77c6e9 185
tax 0:66300c77c6e9 186 //
tax 0:66300c77c6e9 187 usb_free_ed((volatile byte*)m_pEd);
tax 0:66300c77c6e9 188
tax 0:66300c77c6e9 189 usb_free_td((volatile byte*)m_pTdHead);
tax 0:66300c77c6e9 190 usb_free_td((volatile byte*)m_pTdTail);
tax 0:66300c77c6e9 191 }
tax 0:66300c77c6e9 192
tax 0:66300c77c6e9 193 void UsbEndpoint::setNextToken(uint32_t token) //Only for control Eps
tax 0:66300c77c6e9 194 {
tax 0:66300c77c6e9 195 switch(token)
tax 0:66300c77c6e9 196 {
tax 0:66300c77c6e9 197 case TD_SETUP:
tax 0:66300c77c6e9 198 m_dir = false;
tax 0:66300c77c6e9 199 m_setup = true;
tax 0:66300c77c6e9 200 break;
tax 0:66300c77c6e9 201 case TD_IN:
tax 0:66300c77c6e9 202 m_dir = true;
tax 0:66300c77c6e9 203 m_setup = false;
tax 0:66300c77c6e9 204 break;
tax 0:66300c77c6e9 205 case TD_OUT:
tax 0:66300c77c6e9 206 m_dir = false;
tax 0:66300c77c6e9 207 m_setup = false;
tax 0:66300c77c6e9 208 break;
tax 0:66300c77c6e9 209 }
tax 0:66300c77c6e9 210 }
tax 0:66300c77c6e9 211
tax 0:66300c77c6e9 212 UsbErr UsbEndpoint::transfer(volatile uint8_t* buf, uint32_t len)
tax 0:66300c77c6e9 213 {
tax 0:66300c77c6e9 214 if(!m_result)
tax 0:66300c77c6e9 215 return USBERR_BUSY; //The previous trasnfer is not completed
tax 0:66300c77c6e9 216 //FIXME: We should be able to queue the next transfer, still needs to be implemented
tax 0:66300c77c6e9 217
tax 0:66300c77c6e9 218 if( !m_pDevice->connected() )
tax 0:66300c77c6e9 219 return USBERR_DISCONNECTED;
tax 0:66300c77c6e9 220
tax 0:66300c77c6e9 221 m_result = false;
tax 0:66300c77c6e9 222
tax 0:66300c77c6e9 223 volatile uint32_t token = (m_setup?TD_SETUP:(m_dir?TD_IN:TD_OUT));
tax 0:66300c77c6e9 224
tax 0:66300c77c6e9 225 volatile uint32_t td_toggle;
tax 0:66300c77c6e9 226 if (m_type == USB_CONTROL)
tax 0:66300c77c6e9 227 {
tax 0:66300c77c6e9 228 if (m_setup)
tax 0:66300c77c6e9 229 {
tax 0:66300c77c6e9 230 td_toggle = TD_TOGGLE_0;
tax 0:66300c77c6e9 231 }
tax 0:66300c77c6e9 232 else
tax 0:66300c77c6e9 233 {
tax 0:66300c77c6e9 234 td_toggle = TD_TOGGLE_1;
tax 0:66300c77c6e9 235 }
tax 0:66300c77c6e9 236 }
tax 0:66300c77c6e9 237 else
tax 0:66300c77c6e9 238 {
tax 0:66300c77c6e9 239 td_toggle = 0;
tax 0:66300c77c6e9 240 }
tax 0:66300c77c6e9 241
tax 0:66300c77c6e9 242 //Swap Tds
tax 0:66300c77c6e9 243 volatile HCTD* pTdSwap;
tax 0:66300c77c6e9 244 pTdSwap = m_pTdTail;
tax 0:66300c77c6e9 245 m_pTdTail = m_pTdHead;
tax 0:66300c77c6e9 246 m_pTdHead = pTdSwap;
tax 0:66300c77c6e9 247
tax 0:66300c77c6e9 248 m_pTdHead->Control = (TD_ROUNDING |
tax 0:66300c77c6e9 249 token |
tax 0:66300c77c6e9 250 TD_DELAY_INT(0) |//7
tax 0:66300c77c6e9 251 td_toggle |
tax 0:66300c77c6e9 252 TD_CC);
tax 0:66300c77c6e9 253
tax 0:66300c77c6e9 254 m_pTdTail->Control = 0;
tax 0:66300c77c6e9 255 m_pTdHead->CurrBufPtr = (uint32_t) buf;
tax 0:66300c77c6e9 256 m_pBufStartPtr = buf;
tax 0:66300c77c6e9 257 m_pTdTail->CurrBufPtr = 0;
tax 0:66300c77c6e9 258 m_pTdHead->Next = (uint32_t) m_pTdTail;
tax 0:66300c77c6e9 259 m_pTdTail->Next = 0;
tax 0:66300c77c6e9 260 m_pTdHead->BufEnd = (uint32_t)(buf + (len - 1));
tax 0:66300c77c6e9 261 m_pTdTail->BufEnd = 0;
tax 0:66300c77c6e9 262
tax 0:66300c77c6e9 263 m_pEd->HeadTd = (uint32_t)m_pTdHead | ((m_pEd->HeadTd) & 0x00000002); //Carry bit
tax 0:66300c77c6e9 264 m_pEd->TailTd = (uint32_t)m_pTdTail;
tax 0:66300c77c6e9 265
tax 0:66300c77c6e9 266 //DBG("m_pEd->HeadTd = %08x\n", m_pEd->HeadTd);
tax 0:66300c77c6e9 267
tax 0:66300c77c6e9 268 if(m_type == USB_CONTROL)
tax 0:66300c77c6e9 269 {
tax 0:66300c77c6e9 270 LPC_USB->HcCommandStatus = LPC_USB->HcCommandStatus | OR_CMD_STATUS_CLF;
tax 0:66300c77c6e9 271 LPC_USB->HcControl = LPC_USB->HcControl | OR_CONTROL_CLE; //Enable control list
tax 0:66300c77c6e9 272 }
tax 0:66300c77c6e9 273 else //USB_BULK
tax 0:66300c77c6e9 274 {
tax 0:66300c77c6e9 275 LPC_USB->HcCommandStatus = LPC_USB->HcCommandStatus | OR_CMD_STATUS_BLF;
tax 0:66300c77c6e9 276 LPC_USB->HcControl = LPC_USB->HcControl | OR_CONTROL_BLE; //Enable bulk list
tax 0:66300c77c6e9 277 }
tax 0:66300c77c6e9 278
tax 0:66300c77c6e9 279 //m_done = false;
tax 0:66300c77c6e9 280 m_len = len;
tax 0:66300c77c6e9 281
tax 0:66300c77c6e9 282 return USBERR_PROCESSING;
tax 0:66300c77c6e9 283
tax 0:66300c77c6e9 284 }
tax 0:66300c77c6e9 285
tax 0:66300c77c6e9 286 int UsbEndpoint::status()
tax 0:66300c77c6e9 287 {
tax 0:66300c77c6e9 288 if( !m_pDevice->connected() )
tax 0:66300c77c6e9 289 {
tax 0:66300c77c6e9 290 if(!m_result)
tax 0:66300c77c6e9 291 onCompletion();
tax 0:66300c77c6e9 292 m_result = true;
tax 0:66300c77c6e9 293 return (int)USBERR_DISCONNECTED;
tax 0:66300c77c6e9 294 }
tax 0:66300c77c6e9 295 else if( !m_result )
tax 0:66300c77c6e9 296 {
tax 0:66300c77c6e9 297 return (int)USBERR_PROCESSING;
tax 0:66300c77c6e9 298 }
tax 0:66300c77c6e9 299 /*else if( m_done )
tax 0:66300c77c6e9 300 {
tax 0:66300c77c6e9 301 return (int)USBERR_OK;
tax 0:66300c77c6e9 302 }*/
tax 0:66300c77c6e9 303 else
tax 0:66300c77c6e9 304 {
tax 0:66300c77c6e9 305 return m_status;
tax 0:66300c77c6e9 306 }
tax 0:66300c77c6e9 307 }
tax 0:66300c77c6e9 308
tax 0:66300c77c6e9 309 void UsbEndpoint::updateAddr(int addr)
tax 0:66300c77c6e9 310 {
tax 0:66300c77c6e9 311 DBG("m_pEd->Control = %08x\n", m_pEd->Control);
tax 0:66300c77c6e9 312 m_pEd->Control &= ~0x7F;
tax 0:66300c77c6e9 313 m_pEd->Control |= addr;
tax 0:66300c77c6e9 314 DBG("m_pEd->Control = %08x\n", m_pEd->Control);
tax 0:66300c77c6e9 315 }
tax 0:66300c77c6e9 316
tax 0:66300c77c6e9 317 void UsbEndpoint::updateSize(uint16_t size)
tax 0:66300c77c6e9 318 {
tax 0:66300c77c6e9 319 DBG("m_pEd->Control = %08x\n", m_pEd->Control);
tax 0:66300c77c6e9 320 m_pEd->Control &= ~0x3FF0000;
tax 0:66300c77c6e9 321 m_pEd->Control |= (size << 16);
tax 0:66300c77c6e9 322 DBG("m_pEd->Control = %08x\n", m_pEd->Control);
tax 0:66300c77c6e9 323 }
tax 0:66300c77c6e9 324
tax 0:66300c77c6e9 325 #if 0 //For doc only
tax 0:66300c77c6e9 326 template <class T>
tax 0:66300c77c6e9 327 void UsbEndpoint::setOnCompletion( T* pCbItem, void (T::*pCbMeth)() )
tax 0:66300c77c6e9 328 {
tax 0:66300c77c6e9 329 m_pCbItem = (CDummy*) pCbItem;
tax 0:66300c77c6e9 330 m_pCbMeth = (void (CDummy::*)()) pCbMeth;
tax 0:66300c77c6e9 331 }
tax 0:66300c77c6e9 332 #endif
tax 0:66300c77c6e9 333
tax 0:66300c77c6e9 334 void UsbEndpoint::onCompletion()
tax 0:66300c77c6e9 335 {
tax 0:66300c77c6e9 336 //DBG("Transfer completed\n");
tax 0:66300c77c6e9 337 if( m_pTdHead->Control >> 28 )
tax 0:66300c77c6e9 338 {
tax 0:66300c77c6e9 339 DBG("TD Failed with condition code %01x\n", m_pTdHead->Control >> 28 );
tax 0:66300c77c6e9 340 m_status = (int)USBERR_TDFAIL;
tax 0:66300c77c6e9 341 }
tax 0:66300c77c6e9 342 else if( m_pEd->HeadTd & 0x1 )
tax 0:66300c77c6e9 343 {
tax 0:66300c77c6e9 344 m_pEd->HeadTd = m_pEd->HeadTd & ~0x1;
tax 0:66300c77c6e9 345 DBG("\r\nHALTED!!\r\n");
tax 0:66300c77c6e9 346 m_status = (int)USBERR_HALTED;
tax 0:66300c77c6e9 347 }
tax 0:66300c77c6e9 348 else if( (m_pEd->HeadTd & ~0xF) == (uint32_t) m_pTdTail )
tax 0:66300c77c6e9 349 {
tax 0:66300c77c6e9 350 //Done
tax 0:66300c77c6e9 351 int len;
tax 0:66300c77c6e9 352 //DBG("m_pTdHead->CurrBufPtr = %08x, m_pBufStartPtr=%08x\n", m_pTdHead->CurrBufPtr, (uint32_t) m_pBufStartPtr);
tax 0:66300c77c6e9 353 if(m_pTdHead->CurrBufPtr)
tax 0:66300c77c6e9 354 len = m_pTdHead->CurrBufPtr - (uint32_t) m_pBufStartPtr;
tax 0:66300c77c6e9 355 else
tax 0:66300c77c6e9 356 len = m_len;
tax 0:66300c77c6e9 357 /*if(len == 0) //Packet transfered completely
tax 0:66300c77c6e9 358 len = m_len;*/
tax 0:66300c77c6e9 359 //m_done = true;
tax 0:66300c77c6e9 360 DBG("Transfered %d bytes\n", len);
tax 0:66300c77c6e9 361 m_status = len;
tax 0:66300c77c6e9 362 }
tax 0:66300c77c6e9 363 else
tax 0:66300c77c6e9 364 {
tax 0:66300c77c6e9 365 DBG("Unknown error...\n");
tax 0:66300c77c6e9 366 m_status = (int)USBERR_ERROR;
tax 0:66300c77c6e9 367 }
tax 0:66300c77c6e9 368 m_result = true;
tax 0:66300c77c6e9 369 if(m_pCbItem && m_pCbMeth)
tax 0:66300c77c6e9 370 (m_pCbItem->*m_pCbMeth)();
tax 0:66300c77c6e9 371 }
tax 0:66300c77c6e9 372
tax 0:66300c77c6e9 373 void UsbEndpoint::sOnCompletion(uint32_t pTd)
tax 0:66300c77c6e9 374 {
tax 0:66300c77c6e9 375 if(!m_pHeadEp)
tax 0:66300c77c6e9 376 return;
tax 0:66300c77c6e9 377 do
tax 0:66300c77c6e9 378 {
tax 0:66300c77c6e9 379 //DBG("sOnCompletion (pTd = %08x)\n", pTd);
tax 0:66300c77c6e9 380 UsbEndpoint* pEp = m_pHeadEp;
tax 0:66300c77c6e9 381 do
tax 0:66300c77c6e9 382 {
tax 0:66300c77c6e9 383 if((uint32_t)pEp->m_pTdHead == pTd)
tax 0:66300c77c6e9 384 {
tax 0:66300c77c6e9 385 pEp->onCompletion();
tax 0:66300c77c6e9 386 break;
tax 0:66300c77c6e9 387 }
tax 0:66300c77c6e9 388 } while(pEp = pEp->m_pNextEp);
tax 0:66300c77c6e9 389 } while( pTd = (uint32_t)( ((HCTD*)pTd)->Next ) ); //Go around the Done queue
tax 0:66300c77c6e9 390 }
tax 0:66300c77c6e9 391
tax 0:66300c77c6e9 392 UsbEndpoint* UsbEndpoint::m_pHeadEp = NULL;
tax 0:66300c77c6e9 393
tax 0:66300c77c6e9 394 #endif