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

📄 usbtransunitstd.c

📁 This the compressed USB driver source code for vxworks5.6. It has device controller driver and other
💻 C
📖 第 1 页 / 共 2 页
字号:
** For string descriptors the <languageId> should specify the desired* language for the string.  According to the USB Specification, strings* descriptors are returned in UNICODE format and the <languageId> should* be the "sixteen-bit language ID (LANGID) defined by Microsoft for* Windows as described in .I "Developing International Software for Windows* 95 and Windows NT."  Please refer to Section 9.6.5 of revision 1.1 of the* USB Specification for more detail.  For device and configuration* descriptors, <languageId> should be 0.** The caller must provide a buffer to receive the descriptor data.  <pBfr>* is a pointer to a caller-supplied buffer of length <bfrLen>.	If the* descriptor is too long to fit in the buffer provided, the descriptor will* be truncated.  If a non-NULL pointer is passed in <pActLen>, the actual* length of the data transferred will be stored in <pActLen> upon return.** RETURNS: OK, or ERROR if unable to get descriptor.** ERRNO: none*/STATUS usbdDescriptorGet    (    USBD_CLIENT_HANDLE clientHandle,	/* Client handle */    USBD_NODE_ID nodeId,		/* Node Id of device/hub */    UINT8 requestType,			/* specifies type of request */    UINT8 descriptorType,		/* Type of descriptor */    UINT8 descriptorIndex,		/* Index of descriptor */    UINT16 languageId,			/* Language ID */    UINT16 bfrLen,			/* Max length of data to be returned */    pUINT8 pBfr,			/* Pointer to bfr to receive data */    pUINT16 pActLen			/* bfr to receive actual length */    )    {    USBHST_STATUS status;    UINT32  len = bfrLen;    pUSBTU_DEVICE_DRIVER pDriver = (pUSBTU_DEVICE_DRIVER) clientHandle;    /* Wind View Instrumentation */    if ((usbtuInitWvFilter & USBTU_WV_FILTER) == TRUE)        {        char evLog[USBTU_WV_LOGSIZE];        if ( pDriver != NULL)            strncpy ((char*)evLog, (char *)(pDriver->clientName),USBD_NAME_LEN );         else            strncpy ((char*)evLog, "Translation unit thread" ,                      strlen("Translation unit thread") +1);        strcat(evLog, " : Get Descriptor ");         USB_HCD_LOG_EVENT(USBTU_WV_CLIENT_STD, evLog, USBTU_WV_FILTER);         }      USBTU_LOG ( "usbdDescriptorGet entered \n ");    status = usbHstGetDescriptor( (UINT32) nodeId, descriptorType,                                    descriptorIndex, languageId, &len, pBfr);    if ( status != USBHST_SUCCESS)        {        USBTU_LOG( "usbdDescriptorGet returns ERROR \n ");        return ERROR;        }    else        {        if (pActLen != NULL)            *pActLen = len;        }    USBTU_LOG( "usbdDescriptorGet returns OK \n ");    return OK;    }/********************************************************************************* usbdDescriptorSet - sets a USB descriptor** A client uses this function to set a descriptor on the USB device identified* by <nodeId>.	The parameters <requestType>, <descriptorType>,* <descriptorIndex>, and <languageId> are the same as those described for the* usbdDescriptorGet() function.  <pBfr> is a pointer to a buffer of length* <bfrLen> which contains the descriptor data to be sent to the device.** RETURNS: OK, or ERROR if unable to set descriptor.* * ERRNO: none*/STATUS usbdDescriptorSet    (    USBD_CLIENT_HANDLE clientHandle,	/* Client handle */    USBD_NODE_ID nodeId,		/* Node Id of device/hub */    UINT8 requestType,			/* selects request type */    UINT8 descriptorType,		/* Type of descriptor */    UINT8 descriptorIndex,		/* Index of descriptor */    UINT16 languageId,			/* Language ID */    UINT16 bfrLen,			/* Max length of data to be returned */    pUINT8 pBfr 			/* Pointer to bfr to receive data */    )    {    USBHST_STATUS status;    pUSBTU_DEVICE_DRIVER pDriver = (pUSBTU_DEVICE_DRIVER) clientHandle;    /* Wind View Instrumentation */    if ((usbtuInitWvFilter & USBTU_WV_FILTER) == TRUE)        {        char evLog[USBTU_WV_LOGSIZE];        strncpy ((char*)evLog, (char *)(pDriver->clientName),USBD_NAME_LEN );         strcat(evLog, " : Set Descriptor ");         USB_HCD_LOG_EVENT(USBTU_WV_CLIENT_STD, evLog, USBTU_WV_FILTER);         }      USBTU_LOG ( "usbdDescriptorSet entered \n ");    status = usbHstSetDescriptor( (UINT32) nodeId, descriptorType,                                    descriptorIndex, languageId, pBfr, bfrLen);    if ( status != USBHST_SUCCESS)        {        USBTU_LOG( "usbdDescriptorSet returns ERROR \n ");        return ERROR;        }    else        {        USBTU_LOG( "usbdDescriptorSet returns OK \n ");        return OK;        }    }/********************************************************************************* usbdInterfaceGet - retrieves a device's current interface** This function allows a client to query the current alternate setting for* a given device抯 interface.  <nodeId> and <interfaceIndex> specify the* device and interface to be queried, respectively.  <pAlternateSetting>* points to a UINT16 variable in which the alternate setting will be stored* upon return.** RETURNS: OK, or ERROR if unable to get interface.** ERRNO: none*/STATUS usbdInterfaceGet    (    USBD_CLIENT_HANDLE clientHandle,	/* Client handle */    USBD_NODE_ID nodeId,		/* Node Id of device/hub */    UINT16 interfaceIndex,		/* Index of interface */    pUINT16 pAlternateSetting		/* Current alternate setting */    )    {    USBHST_STATUS status;    UCHAR   alternateSetting;    pUSBTU_DEVICE_DRIVER pDriver = (pUSBTU_DEVICE_DRIVER) clientHandle;    /* Wind View Instrumentation */    if ((usbtuInitWvFilter & USBTU_WV_FILTER) == TRUE)        {        char evLog[USBTU_WV_LOGSIZE];        strncpy ((char*)evLog, (char *)(pDriver->clientName),USBD_NAME_LEN );         strcat(evLog, " : Get Interface ");         USB_HCD_LOG_EVENT(USBTU_WV_CLIENT_STD, evLog, USBTU_WV_FILTER);         }      USBTU_LOG ( "usbdInterfaceGet entered \n ");    status = usbHstGetInterface( (UINT32) nodeId, interfaceIndex,                                   &alternateSetting );    if ( status != USBHST_SUCCESS)        {        USBTU_LOG( "usbdInterfaceGet returns ERROR \n ");        return ERROR;        }    else        {        if (pAlternateSetting != NULL)        *pAlternateSetting = alternateSetting;        }    USBTU_LOG( "usbdInterfaceGet returns OK \n ");    return OK;    }/********************************************************************************* usbdInterfaceSet - sets a device's current interface** This function allows a client to select an alternate setting for a given* device抯 interface.  <nodeId> and <interfaceIndex> specify the device and* interface to be modified, respectively.  <alternateSetting> specifies the* new alternate setting.** RETURNS: OK, or ERROR if unable to set interface.** ERRNO: none*/STATUS usbdInterfaceSet    (    USBD_CLIENT_HANDLE clientHandle,	/* Client handle */    USBD_NODE_ID nodeId,		/* Node Id of device/hub */    UINT16 interfaceIndex,		/* Index of interface */    UINT16 alternateSetting		/* Alternate setting */    )    {    USBHST_STATUS status;    pUSBTU_DEVICE_DRIVER pDriver = (pUSBTU_DEVICE_DRIVER) clientHandle;    /* Wind View Instrumentation */    if ((usbtuInitWvFilter & USBTU_WV_FILTER) == TRUE)        {        char evLog[USBTU_WV_LOGSIZE];        strncpy ((char*)evLog, (char *)(pDriver->clientName),USBD_NAME_LEN );         strcat(evLog, " : Set interface ");         USB_HCD_LOG_EVENT(USBTU_WV_CLIENT_STD, evLog, USBTU_WV_FILTER);         }      USBTU_LOG ( "usbdInterfaceSet entered \n ");    status = usbHstSetInterface( (UINT32) nodeId, interfaceIndex,                                  alternateSetting );    if ( status != USBHST_SUCCESS)        {        USBTU_LOG( "usbdInterfaceSet returns ERROR \n ");        return ERROR;        }    else        {        USBTU_LOG( "usbdInterfaceSet returns OK \n ");        return OK;        }    }/********************************************************************************* usbdStatusGet - Retrieves USB status from a device/interface/etc.** This function retrieves the current status from the device indicated* by <nodeId>.	<requestType> indicates the nature of the desired status* as documented for the usbdFeatureClear() function.** The status word is returned in <pBfr>.  The meaning of the status* varies depending on whether it was queried from the device, an interface,* or an endpoint, class-specific function, etc. as described in the USB* Specification.** RETURNS: OK, or ERROR if unable to get status.** ERRNO: none*/STATUS usbdStatusGet    (    USBD_CLIENT_HANDLE clientHandle,	/* Client handle */    USBD_NODE_ID nodeId,		/* Node Id of device/hub */    UINT16 requestType, 		/* Selects device/interface/endpoint */    UINT16 index,			/* Interface/endpoint index */    UINT16 bfrLen,			/* length of bfr */    pUINT8 pBfr,			/* bfr to receive status */    pUINT16 pActLen			/* bfr to receive act len xfr'd */    )    {    USBHST_STATUS status;    UINT8 recipient;    pUSBTU_DEVICE_DRIVER pDriver = (pUSBTU_DEVICE_DRIVER) clientHandle;    /* Wind View Instrumentation */    if ((usbtuInitWvFilter & USBTU_WV_FILTER) == TRUE)        {        char evLog[USBTU_WV_LOGSIZE];        strncpy ((char*)evLog, (char *)(pDriver->clientName),USBD_NAME_LEN );         strcat(evLog, " : Get Status ");         USB_HCD_LOG_EVENT(USBTU_WV_CLIENT_STD, evLog, USBTU_WV_FILTER);         }      USBTU_LOG ( "usbdStatusGet entered \n ");    /* check buffer size */    if ( bfrLen < USBTUSTD_STATUS_BUFFER_SIZE )        {        USBTU_LOG ( "usbdStatusGet returns ERROR : bfrLen less \n");        return ERROR;        }    /* get the recipient */    recipient = (UINT8)(requestType & USBTUSTD_RECIPIENT_MASK);    status = usbHstGetStatus( (UINT32) nodeId, recipient, index, pBfr);    if ( status != USBHST_SUCCESS )        {        USBTU_LOG ( "usbdStatusGet returns ERROR \n");        return ERROR;        }    else        {        if (pActLen != NULL)            *pActLen = USBTUSTD_STATUS_BUFFER_SIZE;        }    USBTU_LOG ( "usbdStatusGet returns OK \n");    return OK;    }/********************************************************************************* usbdSynchFrameGet - Returns a device's isochronous synch. frame** It is sometimes necessary for clients to re-synchronize with devices when* the two are exchanging data isochronously.  This function allows a client* to query a reference frame number maintained by the device.  Please refer* to the USB Specification for more detail.** <nodeId> specifies the node to query and <endpoint> specifies the endpoint* on that device.  Upon return the device抯 frame number for the specified* endpoint is returned in <pFrameNo>.** RETURNS: OK, or ERROR if unable to retrieve synch. frame.** ERRNO: none*/STATUS usbdSynchFrameGet    (    USBD_CLIENT_HANDLE clientHandle,	/* Client Handle */    USBD_NODE_ID nodeId,		/* Node Id of device/hub */    UINT16 endpoint,			/* Endpoint to be queried */    pUINT16 pFrameNo			/* Frame number returned by device */    )    {    USBHST_STATUS status;    pUSBTU_DEVICE_DRIVER pDriver = (pUSBTU_DEVICE_DRIVER) clientHandle;    UCHAR  bfr;     /* Wind View Instrumentation */    if ((usbtuInitWvFilter & USBTU_WV_FILTER) == TRUE)        {        char evLog[USBTU_WV_LOGSIZE];        strncpy ((char*)evLog, (char *)(pDriver->clientName),USBD_NAME_LEN );         strcat(evLog, " : Get Synch Frame ");         USB_HCD_LOG_EVENT(USBTU_WV_CLIENT_STD, evLog, USBTU_WV_FILTER);         }      USBTU_LOG ( "usbdSynchFrameGet entered \n ");    status = usbHstSetSynchFrame( (UINT32) nodeId, endpoint,&bfr);    *pFrameNo = bfr;    if ( status != USBHST_SUCCESS )        {        USBTU_LOG( "usbdSynchFrameGet returns ERROR \n ");        return ERROR;        }    else        {        USBTU_LOG( "usbdSynchFrameGet returns OK \n ");        return OK;        }    }

⌨️ 快捷键说明

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