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

📄 urb.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 5 页
字号:
    {        OS_LOG_MESSAGE_MEDIUM(            USBD,            "USBHST_GetDescriptor() Failed:Invalid parameter.\n",            0,            0,            0,            0);        return USBHST_INVALID_PARAMETER;    }    /* Obtain the device info of the device handle */    usbdTranslateDeviceHandle(hDevice, &pDeviceInfo);    /* Check if the device info obtained is valid */    if (NULL == pDeviceInfo)    {         OS_LOG_MESSAGE_MEDIUM(             USBD,             "USBHST_GetDescriptor() Failed:Invalid parameter.\n",             0,             0,             0,             0);        return USBHST_INVALID_PARAMETER;    }    /*     * if uDescType is configuration then check if uDescIndex is a valid     * configuration index     */    if ((USBHST_CONFIG_DESC == uDescType) &&        (uDescIndex >= pDeviceInfo->uNumConfigurations))    {         OS_LOG_MESSAGE_MEDIUM(             USBD,             "USBHST_GetDescriptor() Failed:Invalid parameter.\n",             0,             0,             0,             0);        return USBHST_INVALID_PARAMETER;    }    /*     * If the uDescType is for device qualifier or other speed configuration     * descriptor then bcdUSB of the device should be >= 0x0200     */    if ((USBHST_OTHER_SPEED_CONFIG_DESC == uDescType)||        (USBHST_DEVICE_QUALIFIER_DESC == uDescType))    {      if ( 0x0200 > pDeviceInfo->uBCDDevice)      {          OS_LOG_MESSAGE_MEDIUM(             USBD,             "USBHST_GetDescriptor() Failed:Invalid parameter.\n",             0,             0,             0,             0);        return USBHST_INVALID_PARAMETER;      }    }   /*    * fetch the other speed configuration descriptor only if the status of    * GET_DESCRIPTOR for device qualifier is successfull.    */    if (USBHST_OTHER_SPEED_CONFIG_DESC == uDescType)    {       /* To store the device qualifier of the device */       USBHST_DEVICE_QUALIFIER DeviceQualifier;       /* To store the size of device qualifier */       UINT32                  uSize = 0;       /* Update the size */       uSize = sizeof(USBHST_DEVICE_QUALIFIER);       /* memset the device qualifier */       OS_MEMSET (&DeviceQualifier,0,uSize);       /* fetch the device qualifier */       nReturnStatus = usbHstGetDescriptor(hDevice,                                            USBHST_DEVICE_QUALIFIER_DESC,                                            0,                                            0,                                            &uSize,                                            (PUCHAR)&DeviceQualifier);      /* If fetching device qualifier fails */      if ( (USBHST_SUCCESS != nReturnStatus )||           (sizeof(USBHST_DEVICE_QUALIFIER)!= uSize ))      {        return USBHST_FAILURE;      } /* End If fetching device qualifier fails */      /* Convert the qualifier buffer into CPU endian */      OS_BUFFER_LE_TO_CPU(&DeviceQualifier, sizeof(USBHST_DEVICE_QUALIFIER));      /* If the requested other speed config index is not vaild */      if (uDescIndex >= DeviceQualifier.bNumConfigurations)      {        return USBHST_INVALID_PARAMETER;      } /* END if the requested other speed config index is not vaild */    } /* END fetch the other speed configuration descriptor only if ...*/    nReturnStatus =  usbdSubmitRequest (pDeviceInfo,                                        128,                                        USBHST_REQ_GET_DESCRIPTOR,                                        ((uDescType << 8) | uDescIndex),                                        swLangID,                                        puSize,                                        pBuffer);    /* Return the status returned from submit request call */    return nReturnStatus;    } /* End of function usbHstGetDescriptor() *//**************************************************************************** usbHstGetStatus -   Get USB Status ** This function is used to issue the GetStatus USB Standard request** RETURNS: USBHST_SUCCESS, USBHST_INVALID_PARAMETERS,* USBHST_INSUFFICIENT_MEMORY, USBHST_TIMEOUT if request submitted* to Host controller Driver is timed out** ERRNO: None*/USBHST_STATUS usbHstGetStatus    (    UINT32   hDevice,     /* Handle to USB Device            */    UINT8    uRecipient,  /* Desired recipient               */    UINT16   uIndex,      /* Index of receipient             */    UCHAR   *pBuffer      /* Ptr to data buffer to hold data */    )    {    /* To store the device info */    pUSBD_DEVICE_INFO       pDeviceInfo = NULL;    /* To store the usb status returned on submission of request */    USBHST_STATUS           nReturnStatus = USBHST_FAILURE;    /* size of the data to be fetched */    UINT32                  uSize = 0;		/* WindView Instrumentation */		USB_USBD_LOG_EVENT(			USB_USBD_WV_REQUEST,			"Entering usbHstGetStatus() Function.",			USB_USBD_WV_FILTER);    OS_LOG_MESSAGE_LOW(USBD,                       "Entering USBHST_GetStatus() Function.\n",                       0,                       0,                       0,                       0);    /* Check if  buffer are valid */    if (NULL == pBuffer)    {        OS_LOG_MESSAGE_MEDIUM(            USBD,            "usbHstGetStatus() Failed:Invalid parameter.\n",            0,            0,            0,            0);        return USBHST_INVALID_PARAMETER;    }    /* Check if the recipient is either device, interface or endpoint */    if (USBHST_RECIPIENT_ENDPOINT < uRecipient)    {       OS_LOG_MESSAGE_MEDIUM(            USBD,            "usbHstGetStatus() Failed:Invalid parameter.\n",            0,            0,            0,            0);        return USBHST_INVALID_PARAMETER;    }    /* Obtain the device info of the device handle */    usbdTranslateDeviceHandle(hDevice,&pDeviceInfo);    /* Check if the device info obtained is valid */    if (NULL == pDeviceInfo)    {        OS_LOG_MESSAGE_MEDIUM(            USBD,            "usbHstGetStatus() Failed:Invalid device handle parameter.\n",            0,            0,            0,            0);        return USBHST_INVALID_PARAMETER;    }    /*     * If recipient is a device then index should be zero.     * If recipient is an interface then check if it is valid.     * To avoid complexity of code, check for validity of endpoint is not done     * since it needs to parse all interfaces for the given endpoint.     */    if (((USBHST_RECIPIENT_DEVICE == uRecipient) &&         (uIndex != 0)) ||        ((USBHST_RECIPIENT_INTERFACE == uRecipient) &&         (uIndex >= pDeviceInfo->uInterfaceCount)))    {        OS_LOG_MESSAGE_MEDIUM(            USBD,            "usbHstGetStatus() Failed:Invalid parameter.\n",            0,            0,            0,            0);        return USBHST_INVALID_PARAMETER;    }    uSize = 2;    nReturnStatus =  usbdSubmitRequest (pDeviceInfo,                                        128 | uRecipient,                                        USBHST_REQ_GET_STATUS,                                        0,                                        uIndex,                                        &uSize,                                        pBuffer);    /* Return the status returned from submit request call */    return nReturnStatus;    } /* End of function GetStatus *//**************************************************************************** usbHstClearFeature - clear feature USB request** This function is used to issue ClearFeature USB Standard Request** RETURNS: USBHST_SUCCESS, USBHST_INVALID_PARAMETERS,* USBHST_INSUFFICIENT_MEMORY, USBHST_TIMEOUT if request submitted* to Host controller Driver is timed out** ERRNO: None*/USBHST_STATUS usbHstClearFeature    (    UINT32    hDevice,       /* USB device handle */    UINT8     uRecipient,    /* Desired recipient */    UINT16    uIndex,        /* Recipient index   */    UINT16    uFeature       /* Feature selector  */    )    {    /* To store the device info */    pUSBD_DEVICE_INFO       pDeviceInfo = NULL;    /* To store the usb status returned on submission of request */    USBHST_STATUS           nReturnStatus = USBHST_FAILURE;    /* size of the data to be fetched */    UINT32                  uSize = 0;		/* WindView Instrumentation */		USB_USBD_LOG_EVENT(			USB_USBD_WV_REQUEST,			"Entering usbHstClearFeature() Function.",			USB_USBD_WV_FILTER);    OS_LOG_MESSAGE_LOW(USBD,                       "Entering usbHstClearFeature() Function.\n",                       0,                       0,                       0,                       0);    /*     * if recipient is device then feature should be remote wakeup     * if recipient is endpoint then feature should be endpoint halt     */    if (((USBHST_RECIPIENT_DEVICE == uRecipient) &&         (USBHST_FEATURE_DEVICE_REMOTE_WAKEUP != uFeature)) ||        ((USBHST_RECIPIENT_ENDPOINT == uRecipient) &&         (USBHST_FEATURE_ENDPOINT_HALT != uFeature)))    {        OS_LOG_MESSAGE_MEDIUM(            USBD,            "usbHstClearFeature() Failed:Invalid parameter.\n",            0,            0,            0,            0);        return USBHST_INVALID_PARAMETER;    }    /* If recipient is device then uIndex should be zero */    if (USBHST_RECIPIENT_DEVICE == uRecipient)    {        if (uIndex != 0)        {            OS_LOG_MESSAGE_MEDIUM(                USBD,                "usbHstClearFeature() Failed:Invalid parameter.\n",                0,                0,                0,                0);            return USBHST_INVALID_PARAMETER;        }    }    /* TEST MODE feature can not be cleared */    if (USBHST_FEATURE_TEST_MODE == uFeature)    {      return USBHST_INVALID_PARAMETER;    }    /* Obtain the device info of the device handle */    usbdTranslateDeviceHandle(hDevice, &pDeviceInfo);    /* Check if the device info obtained is valid */    if (NULL == pDeviceInfo)    {        OS_LOG_MESSAGE_MEDIUM(            USBD,            "usbHstClearFeature() Failed:Invalid parameter.\n",            0,            0,            0,            0);        return USBHST_INVALID_PARAMETER;    }    uSize = 0;    nReturnStatus =  usbdSubmitRequest(pDeviceInfo,                                        uRecipient,                                        USBHST_REQ_CLEAR_FEATURE,                                        uFeature,                                        uIndex,                                        &uSize,                                        NULL);     /* Return the status returned from submit request call */    return nReturnStatus;    } /* End of function usbHstClearFeature()*//**************************************************************************** usbHstGetConfiguration -  get configuration USB request** This function is used to issue the GetConfiguration USB Standard Request** RETURNS: USBHST_SUCCESS, USBHST_INVALID_PARAMETERS,* USBHST_INSUFFICIENT_MEMORY, USBHST_TIMEOUT if request submitted* to Host controller Driver is timed out** ERRNO: None*/USBHST_STATUS usbHstGetConfiguration    (    UINT32    hDevice,       /* USB Device handle          */    UCHAR    *pBuffer        /* Ptr to fetched data buffer */    )    {    /* To store the device info */    pUSBD_DEVICE_INFO       pDeviceInfo = NULL;    /* To store the usb status returned on submission of request */    USBHST_STATUS           nReturnStatus = USBHST_FAILURE;    /* size of the data to be fetched */    UINT32                  uSize = 0;		/* WindView Instrumentation */		USB_USBD_LOG_EVENT(			USB_USBD_WV_REQUEST,			"Entering usbHstGetConfiguration() Function.",			USB_USBD_WV_FILTER);    OS_LOG_MESSAGE_LOW(USBD,                       "Entering usbHstGetConfiguration() Function.\n",                       0,                       0,                       0,                       0);    /* Check if buffer are valid */    if (NULL == pBuffer)    {        OS_LOG_MESSAGE_MEDIUM(            USBD,            "usbHstGetConfiguration() Failed:Invalid parameter.\n",            0,            0,            0,            0);

⌨️ 快捷键说明

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