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

📄 usbtcdnet2280endpoint.c

📁 This the compressed USB driver source code for vxworks5.6. It has device controller driver and other
💻 C
📖 第 1 页 / 共 5 页
字号:
    /*     * Store Direction, transfer type, max packet size and endpoint index in     * the USB_TCD_ISP1582_ENDPOINT.     */    pEndpointInfo->transferType = transferType;    pEndpointInfo->direction = direction;    pEndpointInfo->maxPacketSize = maxPacketSize;    pEndpointInfo->endpointIndex = endpointIndex;    /*     * endpoint index is used to access the endpoint specific hardware and      * as there is only one control endpoint, set endpoint Index to 0     */     if ((transferType == USB_ATTR_CONTROL) && (direction == USB_TCD_ENDPT_IN))         endpointIndex = 0;            /* set corresponding bit of pTarget->endpointIndexInUse */    pTarget->endpointIndexInUse |= (1 << pEndpointInfo->endpointIndex);#ifdef NET2280_DMA_SUPPORTED    pEndpointInfo->dmaInUse = FALSE;    /* Only endpoint A,B,C & D supports DMA */    switch (endpointIndex)        {         case NET2280_ENDPT_A:        case NET2280_ENDPT_B:	case NET2280_ENDPT_C:         case NET2280_ENDPT_D:             pEndpointInfo->isDmaSupported = TRUE;            break;         default : pEndpointInfo->isDmaSupported = FALSE;        }#endif    /* Update the configuration if the endpoint indices are not E, F & 0 */    if ((endpointIndex != NET2280_ENDPT_E) &&         (endpointIndex != NET2280_ENDPT_F) && (endpointIndex != NET2280_ENDPT_0_OUT))        {        /* Read the contents of the FIFOCTL register */        data32 = NET2280_CFG_READ (pTarget, NET2280_FIFOCTL_REG);        /* Clear the configuration mode */        data32 &= ~NET2280_FIFOCTL_CFG_MASK;        /* Write to the FIFOCTL register to set the FIFO configuration */        NET2280_CFG_WRITE (pTarget, NET2280_FIFOCTL_REG, data32 | fifoConfMode);        }    /* If it is not a control endpoint, configure the endpoint */    if (transferType != USB_ATTR_CONTROL)        {        /*         * Configure the Endpoint Configuration Register and enable it.           * We donot enable Endpoint 0. It is always enabled          */        data32 = 0;        /* Reset the configuration register for the endpoint */        NET2280_CFG_WRITE (pTarget, NET2280_EP_CFG_OFFSET(endpointIndex),0);        /*         * Set the Configuration Register with endpoint number, transfer type         * & endpoint direction         */        /* endpoint number */        data32 = endpointNum;                /* direction */                  data32 |= (direction << NET2280_EP_CFG_DIR_SHIFT);        /* transfer type */        switch (transferType)            {            case USB_ATTR_BULK:  data32 |= NET2280_EP_CFG_TYPE_BULK;                break;            case USB_ATTR_ISOCH: data32 |= NET2280_EP_CFG_TYPE_ISO;                 break;            case USB_ATTR_INTERRUPT: data32 |= NET2280_EP_CFG_TYPE_INT;                break;            default : USB_NET2280_ERROR ("usbTcdNET2280FncEndpointAssign: \                      Wrong Transfer Type...\n",0,0,0,0,0,0);                      OSS_FREE (pEndpointInfo);                      /* WindView Instrumentation */                      USB_TCD_LOG_EVENT (USB_TCD_NET2280_ENDPOINT,                      "usbTcdNET2280FncEndpointAssign exiting...Wrong Transfer \                      Type", USB_TCD_NET2280_WV_FILTER);                      return ossStatus (S_usbTcdLib_GENERAL_FAULT);           }        /* Write into configuration regsiter */            NET2280_CFG_WRITE (pTarget,                            NET2280_EP_CFG_OFFSET (endpointIndex),                           data32);        /* Update the max packet size determining on the speed */         if (pTarget->speed == USB_TCD_HIGH_SPEED)            data32 =  NET2280_EP_X_HS_MAXPKT_IDX(endpointIndex);        else            data32 =  NET2280_EP_X_FS_MAXPKT_IDX(endpointIndex);                      /*         * Write the max packet size in the high speed max packet size          * register of the corresponding endpoint         */                  /* Write the address in the index register */                   NET2280_CFG_WRITE (pTarget, NET2280_IDXADDR_REG, data32);       /* Write the max packet size in the index data register */       if (pTarget->speed == USB_TCD_HIGH_SPEED)           {              data32 =  (nTrans << NET2280_NTRANS_SHIFT) | maxPacketSize;           }          else                      data32 = maxPacketSize;                NET2280_CFG_WRITE (pTarget, NET2280_IDXDATA_REG, data32);       /* Unstall the endpoint by writing into EP_RSP register */       NET2280_CFG_WRITE (pTarget, NET2280_EP_RSP_OFFSET (endpointIndex),                           NET2280_EP_RSP_CLEAR (NET2280_EP_RSP_STALL));               /* Enable the interrupts for the correponding endpoint */       data32 = NET2280_CFG_READ (pTarget, NET2280_PCIIRQENB0_REG);       data32 |= NET2280_IRQENB0_EP(endpointIndex);       NET2280_CFG_WRITE (pTarget, NET2280_PCIIRQENB0_REG, data32);           }              /* Reset the EP_STAT register */        NET2280_CFG_WRITE (pTarget, NET2280_EP_STAT_OFFSET (endpointIndex),                          0xFFFF);        /*        * Depending on the direction update Data Packet Received Interrupt         * and Data Packet Transmitted Interupt        */              if (direction == USB_TCD_ENDPT_IN)          {          data32 = NET2280_CFG_READ (pTarget,                                      NET2280_EP_IRQENB_OFFSET(endpointIndex));          data32 |= NET2280_EP_IRQENB_DPT;          NET2280_CFG_WRITE (pTarget, NET2280_EP_IRQENB_OFFSET(endpointIndex),                             data32);                       }           else          {          data32 = NET2280_CFG_READ (pTarget,                    NET2280_EP_IRQENB_OFFSET(endpointIndex));           data32 |= NET2280_EP_IRQENB_DPR;          NET2280_CFG_WRITE (pTarget, NET2280_EP_IRQENB_OFFSET(endpointIndex),                             data32);                       }        data32 = NET2280_CFG_READ (pTarget, NET2280_EP_CFG_OFFSET (endpointIndex));        /* Enable the endpoint for USB Transfer */        data32 |= NET2280_EP_CFG_ENABLE;        /* Write into configuration regsiter */            NET2280_CFG_WRITE (pTarget,                            NET2280_EP_CFG_OFFSET (endpointIndex),                           data32);    /* Store the handle */    pTrb->pipeHandle = (UINT32)pEndpointInfo;    USB_NET2280_DEBUG ("usbTcdNET2280FncEndpointAssign : Exiting...\n",    0,0,0,0,0,0);    return OK;    }/********************************************************************************* usbTcdNET2280FncEndpointRelease - 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 usbTcdNET2280FncEndpointRelease    (    pTRB_ENDPOINT_RELEASE	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 */    UINT8	direction = 0;			/* direction */    UINT8	transferType = 0;		/* Transfer type */    UINT32	data32 = 0;			/* temporary variable */    UINT32	fifoConfMode = 0;		/* fifo config value */    /* WindView Instrumentation */    USB_TCD_LOG_EVENT(USB_TCD_NET2280_ENDPOINT,    "usbTcdNET2280FncEndpointRelease entered...", USB_TCD_NET2280_WV_FILTER);    USB_NET2280_DEBUG ("usbTcdNET2280FncEndpointRelease : 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,        "usbTcdNET2280FncEndpointRelease exiting...Bad Parameters received",        USB_TCD_NET2280_WV_FILTER);        USB_NET2280_ERROR ("usbTcdNET2280FncEndpointRelease : Bad Parameters \        ...\n",0,0,0,0,0,0);        return ossStatus (S_usbTcdLib_BAD_PARAM);        }    pTarget = (pUSB_TCD_NET2280_TARGET)pHeader->handle;    pEndpointInfo = (pUSB_TCD_NET2280_ENDPOINT)pTrb->pipeHandle;    endpointIndex = pEndpointInfo->endpointIndex;    direction = pEndpointInfo->direction;    transferType = pEndpointInfo->transferType;        if (transferType == USB_ATTR_CONTROL)        {        if (direction ==  USB_TCD_ENDPT_OUT)                    {            /*             * Disable the setup packet interrupt and endpoint 0 interupt in              * PCIIRQENB0 register              */            data32 = NET2280_CFG_READ (pTarget, NET2280_PCIIRQENB0_REG);            if ((data32 & (NET2280_XIRQENB0_SETUP |                  NET2280_XIRQENB0_EP(NET2280_ENDPT_0_OUT))) != 0)                  {                data32 &= ~(NET2280_XIRQENB0_SETUP | 			NET2280_XIRQENB0_EP(endpointIndex));                NET2280_CFG_WRITE (pTarget, NET2280_PCIIRQENB0_REG,                                data32 & NET2280_XIRQENB0_MASK);                 }            /*             * Disable the control status interrupt. The disabling of this bit             * can be done for control endpoint IN also. We are doing some              * interrupt specific handling for endpoint 0 here, hence we are             * handling this interrupt also here.                  */            if (((data32 = NET2280_CFG_READ (pTarget, NET2280_PCIIRQENB1_REG)) &                  NET2280_XIRQENB1_CS) != 0)                {                data32 &= ~NET2280_XIRQENB1_CS;                 NET2280_CFG_WRITE (pTarget, NET2280_PCIIRQENB1_REG,                                data32 & NET2280_XIRQENB1_REG_MASK);                 }            }         else            {               /*             * endpoint index is used to access the endpoint specific hardware and              * as there is only one control endpoint, set endpoint Index to 0             */             endpointIndex = 0;            }           }     else        {        /* Disable the Endpoint by writing into EP_CFG register */        NET2280_CFG_WRITE (pTarget, NET2280_EP_CFG_OFFSET (endpointIndex), 0);        /* Disable the interupts on the endpoint */        data32 = NET2280_CFG_READ (pTarget, NET2280_PCIIRQENB0_REG);          data32 &= ~NET2280_XIRQENB0_EP(endpointIndex);                                      NET2280_CFG_WRITE (pTarget, NET2280_PCIIRQENB0_REG,                            data32 & NET2280_XIRQENB0_MASK);                    }    /* Flush the respective FIFO buffer for the endpoint */    NET2280_CFG_WRITE (pTarget, NET2280_EP_STAT_OFFSET (endpointIndex),                       NET2280_EP_STAT_FIFO_FLUSH);    if (direction == USB_TCD_ENDPT_IN)        {        data32 = NET2280_CFG_READ (pTarget,                                    NET2280_EP_IRQENB_OFFSET(endpointIndex));        data32 &= ~NET2280_EP_IRQENB_DPT;        NET2280_CFG_WRITE (pTarget, NET2280_EP_IRQENB_OFFSET(endpointIndex),                           data32 & NET2280_EP_IRQEBN_MASK);                     }         else        {        data32 = NET2280_CFG_READ (pTarget,                                    NET2280_EP_IRQENB_OFFSET(endpointIndex));         data32 &= ~NET2280_EP_IRQENB_DPR;        NET2280_CFG_WRITE (pTarget, NET2280_EP_IRQENB_OFFSET(endpointIndex),                           data32 & NET2280_EP_IRQEBN_MASK);                     }    /* Write all 1s to clear the interrupt status */    NET2280_CFG_WRITE (pTarget, NET2280_EP_STAT_OFFSET(endpointIndex),                       0xFFFFFFFF);                 /* Clear the contents of the EP RESPONSE register */    NET2280_CFG_WRITE (pTarget, NET2280_EP_RSP_OFFSET(endpointIndex),                       NET2280_EP_RSP_CLEAR(NET2280_EP_RSP_NAKOUT));    /*      * Based on the current endpoint configuration,     * reconfigure the FIFO. endpoints E and F if unconfigured,     * no FIFO reconfiguration is required.     */        if ((pEndpointInfo->endpointIndex != NET2280_ENDPT_E) &&        (pEndpointInfo->endpointIndex != NET2280_ENDPT_F))        {        /* If endpoint D is being used, then only config 1 can be set */         if ((pTarget->endpointIndexInUse & (0x1 << NET2280_ENDPT_D)) != 0)            fifoConfMode = NET2280_FIFOCTL_CFG0;        else if ((pTarget->endpointIndexInUse & (0x1 << NET2280_ENDPT_C)) != 0)            fifoConfMode = NET2280_FIFOCTL_CFG1;        else            fifoConfMode = NET2280_FIFOCTL_CFG2;         /* Read the contents of the FIFOCTL register */        data32 = NET2280_CFG_READ (pTarget, NET2280_FIFOCTL_REG);        /* Clear the configuration mode */        data32 &= ~NET2280_FIFOCTL_CFG_MASK;

⌨️ 快捷键说明

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