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

📄 usbtcdisp1582endpoint.c

📁 This the compressed USB driver source code for vxworks5.6. It has device controller driver and other
💻 C
📖 第 1 页 / 共 4 页
字号:
            data16 = ISP1582_ENDPT_TYPE_REG_EPTYPE_NOT_USED |                     ISP1582_ENDPT_TYPE_REG_ENDPT_ENABLE;            break;        /* WindView Instrumentation */         USB_TCD_LOG_EVENT(USB_TCD_ISP1582_ENDPOINT,        "usbTcdIsp1582FncEndpointAssign exiting... Wrong Transfer Type",         USB_TCD_ISP582_WV_FILTER);           default : return ERROR;        }    /* Initialize endpoint type register */    isp1582Write16 (pTarget , ISP1582_ENDPT_TYPE_REG ,             data16 & ISP1582_ENDPT_TYPE_REG_MASK );    /*     * Clear the buffer by setting bit CLBUF of Control Function Register     * if it is a OUT transfer type     */    if ( direction == USB_ENDPOINT_OUT)        isp1582Write8(pTarget, ISP1582_CNTL_FUNC_REG,                      ISP1582_CNTL_FUNC_REG_CLBUF);    /* Read Interrupt Enable Regsiter */    data32 = isp1582Read32 (pTarget , ISP_1582_INT_ENABLE_REG);    /*     * Form the data to write into Interrupt Enable Register. If control     * endpoint,set EP0SETUP bit also.     */    if ( endpointIndex == ISP1582_ENDPT_0_RX ||         endpointIndex == ISP1582_ENDPT_0_TX)        data32 |= (ISP1582_INT_ENABLE_REG_IEP0SETUP |                 ISP1582_INT_ENABLE_REG_ENDPT_SET (endpointIndex));    else        data32 |= ISP1582_INT_ENABLE_REG_ENDPT_SET (endpointIndex);    /* Set appropiate bit of Interrupt Enable Register */    isp1582Write32 (pTarget , ISP_1582_INT_ENABLE_REG , data32);    /* Store the handle */    pTrb->pipeHandle = (UINT32)pEndpointInfo;    /* WindView Instrumentation */     USB_TCD_LOG_EVENT(USB_TCD_ISP1582_ENDPOINT,    "usbTcdIsp1582FncEndpointAssign exiting...", USB_TCD_ISP582_WV_FILTER);       USBISP1582_DEBUG ("usbTcdIsp1582FncEndpointAssign : Exiting...\n",    0,0,0,0,0,0);    return OK;    }/********************************************************************************* usbTcdIsp1582FncEndpointRelease - implements TCD_FNC_ENDPOINT_RELEASE** This function releases an endpoint.** RETURNS: OK or ERROR if failed to unconfigure the endpoint** ERRNO:* \is* \i S_usbTcdLib_BAD_PARAM.* Bad Parameter is passed.* \ie** \NOMANUAL*/LOCAL STATUS usbTcdIsp1582FncEndpointRelease    (    pTRB_ENDPOINT_RELEASE	pTrb		/* Trb to be executed */    )    {    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */    pUSB_TCD_ISP1582_TARGET	pTarget = NULL;	/* USB_TCD_ISP1582_TARGET */    pUSB_TCD_ISP1582_ENDPOINT	pEndpointInfo = NULL;/*USB_TCD_ISP1582_ENDPOINT*/    UINT8	endpointIndex = 0;		/* endpoint index */    UINT8	direction = 0;			/* direction */    UINT32	data32 = 0;		/* variable to read write in register */    /* WindView Instrumentation */     USB_TCD_LOG_EVENT(USB_TCD_ISP1582_ENDPOINT,    "usbTcdIsp1582FncEndpointRelease entered...", USB_TCD_ISP582_WV_FILTER);           USBISP1582_DEBUG ("usbTcdIsp1582FncEndpointRelease : 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_ISP1582_ENDPOINT,        "usbTcdIsp1582FncEndpointRelease exiting...Bad Parameters Received",        USB_TCD_ISP582_WV_FILTER);           USBISP1582_ERROR ("usbTcdIsp1582FncEndpointRelease : Bad Parameters \        ...\n",0,0,0,0,0,0);        return ossStatus (S_usbTcdLib_BAD_PARAM);        }    pTarget = (pUSB_TCD_ISP1582_TARGET)pHeader->handle;    pEndpointInfo = (pUSB_TCD_ISP1582_ENDPOINT)pTrb->pipeHandle;    endpointIndex = pEndpointInfo->endpointIndex;    direction = pEndpointInfo->direction;    /* Initialize endpoint Index regsiter */    isp1582Write8 ( pTarget , ISP1582_ENDPT_INDEX_REG , endpointIndex);    /* Disable the endpoint by writing Logic 0 into endpoint type register */    isp1582Write16 ( pTarget , ISP1582_ENDPT_TYPE_REG , 0);    /* update endpointIndexInUse member indicating that the endpoint is free */    pTarget->endpointIndexInUse &= ~(0x1 << endpointIndex);    /*     * Decrement the bufSize member of TARGET structure. If transfer type is     * bulk or isochronous decrement with twice the maxpacket size.     */    if (pEndpointInfo->isDoubleBufSup)        pTarget->bufSize -= (2 * pEndpointInfo->maxPacketSize);    else        pTarget->bufSize -= pEndpointInfo->maxPacketSize;    /*     * Get the data from interrupt enable register and reset corresponding     * endpoint bit from it. If its a control endpoint reset EP0SET bit also.     */    /* Read Interrupt Enable Regsiter */    data32 = isp1582Read32 (pTarget , ISP_1582_INT_ENABLE_REG);    /*     * Form the data to write into Interrupt Enable Register. If control     * endpoint,reset EP0SETUP bit also.     */    if ( endpointIndex == ISP1582_ENDPT_0_RX ||         endpointIndex == ISP1582_ENDPT_0_TX)        data32 &= ~(ISP1582_INT_ENABLE_REG_IEP0SETUP |                    ISP1582_INT_ENABLE_REG_ENDPT_SET (endpointIndex));    else        data32 &= ~ISP1582_INT_ENABLE_REG_ENDPT_SET (endpointIndex);    /* Set appropiate bit of Interrupt Enable Register */    isp1582Write32 (pTarget , ISP_1582_INT_ENABLE_REG , data32);    /* Release the USB_TCD_ISP1582_ENDPOINT structure */    OSS_FREE (pEndpointInfo);    /* WindView Instrumentation */     USB_TCD_LOG_EVENT(USB_TCD_ISP1582_ENDPOINT,    "usbTcdIsp1582FncEndpointRelease exiting...", USB_TCD_ISP582_WV_FILTER);       USBISP1582_DEBUG ("usbTcdIsp1582FncEndpointRelease : Exiting...\n",    0,0,0,0,0,0);    return OK;    }/******************************************************************************** usbTcdIsp1582FncEndpointStateSet - 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 usbTcdIsp1582FncEndpointStateSet    (    pTRB_ENDPOINT_STATE_SET	pTrb		/* Trb to be executed */    )    {    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */    pUSB_TCD_ISP1582_ENDPOINT	pEndpointInfo = NULL;/*USB_TCD_ISP1582_ENDPOINT*/    pUSB_TCD_ISP1582_TARGET	pTarget = NULL;	/* USB_TCD_ISP1582_TARGET */    UINT8	endpointIndex = 0;		/* endpoint index */    UINT8	data8 = 0;			    UINT16	data16 = 0;        /* WindView Instrumentation */     USB_TCD_LOG_EVENT(USB_TCD_ISP1582_ENDPOINT,    "usbTcdIsp1582FncEndpointStateSet entered...", USB_TCD_ISP582_WV_FILTER);       USBISP1582_DEBUG ("usbTcdIsp1582FncEndpointStateSet : 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_ISP1582_ENDPOINT,        "usbTcdIsp1582FncEndpointStateSet exiting...Bad Parameters Received",        USB_TCD_ISP582_WV_FILTER);           USBISP1582_ERROR ("usbTcdIsp1582FncEndpointStateSet : Bad Parameters \        ...\n",0,0,0,0,0,0);        return ossStatus(S_usbTcdLib_BAD_PARAM);        }    pEndpointInfo = (pUSB_TCD_ISP1582_ENDPOINT)pTrb->pipeHandle;    pTarget = (pUSB_TCD_ISP1582_TARGET)pHeader->handle;    endpointIndex = pEndpointInfo->endpointIndex;    /* Set the Endpoint Index Register */    isp1582Write8 (pTarget , ISP1582_ENDPT_INDEX_REG ,                                   endpointIndex & ISP1582_ENDPT_INDEX_REG_MASK);    /* Read the Control Function Register */    data8 = isp1582Read8 (pTarget , ISP1582_CNTL_FUNC_REG) &            ISP1582_CNTL_FUNC_REG_MASK;    if (pTrb->state == TCD_ENDPOINT_STALL)        {        /*         * Stall the endpoint by writing Control Function Register with         * Stall bit set.         */         USBISP1582_DEBUG ("usbTcdIsp1582FncEndpointStateSet : Stalling...\n",         0,0,0,0,0,0);         isp1582Write8 (pTarget , ISP1582_CNTL_FUNC_REG ,                                           data8 | ISP1582_CNTL_FUNC_REG_STALL);        /* WindView Instrumentation */         USB_TCD_LOG_EVENT(USB_TCD_ISP1582_ENDPOINT,        "usbTcdIsp1582FncEndpointStateSet: endpoints stalled",        USB_TCD_ISP582_WV_FILTER);           }    else if (pTrb->state == TCD_ENDPOINT_UNSTALL)        {        USBISP1582_DEBUG ("usbTcdIsp1582FncEndpointStateSet : Un-stalling...\n",         0,0,0,0,0,0);        /*         * Un-Stall the endpoint by writing Control Function Register with         * Stall bit reset.         */        data8 &= ~ISP1582_CNTL_FUNC_REG_STALL;        isp1582Write8 (pTarget , ISP1582_CNTL_FUNC_REG ,                       data8 & ISP1582_CNTL_FUNC_REG_MASK);        /* WindView Instrumentation */         USB_TCD_LOG_EVENT(USB_TCD_ISP1582_ENDPOINT,        "usbTcdIsp1582FncEndpointStateSet: Endpoint Un-stall",        USB_TCD_ISP582_WV_FILTER);           }     /* Reset data toggle */    /* Read the Endpoint Type Register */    data16 = isp1582Read16 (pTarget , ISP1582_ENDPT_TYPE_REG) &             ISP1582_ENDPT_TYPE_REG_MASK;    /* Reset bit Enable and write into the register */    data16 &= ~ISP1582_ENDPT_TYPE_REG_ENDPT_ENABLE;    isp1582Write16 (pTarget , ISP1582_ENDPT_TYPE_REG ,                    data16 & ISP1582_ENDPT_TYPE_REG_MASK);    /* Set bit Enable and write into the register */    isp1582Write16 (pTarget, ISP1582_ENDPT_TYPE_REG ,                   (data16 | ISP1582_ENDPT_TYPE_REG_ENDPT_ENABLE) &                   ISP1582_ENDPT_TYPE_REG_MASK);    /* WindView Instrumentation */     USB_TCD_LOG_EVENT(USB_TCD_ISP1582_ENDPOINT,    "usbTcdIsp1582FncEndpointStateSet exiting...",USB_TCD_ISP582_WV_FILTER);       USBISP1582_DEBUG ("usbTcdIsp1582FncEndpointStateSet : Exiting...\n",    0,0,0,0,0,0);    return OK;    }/******************************************************************************** usbTcdIsp1582FncEndpointStatusGet - 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 usbTcdIsp1582FncEndpointStatusGet    (    pTRB_ENDPOINT_STATUS_GET	pTrb		/* Trb to be executed */    )    {    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */    pUSB_TCD_ISP1582_ENDPOINT	pEndpointInfo = NULL;/*USB_TCD_ISP1582_ENDPOINT*/    pUSB_TCD_ISP1582_TARGET	pTarget = NULL;	/* USB_TCD_ISP1582_TARGET */	    UINT8	endpointIndex = 0;		/* endpoint index */    UINT8	data8 = 0;        /* WindView Instrumentation */     USB_TCD_LOG_EVENT(USB_TCD_ISP1582_ENDPOINT,    "usbTcdIsp1582FncEndpointStatusGet entered...", USB_TCD_ISP582_WV_FILTER);       USBISP1582_DEBUG ("usbTcdIsp1582FncEndpointStatusGet : 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_ISP1582_ENDPOINT,        "usbTcdIsp1582FncEndpointStatusGet exiting...Bad Parameters Received",        USB_TCD_ISP582_WV_FILTER);           USBISP1582_ERROR ("usbTcdIsp1582FncEndpointStatusGet : Bad Parameters \        ...\n",0,0,0,0,0,0);        return ossStatus(S_usbTcdLib_BAD_PARAM);        }    pEndpointInfo = (pUSB_TCD_ISP1582_ENDPOINT)pTrb->pipeHandle;    pTarget = (pUSB_TCD_ISP1582_TARGET)pHeader->handle;    endpointIndex = pEndpointInfo->endpointIndex;    /* Set the Endpoint Index Register */    isp1582Write8 (pTarget , ISP1582_ENDPT_INDEX_REG , endpointIndex);    /* Read the Control Function Register */    data8 = isp1582Read8 ( pTarget , ISP1582_CNTL_FUNC_REG) &            ISP1582_CNTL_FUNC_REG_MASK;    if ((data8 & ISP1582_CNTL_FUNC_REG_STALL) != 0)        /* Endpoint is stalled */        *(pTrb->pStatus) = USB_ENDPOINT_STS_HALT;    else        /* Endpoint is not stalled. Update pStatus to 0 */        *(pTrb->pStatus) = 0;    /* WindView Instrumentation */     USB_TCD_LOG_EVENT(USB_TCD_ISP1582_ENDPOINT,    "usbTcdIsp1582FncEndpointStatusGet exiting...", USB_TCD_ISP582_WV_FILTER);       USBISP1582_DEBUG ("usbTcdIsp1582FncEndpointStatusGet : Exiting...\n",    0,0,0,0,0,0);    return OK;    }/********************************************************************************* usbTcdIsp1582FncIsBufferEmpty - 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.*

⌨️ 快捷键说明

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