📄 usbtcdpdiusbd12endpoint.c
字号:
/* USB_TCD_PDIUSBD12_ENDPOINT */ pUSB_TCD_PDIUSBD12_TARGET pTarget = NULL; /* USB_TCD_PDIUSBD12_TARGET */ UINT8 byte = 0; /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncEndpointStatusGet entered ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointStatusGet: Entered \ ...\n",0,0,0,0,0,0); /* Validate parameters */ if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) || (pTrb->pipeHandle == 0) || (pTrb->pStatus == NULL)) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncEndpointStatusGet exiting: Bad Paramter Received ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ("usbTcdPdiusbd12FncEndpointStatusGet: Invalid \ Parameters ... \n",0,0,0,0,0,0); return ERROR; } pEndpointInfo = (pUSB_TCD_PDIUSBD12_ENDPOINT)pTrb->pipeHandle; pTarget = (pUSB_TCD_PDIUSBD12_TARGET)pHeader->handle; if ( pTarget == NULL ) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncEndpointStatusGet exiting: Error assigning pTarget ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ( "usbTcdPdiusbd12FncEndpointStatusGet : Error \ assigning pTarget...\n",0,0,0,0,0,0); return ERROR; } /* select endpoint command */ USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointStatusGet: Selecting \ Endpoint ...\n",0,0,0,0,0,0); byte = d12SelectEndpoint (pTarget , pEndpointInfo->endpointIndex); if ((byte & D12_CMD_SE_STALL) != 0) { /* endpoint is stalled */ USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointStatusGet: Endpoint \ is stalled ...\n",0,0,0,0,0,0); *(pTrb->pStatus) = 1; } else { /* endpoint is not in stalled state */ USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointStatusGet: Endpoint \ is un-stalled ...\n",0,0,0,0,0,0); *(pTrb->pStatus) = 0; } /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncEndpointStatusGet exiting...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointStatusGet: Exiting \ ...\n",0,0,0,0,0,0); return OK; }/********************************************************************************* usbTcdPdiusbd12FncIsBufferEmpty - implements TCD_FNC_IS_BUFFER_EMPTY** This function returns TRUE if the FIFO buffer associated with the endpoint* is empty..** RETURNS: OK or ERROR, if there is an error in checking the buffer status.** ERRNO:* None.** \NOMANUAL*/LOCAL STATUS usbTcdPdiusbd12FncIsBufferEmpty ( pTRB_IS_BUFFER_EMPTY pTrb /* TRB to be executed */ ) { pTRB_HEADER pHeader = (pTRB_HEADER) pTrb; /* TRB_HEADER */ pUSB_TCD_PDIUSBD12_ENDPOINT pEndpointInfo = NULL; /* USB_TCD_PDIUSBD12_ENDPOINT */ pUSB_TCD_PDIUSBD12_TARGET pTarget = NULL; /* USB_TCD_PDIUSBD12_TARGET */ UINT8 byte = 0; /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncIsBufferEmpty entered ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncIsBufferEmpty : Entered \ ...\n",0,0,0,0,0,0); /* Validate parameters */ if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) || (pTrb->pipeHandle == 0)) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncIsBufferEmpty exiting: Bad Paramter Received ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ("usbTcdPdiusbd12FncIsBufferEmpty : Invalid \ Parameter...\n",0,0,0,0,0,0); return ERROR; } pEndpointInfo = (pUSB_TCD_PDIUSBD12_ENDPOINT)pTrb->pipeHandle; pTarget = (pUSB_TCD_PDIUSBD12_TARGET)pHeader->handle; if ( pTarget == NULL ) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncIsBufferEmpty exiting: Error assigning pTarget ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ( "usbTcdPdiusbd12FncIsBufferEmpty : Error \ assigning pTarget...\n",0,0,0,0,0,0); return ERROR; } /* select endpoint command */ byte = d12SelectEndpoint (pTarget , pEndpointInfo->endpointIndex); if ((byte & D12_CMD_SE_FULL_EMPTY) == 0) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncIsBufferEmpty: Buffer is empty...", USB_TCD_PDIUSBD12_WV_FILTER); /* buffer is empty */ USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncIsBufferEmpty : Buffer is \ empty ...\n",0,0,0,0,0,0); pTrb->bufferEmpty = TRUE; } else { /* buffer is full */ /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncIsBufferEmpty: Buffer is full...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncIsBufferEmpty : Buffer is \ full ...\n",0,0,0,0,0,0); pTrb->bufferEmpty = FALSE; } USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncIsBufferEmpty : Exiting \ ...\n",0,0,0,0,0,0); /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncIsBufferEmpty exiting...", USB_TCD_PDIUSBD12_WV_FILTER); return OK; }/********************************************************************************* usbTcdPdiusbd12CopyDMABufferData - To copy data to/from the DMA buffer** The data which is copied to/from the DMA buffer is to be copied in* the sequence as follows* 1st packet as the 0th packet.* 0th packet as the 1st packet.* 3rd packet as the 2nd packet.* 2nd packet as the 3rd packet and so on.* This function copies data from source to destination in the above-mentioned* sequence** RETURNS: N/A** ERRNO:* None.** \NOMANUAL*/LOCAL VOID usbTcdPdiusbd12CopyDMABufferData ( char * pDestination, /* Destination Address */ char * pSource, /* Source to copy */ UINT32 sizeToCopy, /* Size of data to copy */ UINT16 maxPacketSize /* Maximum packet size */ ) { UINT32 tempSize = 0; UINT16 sizeCopied = 0; /* This loop continues till the size becomes 0 */ while (sizeToCopy >0) { sizeCopied = 0; /* * Check if the size to be copied is more than the * maximum packet size */ if (sizeToCopy > maxPacketSize) { if (sizeToCopy < (UINT32)(2 * maxPacketSize)) tempSize = sizeToCopy - maxPacketSize; else tempSize = maxPacketSize; /* Copy the data from the 2nd packet */ memcpy(pDestination, pSource + maxPacketSize, tempSize); /* Update the destination buffer */ pDestination += tempSize; /* Decrement the size remaining to be copied */ sizeToCopy -= tempSize; /* Update the size of data copied */ sizeCopied = tempSize; /* Update the size of data to be copied next */ tempSize = maxPacketSize; } else tempSize = sizeToCopy; /* Copy the 1st packet */ memcpy(pDestination,pSource, tempSize); /* Update the source pointer */ pSource += (tempSize + sizeCopied); /* Update the destination pointer */ pDestination += tempSize; /* Decrement the number of bytes remaining to be copied */ sizeToCopy -= tempSize; } return; } /********************************************************************************* usbTcdPdiusbd12FncCopyDataFromEpBuf - implements TCD_FNC_COPY_DATA_FROM _EPBUF** This function copies data from endpoint FIFO buffer into the buffer that is* passed.** RETURNS: OK if successfully copied, ERROR otherwise.** ERRNO:* None.** \NOMANUAL*/LOCAL STATUS usbTcdPdiusbd12FncCopyDataFromEpBuf ( pTRB_COPY_DATA_FROM_EPBUF pTrb /* TRB to be executed */ ) { pTRB_HEADER pHeader = (pTRB_HEADER) pTrb; /* TRB_HEADER */ pUSB_TCD_PDIUSBD12_ENDPOINT pEndpointInfo = NULL; /* USB_TCD_PDIUSBD12_ENDPOINT */ pUSB_TCD_PDIUSBD12_TARGET pTarget = NULL; /* pUSB_TCD_PDIUSBD12_TARGET */ UINT32 sizeToCopy = 0; /* size to copy */ /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncCopyDataFromEpBuf entered ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncCopyDataFromEpBuf : Entered \ ...\n",0,0,0,0,0,0); /* Validate parameters */ if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) || (pTrb->pipeHandle == 0)) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncCopyDataFromEpBuf exiting: Bad Paramter Received ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ("usbTcdPdiusbd12FncCopyDataFromEpBuf : Bad \ Parameter...\n",0,0,0,0,0,0); return ERROR; } pEndpointInfo = (pUSB_TCD_PDIUSBD12_ENDPOINT)pTrb->pipeHandle; pTarget = (pUSB_TCD_PDIUSBD12_TARGET)pHeader->handle; if ( pTarget == NULL ) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncCopyDataFromEpBuf exiting: Error assigning pTarget ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ( "usbTcdPdiusbd12FncCopyDataFromEpBuf : Error \ assigning pTarget...\n",0,0,0,0,0,0); return ERROR; } /* Check for main endpoint */ if (pEndpointInfo->endpointNo == D12_ENDPOINT_NO_2) { /* endpoint supports DMA */ /* Endpoint using DMA and DMA EOT */ if ((pTarget->dmaEndpointId == pEndpointInfo->endpointIndex) && (pTarget->dmaInUse) && (pTarget->dmaEot)) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncCopyDataFromEpBuf: end of DMA transfer detected...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncCopyDataFromEpBuf : \ Endpoint supports DMA and DMA is inuse...\n",0,0,0,0,0,0); /* Determine the size to copy */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -