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

📄 usbdlib.c

📁 This the USB source code for vxworks5.5. It has OSS library source code and also the complete targ
💻 C
📖 第 1 页 / 共 5 页
字号:
    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 * each endpoint in its configuration descriptors.  The client will typically * read these descriptors using the USBD Configuration Functions and then * parse the descriptors to retrieve the appropriate maximum payload value.* * <bandwidth> specifies the bandwidth required for this pipe.  For control* and bulk pipes, this parameter should be 0.  For interrupt pipes, this* parameter should express the number of bytes per frame to be transferred.* for isochronous pipes, this parameter should express the number of bytes* per second to be transferred.** <serviceInterval> specifies the maximum latency for the pipe in * milliseconds.  So, if a pipe needs to be serviced, for example, at least * every 20 milliseconds, then the <serviceInterval> value should be 20.  The * <serviceInterval> parameter is required only for interrupt pipes.  For * other types of pipes, <serviceInterval> should be 0.** If the USBD succeeds in creating the pipe it returns a pipe handle in * <pPipeHandle>.  The client must use the pipe handle to identify the pipe * in subsequent calls to the USBD Transfer Functions.  If there is * insufficient bus bandwidth available to create the pipe (as might happen * for an isochronous or interrupt pipe), then the USBD will return an error * and a NULL handle in <pPipeHandle>.** RETURNS: OK, or ERROR if pipe could not be create*/STATUS usbdPipeCreate    (    USBD_CLIENT_HANDLE clientHandle,	/* Client handle */    USBD_NODE_ID nodeId,		/* Node Id of device/hub */    UINT16 endpoint,			/* Endpoint number */    UINT16 configuration,		/* config w/which pipe associated */    UINT16 interface,			/* interface w/which pipe associated */    UINT16 transferType,		/* Type of transfer: control, bulk... */    UINT16 direction,			/* Specifies IN or OUT endpoint */    UINT16 maxPayload,			/* Maximum data payload per packet */    UINT32 bandwidth,			/* Bandwidth required for pipe */    UINT16 serviceInterval,		/* Required service interval */    pUSBD_PIPE_HANDLE pPipeHandle	/* pipe handle returned by USBD */    )    {    URB_PIPE_CREATE urb;    STATUS s;    /* Initalize URB */    urbInit (&urb.header, clientHandle, USBD_FNC_PIPE_CREATE, NULL, NULL,	sizeof (urb));    urb.nodeId = nodeId;    urb.endpoint = endpoint;    urb.configuration = configuration;    urb.interface = interface;    urb.transferType = transferType;    urb.direction = direction;    urb.maxPayload = maxPayload;    urb.bandwidth = bandwidth;    urb.serviceInterval = serviceInterval;    /* Execute URB */    s = urbExecBlock (&urb.header);

⌨️ 快捷键说明

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