⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usbhalendpoint.c

📁 USB source code of Vxworks 5.6. It has device and the host stack.
💻 C
📖 第 1 页 / 共 4 页
字号:
    }/********************************************************************************* usbHalTcdEndpointStateSet - set the state of an endpoint** This function is used to stall or un-stall an endpoint. <pPipeHandle> is the * handle to the corresponding endpoint and <state> is the state to be set.** RETURNS: OK if endpoint state is set successfully, ERROR otherwise.** ERRNO:*  none.*/STATUS usbHalTcdEndpointStateSet    (    pUSBHAL_TCD_NEXUS	pNexus,		/* USBHAL_TCD_NEXUS */    pVOID		pPipeHandle,	/* pipe handle */    UINT16		state		/* state of the pipe */    )    {    pUSBHAL_TCD		pUsbHal = NULL;	/* USBHAL_TCD */    TRB_ENDPOINT_STATE_SET trbEndpointStateSet; /* TRB_ENDPOINT_STATE_SET */    STATUS		status = ERROR;    pUSBHAL_PIPE_INFO	pHalPipeHandle = NULL;	/* USBHAL_PIPE_INFO */    /* WindView Instrumentation */     USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,    "usbHalTcdEndpointStateSet entered...", USB_HAL_WV_FILTER);       USBHAL_DEBUG("usbHalTcdEndpointStateSet - Entering\n",0,0,0,0,0,0);    /* Check the validity of the parameters */    if ((pNexus == NULL) || (pPipeHandle == NULL) || (pNexus->handle == NULL))        {        /* WindView Instrumentation */         USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,        "usbHalTcdEndpointStateSet exiting: Bad Parameters Received...",        USB_HAL_WV_FILTER);           USBHAL_ERR("usbHalTcdEndpointStateSet : Invalid parameters\n",                    0,0,0,0,0,0);        return ERROR;        }    /* Extract the pointer to the USB HAL data structure */    pUsbHal = (pUSBHAL_TCD)pNexus->handle;    /* Extract the Pipe handle */    pHalPipeHandle = (pUSBHAL_PIPE_INFO)pPipeHandle;    /* Populate the TRB - start */    trbHeaderInit ((pTRB_HEADER)(&trbEndpointStateSet),                   pUsbHal->pTCDHandle,                   TCD_FNC_ENDPOINT_STATE_SET,                   sizeof(TRB_ENDPOINT_STATE_SET));    trbEndpointStateSet.pipeHandle = pHalPipeHandle->pipeHandle;    trbEndpointStateSet.state = state;    /* Populate the TRB - End */    /* Call the single entry point of the TCD */    status = (*pUsbHal->tcdExecFunc)(&trbEndpointStateSet);    /* If the return status is an error, display an error message */    if (status == ERROR)        {        /* WindView Instrumentation */         USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,        "usbHalTcdEndpointStateSet exiting: SEP returned ERROR...",        USB_HAL_WV_FILTER);           USBHAL_ERR("usbHalTcdEndpointStateSet : SEP returned ERROR - exiting\n",                    0,0,0,0,0,0);        }    else        {        /* WindView Instrumentation */         USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,        "usbHalTcdEndpointStateSet exiting...", USB_HAL_WV_FILTER);           USBHAL_DEBUG("usbHalTcdEndpointStateSet: Success - exiting\n",                      0,0,0,0,0,0);        }    return status;    }/********************************************************************************* usbHalTcdEndpointStatusGet - get the status of an endpoint** This function is used to get the status of an endpoint.  <pPipeHandle> is the* handle to the corresponding endpoint and <pStatus> is the pointer to the * status information obtained.** RETURNS: OK if endpoint status is retrieved successfully, ERROR otherwise.** ERRNO:*   None.*/STATUS usbHalTcdEndpointStatusGet    (    pUSBHAL_TCD_NEXUS	pNexus,		/* USBHAL_TCD_NEXUS */    pVOID		pPipeHandle,	/* pipe handle */    pUINT8		pStatus		/* pointer to hold the endpoint status */    )    {    pUSBHAL_TCD		pUsbHal = NULL;	/* USBHAL_TCD */    TRB_ENDPOINT_STATUS_GET trbEndpointStatusGet; /* TRB_ENDPOINT_STATUS_GET */    STATUS		status = ERROR;    pUSBHAL_PIPE_INFO	pHalPipeHandle = NULL;	/* USBHAL_PIPE_INFO */    /* WindView Instrumentation */     USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,    "usbHalTcdEndpointStatusGet entered...", USB_HAL_WV_FILTER);       USBHAL_DEBUG ("usbHalTcdEndpointStatusGet - Entering\n",0,0,0,0,0,0);    /* Check the validity of the parameters */    if ((pNexus == NULL) || (pPipeHandle == NULL) || (pStatus == NULL) ||        (pNexus->handle == NULL))        {        /* WindView Instrumentation */         USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,        "usbHalTcdEndpointStatusGet exiting: Bad Parameters Received...",        USB_HAL_WV_FILTER);           USBHAL_ERR("usbHalTcdEndpointStatusGet : Invalid parameters\n",                    0,0,0,0,0,0);        return ERROR;        }    /* Extract the pointer to the USB HAL data structure */    pUsbHal = (pUSBHAL_TCD)pNexus->handle;    /* Extract the Pipe handle */    pHalPipeHandle = (pUSBHAL_PIPE_INFO)pPipeHandle;    /* Populate the TRB - start */    trbHeaderInit ((pTRB_HEADER)(&trbEndpointStatusGet),                    pUsbHal->pTCDHandle,                    TCD_FNC_ENDPOINT_STATUS_GET,                    sizeof(TRB_ENDPOINT_STATUS_GET));    trbEndpointStatusGet.pipeHandle = pHalPipeHandle->pipeHandle;    trbEndpointStatusGet.pStatus = pStatus;    /* Populate the TRB - end */    /* Call the single entry point of the TCD */    status = (*pUsbHal->tcdExecFunc)(&trbEndpointStatusGet);    /* If the return status is an error, display an error message */    if (status == ERROR)        {        /* WindView Instrumentation */         USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,        "usbHalTcdEndpointStatusGet exiting: SEP returned ERROR...",        USB_HAL_WV_FILTER);           USBHAL_ERR ("usbHalTcdEndpointStatusGet : SEP returned ERROR-exiting\n",                     0,0,0,0,0,0);        }    else        {        /* WindView Instrumentation */         USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,        "usbHalTcdEndpointStatusGet exiting...", USB_HAL_WV_FILTER);           USBHAL_DEBUG("usbHalTcdEndpointStatusGet : Success-exiting\n",                     0,0,0,0,0,0);        }    return status;    }/********************************************************************************* usbHalTcdErpSubmit - submit an ERP for an endpoint** This sub-module submits an ERP for transfer on an endpoint. The ERP* structure consists o the pointer of the pipe-handle on which the ERP is* submitted.** RETURNS: OK if ERP is submitted successfully, ERROR otherwise.** ERRNO:*   None.*/STATUS usbHalTcdErpSubmit    (    pUSBHAL_TCD_NEXUS	pNexus,		/* USBHAL_TCD_NEXUS */    pUSB_ERP		pErp		/* pointer to the ERP */    )    {    pUSBHAL_TCD		pUsbHal = NULL;		/* USBHAL_TCD */    STATUS		status = ERROR;    pUSBHAL_PIPE_INFO	pHalPipeHandle = NULL;	/* USBHAL_PIPE_INFO */    /* WindView Instrumentation */     USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,    "usbHalTcdErpSubmit entered...", USB_HAL_WV_FILTER);       USBHAL_DEBUG ("usbHalTcdErpSubmit - Entering\n",0,0,0,0,0,0);    /* Check the validity of the parameters */    if ((pNexus == NULL) || (pErp == NULL) || (pErp->pPipeHandle == NULL) ||        (pNexus->handle == NULL))        {        /* WindView Instrumentation */         USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,        "usbHalTcdErpSubmit exiting: Bad Parameters Received...",        USB_HAL_WV_FILTER);           USBHAL_ERR ("usbHalTcdErpSubmit : Invalid parameters\n",0,0,0,0,0,0);        return ERROR;        }    /* Extract the pointer to the USB HAL data structure */    pUsbHal = (pUSBHAL_TCD)pNexus->handle;    /* Extract the Pipe handle */    pHalPipeHandle = (pUSBHAL_PIPE_INFO)pErp->pPipeHandle;    /* Acquire the mutex created for this list */    OSS_MUTEX_TAKE (pHalPipeHandle->mutexHandle, OSS_BLOCK);    /* Add the ERP to tail of the list maintained for the Pipe */    usbListLink (&pHalPipeHandle->listHead, pErp, &pErp->tcdLink, LINK_TAIL);    /* Release the mutex */    OSS_MUTEX_RELEASE (pHalPipeHandle->mutexHandle);    /*      * Based on whether it is an OUT or IN endpoint request,     * call the appropriate function to handle the request.     */    if ((pHalPipeHandle->uEndpointAddress & USB_ENDPOINT_DIR_MASK) != 0)        {        status = usbHalProcessEndpointIN (pUsbHal, pHalPipeHandle);        }    else        {        /* OUT endpoint request */        /* If interrupt is pending, call the function to process the request */        if (pHalPipeHandle->uEndpointInterruptStatus != 0)            status = usbHalProcessEndpointOUT(pUsbHal, pHalPipeHandle);        else            status = OK;        }    /* WindView Instrumentation */     USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,    "usbHalTcdErpSubmit exiting...", USB_HAL_WV_FILTER);       USBHAL_DEBUG ("usbHalTcdErpSubmit - Exiting\n",0,0,0,0,0,0);    return status;    }/********************************************************************************* usbHalTcdErpCancel - cancel an ERP** This sub-module is used to cancel the ERP submitted on an endpoint.** RETURNS: OK if ERP is cancelled successfully, ERROR otherwise.** ERRNO:*   none.*/STATUS usbHalTcdErpCancel    (    pUSBHAL_TCD_NEXUS	pNexus,			/* USBHAL_TCD_NEXUS */    pUSB_ERP		pErp			/* pointer to the ERP */    )    {    pUSBHAL_TCD		pUsbHal = NULL;		/* USBHAL_TCD */    pUSBHAL_PIPE_INFO	pHalPipeHandle = NULL;	/* USBHAL_PIPE_INFO */    pUSB_ERP		pTempErp = NULL;	/* USB_ERP */	    /* WindView Instrumentation */     USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,    "usbHalTcdErpCancel entered...", USB_HAL_WV_FILTER);       USBHAL_DEBUG ("usbHalTcdErpCancel - Entering\n",0,0,0,0,0,0);    /* Check the validity of the parameters */    if ((pNexus == NULL) || (pErp == NULL) || (pNexus->handle == NULL) ||        (pErp->pPipeHandle == NULL))        {        /* WindView Instrumentation */         USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,        "usbHalTcdErpCancel exiting: Bad Parameters Received...",        USB_HAL_WV_FILTER);           USBHAL_ERR ("usbHalTcdErpCancel : Invalid parameters\n",0,0,0,0,0,0);        return ERROR;        }    /* Extract the pointer to the USB HAL data structure */    pUsbHal = (pUSBHAL_TCD)pNexus->handle;    /* Extract the Pipe handle */    pHalPipeHandle = (pUSBHAL_PIPE_INFO)pErp->pPipeHandle;    /* Acquire the mutex created for this list */    OSS_MUTEX_TAKE (pHalPipeHandle->mutexHandle, OSS_BLOCK);    /* Get the first element of the list */    pTempErp = usbListFirst (&pHalPipeHandle->listHead);    /* Check whether the ERP is present in the list */    while((pTempErp != pErp) && (pTempErp != NULL))        {        pTempErp = usbListNext(&pTempErp->tcdLink);        }    /* If the ERP is not found, return an ERROR */    if (pTempErp != pErp)        {        /* WindView Instrumentation */         USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,        "usbHalTcdErpCancel exiting: Error Canceling the ERP...",        USB_HAL_WV_FILTER);           USBHAL_ERR ("usbHalTcdErpCancel : ERP not found\n",0,0,0,0,0,0);        /* Release the mutex */        OSS_MUTEX_RELEASE (pHalPipeHandle->mutexHandle);        return ERROR;        }    /* Unlink this element */    usbListUnlink (&pErp->tcdLink);    /* Release the mutex */    OSS_MUTEX_RELEASE (pHalPipeHandle->mutexHandle);    /* Update the result of the ERP */    pErp->result = S_usbTcdLib_ERP_CANCELED;    /* Call the callback function for the ERP */    if (pErp->targCallback != NULL)        (*pErp->targCallback)(pErp);    /* WindView Instrumentation */     USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,    "usbHalTcdErpCancel exiting...", USB_HAL_WV_FILTER);       USBHAL_DEBUG("usbHalTcdErpCancel - Exiting\n",0,0,0,0,0,0);    return OK;    }/******************************************************************************** usbHalProcessEndpointOUT - process an OUT endpoint request** This function is called by the interrupt handler module when there is an* interrupt on an OUT endpoint. This function is also called when the* usbTcdErpSubmit() is called for receiving data from the USB host.** RETURNS: OK if OUT endpoint request is processed successfully,ERROR otherwise.** ERRNO:*   None.** \NOMANUAL*/STATUS usbHalProcessEndpointOUT    (    pUSBHAL_TCD		pHalInfo,		/* USBHAL_TCD */    pUSBHAL_PIPE_INFO	pPipeInfo		/* USBHAL_PIPE_INFO */    )    {    pUSB_ERP		pErp = NULL;		/* USB_ERP */    STATUS		status = OK;    TRB_COPY_DATA_FROM_EPBUF trbCopyDataFromEpBuf;    UINT32		uIndex = 0;    /* WindView Instrumentation */     USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,    "usbHalProcessEndpointOUT entered...", USB_HAL_WV_FILTER);       USBHAL_DEBUG ("usbHalProcessEndpointOUT - Entering\n",0,0,0,0,0,0);    /* Check the validity of the parameters */    if ((pHalInfo == NULL) || (pPipeInfo == NULL))        {        /* WindView Instrumentation */         USB_HAL_LOG_EVENT(USB_HAL_ENDPOINT,        "usbHalProcessEndpointOUT exiting: Bad Parameters Received...",        USB_HAL_WV_FILTER);           USBHAL_ERR("usbHalProcessEndpointOUT:Invalid parameters\n",0,0,0,0,0,0);        return ERROR;        }    /* Acquire the mutex created for this list */    OSS_MUTEX_TAKE (pPipeInfo->mutexHandle, OSS_BLOCK);    /*      * If the interrupt is not pending, don't proceed further.     * It is not an error if interrupt is not pending. This is because     * in the usbTcdErpSubmit () function, the check for     * (pHalPipeHandle->uEndpointInterruptStatus != 0) is done without     * acquiring the mutex.     */    if (pPipeInfo->uEndpointInterruptStatus == 0)        {        /* Release the mutex */        OSS_MUTEX_RELEASE (pPipeInfo->mutexHandle);        /* WindView Instrumentation */ 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -