EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t *data, uint32_t *bytesRead) { uint8_t bf = 0; if (!(epComplete & EP(endpoint))) return EP_PENDING; else { epComplete &= ~EP(endpoint); //check which buffer has been filled if (LPC_USB->EPBUFCFG & EP(endpoint)) { // Double buffered (here we read the previous buffer which was used) if (LPC_USB->EPINUSE & EP(endpoint)) { bf = 0; } else { bf = 1; } } // Find how many bytes were read *bytesRead = (uint32_t) (endpointState[endpoint].maxPacket - BYTES_REMAINING(ep[PHY_TO_LOG(endpoint)].out[bf])); // Copy data USBMemCopy(data, ct->out, *bytesRead); return EP_COMPLETED; } }
uint32_t USBHAL::EP0getReadResult(uint8_t *buffer) { // Complete an endpoint 0 read uint32_t bytesRead; // Find how many bytes were read bytesRead = MAX_PACKET_SIZE_EP0 - BYTES_REMAINING(ep[0].out[0]); // Copy data USBMemCopy(buffer, ct->out, bytesRead); return bytesRead; }
DWORD LWNetReadGUID( OUT PBYTE pbtDest, IN PACKED_ARRAY* pArray ) { DWORD dwError = 0; if (BYTES_REMAINING((*pArray)) < LWNET_GUID_SIZE) { dwError = DNS_ERROR_BAD_PACKET; BAIL_ON_LWNET_ERROR(dwError); } memcpy(pbtDest, pArray->pCur, LWNET_GUID_SIZE); pArray->pCur += LWNET_GUID_SIZE; error: return dwError; }