void usbc_ep0_ack(void) { LTRACE_ENTRY; USBDevEndpointDataAck(USB0_BASE, USB_EP_0, true); }
//***************************************************************************** // //! Reads a packet of data received from the USB host via the bulk data //! interface. //! //! \param pvInstance is the pointer to the device instance structure as //! returned by USBDBulkInit(). //! \param pcData points to a buffer into which the received data will be //! written. //! \param ulLength is the size of the buffer pointed to by pcData. //! \param bLast indicates whether the client will make a further call to //! read additional data from the packet. //! //! This function reads up to \e ulLength bytes of data received from the USB //! host into the supplied application buffer. If the driver detects that the //! entire packet has been read, it is acknowledged to the host. //! //! The \e bLast parameter is ignored in this implementation since the end of //! a packet can be determined without relying upon the client to provide //! this information. //! //! \return Returns the number of bytes of data read. // //***************************************************************************** unsigned int USBDBulkPacketRead(void *pvInstance, unsigned char *pcData, unsigned int ulLength, tBoolean bLast) { unsigned int ulEPStatus, ulPkt; unsigned int ulCount; tBulkInstance *psInst; int iRetcode; ASSERT(pvInstance); // // Get our instance data pointer // psInst = ((tUSBDBulkDevice *)pvInstance)->psPrivateBulkData; // // Does the relevant endpoint FIFO have a packet waiting for us? // ulEPStatus = USBEndpointStatus(psInst->ulUSBBase, psInst->ucOUTEndpoint); if(ulEPStatus & USB_DEV_RX_PKT_RDY) { // // How many bytes are available for us to receive? // ulPkt = USBEndpointDataAvail(psInst->ulUSBBase, psInst->ucOUTEndpoint); // // Get as much data as we can. // ulCount = ulLength; iRetcode = USBEndpointDataGet(psInst->ulUSBBase, psInst->ucOUTEndpoint, pcData, &ulCount); // // Did we read the last of the packet data? // if(ulCount == ulPkt) { // // Clear the endpoint status so that we know no packet is // waiting. // USBDevEndpointStatusClear(psInst->ulUSBBase, psInst->ucOUTEndpoint, ulEPStatus); // // Acknowledge the data, thus freeing the host to send the // next packet. // USBDevEndpointDataAck(psInst->ulUSBBase, psInst->ucOUTEndpoint, true); // // Clear the flag we set to indicate that a packet read is // pending. // SetDeferredOpFlag(&psInst->usDeferredOpFlags, BULK_DO_PACKET_RX, false); } // // If all went well, tell the caller how many bytes they got. // if(iRetcode != -1) { return (ulCount); } } // // No packet was available or an error occurred while reading so tell // the caller no bytes were returned. // return (0); }