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

📄 usbdlib.c

📁 VxWorks下USB驱动的源代码!
💻 C
📖 第 1 页 / 共 5 页
字号:
    s = urbExecBlock (&urb.header);    /* Return result */    if (pActLen != NULL)        *pActLen = urb.actLen;    return s;}/***************************************************************************** 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.*/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 */    ){    URB_DESCRIPTOR_GET_SET urb;    /* Initalize URB */    urbInit (&urb.header, clientHandle, USBD_FNC_DESCRIPTOR_SET, NULL, NULL, sizeof (urb));    urb.nodeId = nodeId;    urb.requestType = requestType;    urb.descriptorType = descriptorType;    urb.descriptorIndex = descriptorIndex;    urb.languageId = languageId;    urb.bfrLen = bfrLen;    urb.pBfr = pBfr;    /* Execute URB */    return urbExecBlock (&urb.header);}/***************************************************************************** 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.*/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 */    ){    URB_INTERFACE_GET_SET urb;    STATUS s;    /* Initalize URB */    urbInit (&urb.header, clientHandle, USBD_FNC_INTERFACE_GET, NULL, NULL, sizeof (urb));    urb.nodeId = nodeId;    urb.interfaceIndex = interfaceIndex;    /* Execute URB */    s = urbExecBlock (&urb.header);    /* Return result */    if (pAlternateSetting != NULL)        *pAlternateSetting = urb.alternateSetting;    return s;}/***************************************************************************** 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.*/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 */    ){    URB_INTERFACE_GET_SET urb;    /* Initalize URB */    urbInit (&urb.header, clientHandle, USBD_FNC_INTERFACE_SET, NULL, NULL, sizeof (urb));    urb.nodeId = nodeId;    urb.interfaceIndex = interfaceIndex;    urb.alternateSetting = alternateSetting;    /* Execute URB */    return urbExecBlock (&urb.header);}/***************************************************************************** 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.*/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 */    ){    URB_STATUS_GET urb;    STATUS s;    /* Initalize URB */    urbInit (&urb.header, clientHandle, USBD_FNC_STATUS_GET, NULL, NULL, sizeof (urb));    urb.nodeId = nodeId;    urb.requestType = requestType;    urb.index = index;    urb.bfrLen = bfrLen;    urb.pBfr = pBfr;    /* Execute URB */    s = urbExecBlock (&urb.header);    /* Return result */    if (pActLen != NULL)        *pActLen = urb.actLen;    return s;}/***************************************************************************** usbdAddressGet - Gets the USB address for a given device** This function returns the USB address assigned to device specified by * <nodeId>.  USB addresses are assigned by the USBD, so there is generally * no need for clients to query the USB device address.	Furthermore, this * function has no counterpart in the USB functions described in Chapter 9 * of the USB Specification.** The USBD assigns device addresses such that they are unique within the * scope of each USB host controller.  However, it is possible that two or * more devices attached to different USB host controllers may have identical * addresses.** RETURNS: OK, or ERROR if unable to set address.*/STATUS usbdAddressGet (USBD_CLIENT_HANDLE clientHandle, /* Client handle */                       USBD_NODE_ID nodeId, /* Node Id of device/hub */                       pUINT16 pDeviceAddress   /* Currently assigned device address */    ){    URB_ADDRESS_GET_SET urb;    STATUS s;    /* Initalize URB */    urbInit (&urb.header, clientHandle, USBD_FNC_ADDRESS_GET, NULL, NULL, sizeof (urb));    urb.nodeId = nodeId;    /* Execute URB */    s = urbExecBlock (&urb.header);    /* Return result */    if (pDeviceAddress != NULL)        *pDeviceAddress = urb.deviceAddress;    return s;}/***************************************************************************** usbdAddressSet - Sets the USB address for a given device** This function sets the USB address at which a device will respond to future * requests.  Upon return, the address of the device identified by <nodeId> * will be changed to the value specified in <deviceAddress>.  <deviceAddress> * must be in the range from 0..127.  The <deviceAddress> must also be unique * within the scope of each USB host controller.** The USBD manages USB device addresses automatically, and this function * should never be called by normal USBD clients.  Changing a device address * may cause serious problems, including device address conflicts, and may * cause the USB to cease operation.** RETURNS: OK, or ERROR if unable to get current device address.*/STATUS usbdAddressSet (USBD_CLIENT_HANDLE clientHandle, /* Client handle */                       USBD_NODE_ID nodeId, /* Node Id of device/hub */                       UINT16 deviceAddress /* New device address */    ){    URB_ADDRESS_GET_SET urb;    /* Initalize URB */    urbInit (&urb.header, clientHandle, USBD_FNC_ADDRESS_SET, NULL, NULL, sizeof (urb));    urb.nodeId = nodeId;    urb.deviceAddress = deviceAddress;    /* Execute URB */    return urbExecBlock (&urb.header);}/***************************************************************************** usbdVendorSpecific - Allows clients to issue vendor-specific USB requests** Certain devices may implement vendor-specific USB requests which cannot * be generated using the standard functions described elsewhere.  This * function allows a client to specify directly the exact parameters for a * USB control pipe request.** <requestType>, <request>, <value>, <index>, and <length> correspond * exactly to the bmRequestType, bRequest, wValue, wIndex, and wLength fields * defined by the USB Specfication.  If <length> is greater than zero, then * <pBfr> must be a non-NULL pointer to a data buffer which will provide or * accept data, depending on the direction of the transfer. ** Vendor specific requests issued through this function are always directed * to the control pipe of the device specified by <nodeId>.  This function* formats and sends a Setup packet based on the parameters provided.  If a * non-NULL <pBfr> is also provided, then additional IN or OUT transfers* will be performed following the Setup packet.  The direction of these* transfers is inferred from the direction bit in the <requestType> param.* For IN transfers, the actual length of the data transferred will be* stored in <pActLen> if <pActLen> is not NULL.** RETURNS: OK, or ERROR if unable to execute vendor-specific request.*/STATUS usbdVendorSpecific (USBD_CLIENT_HANDLE clientHandle, /* Client handle */                           USBD_NODE_ID nodeId, /* Node Id of device/hub */                           UINT8 requestType,   /* bmRequestType in USB spec. */                           UINT8 request,   /* bRequest in USB spec. */                           UINT16 value,    /* wValue in USB spec. */                           UINT16 index,    /* wIndex in USB spec. */                           UINT16 length,   /* wLength in USB spec. */                           pUINT8 pBfr, /* ptr to data buffer */                           pUINT16 pActLen  /* actual length of IN */    ){    URB_VENDOR_SPECIFIC urb;    STATUS s;    /* Initalize URB */    urbInit (&urb.header, clientHandle, USBD_FNC_VENDOR_SPECIFIC, NULL, NULL, sizeof (urb));    urb.nodeId = nodeId;    urb.requestType = requestType;    urb.request = request;    urb.value = value;    urb.index = index;    urb.length = length;    urb.pBfr = pBfr;    /* Execute URB */    s = urbExecBlock (&urb.header);    /* return results */    if (pActLen != NULL)        *pActLen = urb.actLen;    return s;}/***************************************************************************** usbdPipeCreate - Creates a USB pipe for subsequent transfers** This function establishes a pipe which can subsequently be used by a * client to exchange data with a USB device endpoint.  ** <nodeId> and <endpoint> identify the device and device endpoint, * respectively, to which the pipe should be "connected."  <configuration>* and <interface> specify the configuration and interface, respectively,* with which the pipe is associated.  (The USBD uses this information to* keep track of "configuration events" associated with the pipe).** <transferType> specifies the type of data transfers for which this pipe * will be used:** .IP "USB_XFRTYPE_CONTROL"* Control transfer pipe (message).* .IP "USB_XFRTYPE_ISOCH"* Isochronous transfer pipe (stream).* .IP "USB_XFRTYPE_INTERRUPT"* Interrupt transfer pipe (stream).* .IP "USB_XFRTYPE_BULK"* Bulk transfer pipe (stream).** <direction> specifies the direction of the pipe as:** .IP "USB_DIR_IN"* Data moves from device to host.* .IP "USB_DIR_OUT"* Data moves from host to device.* .IP "USB_DIR_INOUT"* Data moves bidirectionally (message pipes only).** If the <direction> is specified as USB_DIR_INOUT, the USBD assumes that * both the IN and OUT endpoints identified by endpoint will be used by * this pipe (see the discussion of message pipes in Chapter 5 of the USB * Specification).  USB_DIR_INOUT may be specified only for Control pipes.** <maxPayload> specifies the largest data payload supported by this endpoint.  * Normally a USB device will declare the maximum payload size it supports on 

⌨️ 快捷键说明

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