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

📄 usbtcdnet2280endpoint.c

📁 This the compressed USB driver source code for vxworks5.6. It has device controller driver and other
💻 C
📖 第 1 页 / 共 5 页
字号:
        /* Write to the FIFOCTL register to set the FIFO configuration */        NET2280_CFG_WRITE (pTarget, NET2280_FIFOCTL_REG, data32 | fifoConfMode);        }    /* Reset the corresponding endpoint bit in endpointIndexInUse */    pTarget->endpointIndexInUse &= ~(1 << pEndpointInfo->endpointIndex); #ifdef NET2280_DMA_SUPPORTED    /*      * If the endpoint supports dma, then     * stop the dma transfers     */     switch (pEndpointInfo->endpointIndex )        {        case	NET2280_ENDPT_A:        case	NET2280_ENDPT_B:        case	NET2280_ENDPT_C:        case	NET2280_ENDPT_D:	            disableDma(pTarget,pEndpointInfo);            break;        default: break;        }#endif    /* Release the endpoint */    OSS_FREE(pEndpointInfo);      USB_NET2280_DEBUG ("usbTcdNET2280FncEndpointRelease : Exiting...\n",    0,0,0,0,0,0);        return OK;    }/******************************************************************************** usbTcdNET2280FncEndpointStatusGet - 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 status of the endpoint.** ERRNO:* \is* \i S_usbTcdLib_BAD_PARAM.* Bad Parameter is passed.* \ie** \NOMANUAL*/LOCAL STATUS usbTcdNET2280FncEndpointStatusGet     (    pTRB_ENDPOINT_STATUS_GET pTrb		/* TRB to be executed */    )    {    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */    pUSB_TCD_NET2280_TARGET	pTarget = NULL;	/* USB_TCD_NET2280_TARGET */    pUSB_TCD_NET2280_ENDPOINT	pEndpointInfo = NULL;                                                /*USB_TCD_NET2280_ENDPOINT*/    UINT8	endpointIndex = 0;		/* endpoint index */        /* WindView Instrumentation */    USB_TCD_LOG_EVENT(USB_TCD_NET2280_ENDPOINT,    "usbTcdNET2280FncEndpointStatusGet entered...", USB_TCD_NET2280_WV_FILTER);    USB_NET2280_DEBUG ("usbTcdNET2280FncEndpointStatusGet: Entered...\n",    0,0,0,0,0,0);    /* Validate parameters */    if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) ||        (pTrb->pipeHandle == 0) || (pHeader->handle == NULL))        {        /* WindView Instrumentation */        USB_TCD_LOG_EVENT (USB_TCD_NET2280_ENDPOINT,        "usbTcdNET2280FncEndpointStatusGet exiting...Bad Parameters received",        USB_TCD_NET2280_WV_FILTER);        USB_NET2280_ERROR ("usbTcdNET2280FncEndpointStatusGet: Bad Parameters \        ...\n",0,0,0,0,0,0);        return ossStatus(S_usbTcdLib_BAD_PARAM);        }    pEndpointInfo = (pUSB_TCD_NET2280_ENDPOINT)pTrb->pipeHandle;    pTarget = (pUSB_TCD_NET2280_TARGET)pHeader->handle;    endpointIndex = pEndpointInfo->endpointIndex;    /*     * If transfer type is Control and dirction is IN set endpointIndex to 0.      * Endpoint index is used to access the endpoint specific hardware and      * as there is only one control endpoint, set endpoint Index to 0     */     if (endpointIndex == NET2280_ENDPT_0_IN)                endpointIndex = 0;    /*      * Read the Endpoint Response register and determine the status of the      * endpoint      */            if ((NET2280_CFG_READ (pTarget, NET2280_EP_RSP_OFFSET(endpointIndex))        & NET2280_EP_RSP_STALL) == NET2280_EP_RSP_STALL)        {        /* Endpoint is stalled */        *(pTrb->pStatus) = USB_ENDPOINT_STS_HALT;        }    else        /* Endpoint is not stalled. Update pStatus to 0 */        *(pTrb->pStatus) = 0;    USB_NET2280_DEBUG ("usbTcdNET2280FncEndpointStatusGet : Exiting...\n",    0,0,0,0,0,0);    return OK;    }/******************************************************************************** usbTcdNET2280FncEndpointStateSet - 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:* \is* \i S_usbTcdLib_BAD_PARAM.* Bad Parameter is passed.* \ie** \NOMANUAL*/LOCAL STATUS usbTcdNET2280FncEndpointStateSet     (    pTRB_ENDPOINT_STATE_SET pTrb		/* TRB to be executed */	    )    {    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */    pUSB_TCD_NET2280_ENDPOINT	pEndpointInfo = NULL;/*USB_TCD_NET2280_ENDPOINT*/    pUSB_TCD_NET2280_TARGET	pTarget = NULL;	/* USB_TCD_NET2280_TARGET */    UINT8	endpointIndex = 0;		/* endpoint index */        /* WindView Instrumentation */    USB_TCD_LOG_EVENT(USB_TCD_NET2280_ENDPOINT,    "usbTcdNET2280FncEndpointStateSet entered...", USB_TCD_NET2280_WV_FILTER);    USB_NET2280_DEBUG ("usbTcdNET2280FncEndpointStateSet: Entered...\n",    0,0,0,0,0,0);    /* Validate parameters */    if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) ||        (pTrb->pipeHandle == 0) || (pHeader->handle == NULL))        {        /* WindView Instrumentation */        USB_TCD_LOG_EVENT (USB_TCD_NET2280_ENDPOINT,        "usbTcdNET2280FncEndpointStateSet exiting...Bad Parameters received",        USB_TCD_NET2280_WV_FILTER);        USB_NET2280_ERROR ("usbTcdNET2280FncEndpointStateSet : Bad Parameters \        ...\n",0,0,0,0,0,0);        return ossStatus(S_usbTcdLib_BAD_PARAM);        }    pEndpointInfo = (pUSB_TCD_NET2280_ENDPOINT)pTrb->pipeHandle;    pTarget = (pUSB_TCD_NET2280_TARGET)pHeader->handle;    endpointIndex = pEndpointInfo->endpointIndex;    /*     * If transfer type is Control and dirction is IN set endpointIndex to 0.      * Endpoint index is used to access the endpoint specific hardware and      * as there is only one control endpoint, set endpoint Index to 0     */     if (endpointIndex == NET2280_ENDPT_0_IN)                endpointIndex = 0;    if (pTrb->state == TCD_ENDPOINT_STALL)        {        /* WindView Instrumentation */        USB_TCD_LOG_EVENT (USB_TCD_NET2280_ENDPOINT,        "usbTcdNET2280FncEndpointStateSet exiting...Stalling Endpoint",        USB_TCD_NET2280_WV_FILTER);        /*         * Stall the endpoint by setting the Endpoint Halt (bit 8) of EP_RSP          * register of corresponding endpoint         */            NET2280_CFG_WRITE (pTarget, NET2280_EP_RSP_OFFSET (endpointIndex),                            NET2280_EP_RSP_SET (NET2280_EP_RSP_STALL));           USB_NET2280_DEBUG ("usbTcdNET2280FncEndpointStateSet : Stalling...\n",        0,0,0,0,0,0);                       }    else if (pTrb->state == TCD_ENDPOINT_UNSTALL)        {        /* WindView Instrumentation */        USB_TCD_LOG_EVENT (USB_TCD_NET2280_ENDPOINT,        "usbTcdNET2280FncEndpointStateSet exiting...Un-stalling Endpoint",        USB_TCD_NET2280_WV_FILTER);        /*         * Un-stall the endpoint by setting the Endpoint Halt (bit 0) of EP_RSP          * register of corresponding endpoint         */            NET2280_CFG_WRITE (pTarget, NET2280_EP_RSP_OFFSET (endpointIndex),                            NET2280_EP_RSP_CLEAR (NET2280_EP_RSP_STALL));           USB_NET2280_DEBUG ("usbTcdNET2280FncEndpointStateSet : Un-stalling...\n",        0,0,0,0,0,0);        }        USB_NET2280_DEBUG ("usbTcdNET2280FncEndpointStateSet: Exiting...\n",    0,0,0,0,0,0);    return OK;    }/********************************************************************************* usbTcdNET2280FncIsBufferEmpty - implements TCD_FNC_IS_BUFFER_EMPTY** This utility function is used to check whether the FIFO buffer related* with the associated endpoint is empty or not.** RETURNS: OK or ERROR, it not able to get the status of the buffer.** ERRNO:* \is* \i S_usbTcdLib_BAD_PARAM.* Bad Parameter is passed.* \ie** \NOMANUAL*/LOCAL STATUS usbTcdNET2280FncIsBufferEmpty     (    pTRB_IS_BUFFER_EMPTY pTrb		/* TRB to be executed */    )    {    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */    pUSB_TCD_NET2280_ENDPOINT	pEndpointInfo = NULL;/*USB_TCD_NET2280_ENDPOINT*/    pUSB_TCD_NET2280_TARGET	pTarget = NULL;	/* USB_TCD_NET2280_TARGET */    UINT8	endpointIndex = 0;		/* endpoint index */        /* WindView Instrumentation */    USB_TCD_LOG_EVENT(USB_TCD_NET2280_ENDPOINT,    "usbTcdNET2280FncIsBufferEmpty entered...", USB_TCD_NET2280_WV_FILTER);    USB_NET2280_DEBUG ("usbTcdNET2280FncIsBufferEmpty: Entered...\n",    0,0,0,0,0,0);    /* Validate parameters */    if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) ||        (pHeader->handle == NULL) || (pTrb->pipeHandle == 0))        {        /* WindView Instrumentation */        USB_TCD_LOG_EVENT (USB_TCD_NET2280_ENDPOINT,        "usbTcdNET2280FncIsBufferEmpty exiting...Bad Parameters received",        USB_TCD_NET2280_WV_FILTER);        USB_NET2280_ERROR ("usbTcdNET2280FncIsBufferEmpty : Bad Parameters \        ...\n",0,0,0,0,0,0);        return ossStatus(S_usbTcdLib_BAD_PARAM);        }    pEndpointInfo = (pUSB_TCD_NET2280_ENDPOINT)pTrb->pipeHandle;    pTarget = (pUSB_TCD_NET2280_TARGET)pHeader->handle;    endpointIndex = pEndpointInfo->endpointIndex;    /*     * If transfer type is Control and dirction is IN set endpointIndex to 0.      * Endpoint index is used to access the endpoint specific hardware and      * as there is only one control endpoint, set endpoint Index to 0     */     if (endpointIndex == NET2280_ENDPT_0_IN)                endpointIndex = 0;    /*     * Read the bit 10 of EP_STAT register and determine if the FIFO      * is empty     */       if ((NET2280_CFG_READ (pTarget, NET2280_EP_STAT_OFFSET(endpointIndex))                           & NET2280_EP_STAT_FIFO_EMPTY) != 0)        {        /* FIFO is empty */         pTrb->bufferEmpty = TRUE;         }    else        {        /* FIFO is not empty */           pTrb->bufferEmpty = FALSE;         }        USB_NET2280_DEBUG ("usbTcdNET2280FncIsBufferEmpty : Exiting...\n",    0,0,0,0,0,0);    return OK;    }/******************************************************************************** usbTcdIsp1582FncCopyDataFromEpBuf - implements TCD_FNC_COPY_DATA_FROM_EPBUF** This function copies the data from the endpoint FIFO buffer into the* buffer that is passed. The Setup data on Control Endpoint is read from the * setup register. If the endpoint supports the DMA transfer we initiate the * DMA transfer on the corressponding endpoint. ** RETURNS: OK or ERROR if not able to read data from the enpoint FIFO.** ERRNO:* \is* \i S_usbTcdLib_BAD_PARAM.* Bad Parameter is passed.* \ie** \NOMANUAL*/LOCAL STATUS usbTcdNET2280FncCopyDataFromEpBuf     (    pTRB_COPY_DATA_FROM_EPBUF pTrb		/* TRB to be executed */    )    {    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */    pUSB_TCD_NET2280_ENDPOINT	pEndpointInfo = NULL;/*USB_TCD_NET2280_ENDPOINT*/    pUSB_TCD_NET2280_TARGET	pTarget = NULL;	/* USB_TCD_NET2280_TARGET */    UINT8	endpointIndex = 0;		/* endpoint index */    UINT8	transferType = 0;		/* transfer type */    UINT32	sizeToCopy = 0;			/* size to data to copy */    unsigned char  * pBuf = pTrb->pBuffer;	/* pointer to buffer */    UINT32	data32 = 0;			/* temporary variable */    UINT8       i = 0;    /* WindView Instrumentation */    USB_TCD_LOG_EVENT(USB_TCD_NET2280_ENDPOINT,    "usbTcdNET2280FncCopyDataFromEpBuf entered...", USB_TCD_NET2280_WV_FILTER);    USB_NET2280_DEBUG ("usbTcdNET2280FncCopyDataFromEpBuf: Entered...\n",    0,0,0,0,0,0);    /* Validate parameters */    if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) ||        (pHeader->handle == NULL) || (pTrb->pipeHandle == 0))        {        /* WindView Instrumentation */        USB_TCD_LOG_EVENT (USB_TCD_NET2280_ENDPOINT,        "usbTcdNET2280FncCopyDataFromEpBuf exiting...Bad Parameters received",        USB_TCD_NET2280_WV_FILTER);        USB_NET2280_ERROR ("usbTcdNET2280FncCopyDataFromEpBuf: Bad Parameters \        ...\n",0,0,0,0,0,0);        return ossStatus(S_usbTcdLib_BAD_PARAM);        }    pEndpointInfo = (pUSB_TCD_NET2280_ENDPOINT)pTrb->pipeHandle;    pTarget = (pUSB_TCD_NET2280_TARGET)pHeader->handle;    endpointIndex = pEndpointInfo->endpointIndex;    transferType = pEndpointInfo->transferType;#ifdef NET2280_DMA_SUPPORTED    /*     * DMA transfer is used only when the     * the request length is a multiple of 4.     * If there is a short packet detected, the HAL     * will call the callback immediately after returning     * from this function. If dma is used in this case,     * the HAL will not have any data in the buffer which is     * incorrect handling. So dma should not be used on a short     * packet detection.      */    if (pEndpointInfo->isDmaSupported &&        ((pTrb->uActLength % 4) == 0) &&        !pEndpointInfo->shortPacket)        {        /* Check if dma is being in use */         if (pEndpointInfo->dmaInUse)            {                        /* Check if dmaEot is detected for the corresponding endpoint*/             if ((pTarget->dmaEot & (1 << endpointIndex)) != 0)                {                /* Reset the corresponding bit in pTarget->dmaEot */                pTarget->dmaEot &= ~(1 << endpointIndex);                /* Calculate the size of data actually received */

⌨️ 快捷键说明

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