📄 usbtcdpdiusbd12endpoint.c
字号:
/* * Check whether the main endpoint supports anny generic transfer, * if so retunr error */ if (pTarget->epMainGenericCount != 0) { USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointAssign: \ Mode not supported...\n",0,0,0,0,0,0); /* Free the memory allocated */ OSS_FREE (pEndpointInfo); return ERROR; } /* Clear the current mode of operation */ pTarget->configByte &= ~D12_CMD_SM_CFG_MODE_MASK; switch (direction) { case USB_DIR_OUT: if((pTarget->endpointIndexInUse & ( 0x1 << D12_ENDPOINT_2_IN)) != 0) pTarget->configByte |= D12_CMD_SM_CFG_MODE3_ISO_IO; else pTarget->configByte |= D12_CMD_SM_CFG_MODE1_ISO_OUT; break; case USB_DIR_IN: if((pTarget->endpointIndexInUse & (0x1 << D12_ENDPOINT_2_OUT)) != 0) pTarget->configByte |= D12_CMD_SM_CFG_MODE3_ISO_IO; else pTarget->configByte |= D12_CMD_SM_CFG_MODE2_ISO_IN; break; default: return ERROR; } USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointAssign : Giving \ Set Mode Command ...\n",0,0,0,0,0,0); d12SetMode (pTarget); } /* Increment the main endpoint count */ pTarget->epMainCount++; } if ((endpointNo == D12_ENDPOINT_NO_2) || (endpointNo == D12_ENDPOINT_NO_1)) { if (++pTarget->epOneAndTwoCount == 1) d12SetEndpointEnable (pTarget, TRUE); } /* update endpointIndexInUse */ pTarget->endpointIndexInUse |= (0x1 << endpointIndex); /* Enable the endpoint as necessary. */ d12SetEndpointStatus (pTarget, endpointIndex, 0); /* reset to DATA0 */ /* Clear the buffer if it is an OUT endpoint */ if (direction == USB_ENDPOINT_OUT) { d12SelectEndpoint(pTarget,endpointIndex); d12ClearBfr(pTarget); } /* update the handle */ USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointAssign: update the \ handle... \n",0,0,0,0,0,0); /* Store the handle */ pTrb->pipeHandle = (UINT32)pEndpointInfo; /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncEndpointAssign exiting...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointAssign: Exiting \ ...\n",0,0,0,0,0,0); return OK; }/********************************************************************************* usbTcdPdiusbd12FncEndpointRelease - implements TCD_FNC_ENDPOINT_RELEASE** This function assigns an endpoint for a specific kind of transfer.** RETURNS: OK or ERROR if failed to unconfigure the endpoint** ERRNO:* None.** \NOMANUAL*/LOCAL STATUS usbTcdPdiusbd12FncEndpointRelease ( pTRB_ENDPOINT_RELEASE pTrb /* TRB to be executed */ ) { pTRB_HEADER pHeader = (pTRB_HEADER) pTrb; /* TRB_HEADER */ pUSB_TCD_PDIUSBD12_TARGET pTarget = NULL; /* USB_TCD_PDIUSBD12_TARGET */ pUSB_TCD_PDIUSBD12_ENDPOINT pEndpointInfo = NULL; /* USB_TCD_PDIUSBD12_ENDPOINT */ /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncEndpointRelease entered ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointRelease: 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, "usbTcdPdiusbd12FncEndpointRelease exiting: Bad Paramter Received ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ("usbTcdPdiusbd12FncEndpointRelease : 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, "usbTcdPdiusbd12FncEndpointRelease exiting: Error assigning pTarget ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ( "usbTcdPdiusbd12FncEndpointAssign : Error \ assigning pTarget...\n",0,0,0,0,0,0); return ERROR; } /* update endpointIndexInUse */ pTarget->endpointIndexInUse &= ~(0x1 << pEndpointInfo->endpointIndex); /* if main endpoint */ if ( pEndpointInfo->endpointNo == D12_ENDPOINT_NO_2 ) { USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointRelease : Releasing \ the main endpoint...\n",0,0,0,0,0,0); pTarget->epMainCount-- ; if ((pEndpointInfo->transferType == USB_ATTR_BULK) || (pEndpointInfo->transferType ==USB_ATTR_INTERRUPT)) if ( pTarget->epMainGenericCount != 0) pTarget->epMainGenericCount--; /* Check if the transfer type is isochronous */ if (pEndpointInfo->transferType == USB_ATTR_ISOCH ) { USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointRelease : Setting \ the mode of operation ...\n",0,0,0,0,0,0); /* Clear the current mode of operation */ pTarget->configByte &= ~D12_CMD_SM_CFG_MODE_MASK; /* Switch based on the direction of endpoint */ switch (pEndpointInfo->direction) { case USB_DIR_OUT: if((pTarget->endpointIndexInUse & ( 0x1 << D12_ENDPOINT_2_IN)) != 0) pTarget->configByte |= D12_CMD_SM_CFG_MODE2_ISO_IN; else pTarget->configByte |= D12_CMD_SM_CFG_MODE0_NON_ISO; break; case USB_DIR_IN: if((pTarget->endpointIndexInUse & ( 0x1 << D12_ENDPOINT_2_OUT)) != 0) pTarget->configByte |= D12_CMD_SM_CFG_MODE1_ISO_OUT; else pTarget->configByte |= D12_CMD_SM_CFG_MODE0_NON_ISO; break; default: return ERROR; } d12SetMode (pTarget); } } if ((pEndpointInfo->endpointNo == D12_ENDPOINT_NO_2) || (pEndpointInfo->endpointNo == D12_ENDPOINT_NO_1)) { if (--pTarget->epOneAndTwoCount == 0) d12SetEndpointEnable (pTarget, FALSE); } USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointRelease : Releasing the \ resource alloted endpoint...\n",0,0,0,0,0,0); OSS_FREE(pEndpointInfo); /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncEndpointRelease exiting...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointRelease : Exiting \ ...\n",0,0,0,0,0,0); return OK; }/********************************************************************************* usbTcdPdiusbd12FncEndpointStateSet - implements TCD_FNC_ENDPOINT_STATE_SET** This function sets endpoint state as stalled or un-stalled.** RETURNS: OK or ERROR, it not able to set the state of the endpoint** ERRNO:* None.** \NOMANUAL*/LOCAL STATUS usbTcdPdiusbd12FncEndpointStateSet ( pTRB_ENDPOINT_STATE_SET 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 */ /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncEndpointStateSet entered ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointStateSet : 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, "usbTcdPdiusbd12FncEndpointStateSet exiting: Bad Paramter Received ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ("usbTcdPdiusbd12FncEndpointStateSet: 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, "usbTcdPdiusbd12FncEndpointStateSet exiting: Error assigning pTarget ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ( "usbTcdPdiusbd12FncEndpointStateSet : Error \ assigning pTarget...\n",0,0,0,0,0,0); return ERROR; } if(pTrb->state == TCD_ENDPOINT_STALL) { /* stall the endpoint */ USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointStateSet: Stalling \ the Endpoint ...\n",0,0,0,0,0,0); d12SetEndpointStatus(pTarget, pEndpointInfo->endpointIndex,D12_CMD_SES_STALLED); /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncEndpointStateSet: Endpoint Stalled ...", USB_TCD_PDIUSBD12_WV_FILTER); } else if (pTrb->state == TCD_ENDPOINT_UNSTALL) { /* unstall the endpoint */ USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointStateSet: Un-stalling \ the Endpoint ...\n",0,0,0,0,0,0); d12SetEndpointStatus(pTarget, pEndpointInfo->endpointIndex ,D12_CMD_SES_UNSTALLED); /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncEndpointStateSet: Endpoint Un-Stalled ...", USB_TCD_PDIUSBD12_WV_FILTER); } else { USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointStateSet: Invalid state\ ...\n",0,0,0,0,0,0); return ERROR; } /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_ENDPOINT, "usbTcdPdiusbd12FncEndpointStatusSet exiting...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEndpointStateSet: Exiting \ ...\n",0,0,0,0,0,0); return OK; }/********************************************************************************* usbTcdPdiusbd12FncEndpointStatusGet - implements TCD_FNC_ENDPOINT_STATUS_GET** This function returns the status of an endpoint ie whether it is STALLED or* not.** RETURNS: OK or ERROR, it not able to get the state of the endpoint** ERRNO:* None.** \NOMANUAL*/STATUS usbTcdPdiusbd12FncEndpointStatusGet ( pTRB_ENDPOINT_STATUS_GET pTrb /* TRB to be executed */ ) { pTRB_HEADER pHeader = (pTRB_HEADER) pTrb; /* TRB_HEADER */ pUSB_TCD_PDIUSBD12_ENDPOINT pEndpointInfo = NULL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -