Cypress CyUsb3.sys Programmer\\'s Reference

更新时间:2024-05-31 11:27:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

Cypress CyUsb3.sys

Programmer's Reference

? 2012 Cypress Semiconductor

Contents3Table of Contents

Part IDriver Overview5Part IIModifying CyUSB3.INF7Part IIIMatching Devices to the Driver

13

1Windows XP................................................................................................................................... 142Windows Vista ,Win7 and Win8 Beta................................................................................................................................... 16

Part IVReinstalling the Driver19Part VThe IOCTL Interface

20

1Getting a Handle to the Driver................................................................................................................................... 212IOCTL_ADAPT_ABORT_PIPE................................................................................................................................... 233IOCTL_ADAPT_CYCLE................................................................................................................................... 24_PORT4IOCTL_ADAPT_GE................................................................................................................................... 25T_ADDRESS5IOCTL_ADAPT_GE................................................................................................................................... 26T_ALT_INTERFACE_SETTING6IOCTL_ADAPT_GE................................................................................................................................... 27T_CURRENT_FRAME7IOCTL_ADAPT_GE................................................................................................................................... 28T_DEVICE_NAME8IOCTL_ADAPT_GE................................................................................................................................... 29T_DEVICE_POWER_STATE9IOCTL_ADAPT_GE................................................................................................................................... 30T_DEVICE_SPEED10IOCTL_ADAPT_GE................................................................................................................................... 31T_DRIVER_VERSION11IOCTL_ADAPT_GE................................................................................................................................... 32T_FRIENDLY_NAME12IOCTL_ADAPT_GE................................................................................................................................... 33T_NUMBER_ENDPOINTS13IOCTL_ADAPT_GE................................................................................................................................... 34T_TRANSFER_SIZE14IOCTL_ADAPT_GE................................................................................................................................... 35T_USBDI_VERSION15IOCTL_ADAPT_RE................................................................................................................................... 36SET_PARENT_PORT16IOCTL_ADAPT_RE................................................................................................................................... 37SET_PIPE17IOCTL_ADAPT_SE................................................................................................................................... 38LECT_INTERFACE18IOCTL_ADAPT_SE................................................................................................................................... 39ND_EP0_CONTROL_TRANSFER19IOCTL_ADAPT_SE................................................................................................................................... 41ND_NON_EP0_TRANSFER20IOCTL_ADAPT_SE................................................................................................................................... 43ND_NON_EP0_DIRECT21IOCTL_ADAPT_SE................................................................................................................................... 46T_DEVICE_POWER_STATE22IOCTL_ADAPT_SE................................................................................................................................... 47T_TRANSFER_SIZE

Part VICYIOCTL.H

48

1ISO_ADV_PARAMS................................................................................................................................... 50

? 2012 Cypress Semiconductor

3

4Cypress CyUsb3.sys Programmer's Reference2SINGLE................................................................................................................................... 52_TRANSFER3SETUP_PACKE................................................................................................................................... 53T4SET_TRANSFE................................................................................................................................... 54R_SIZE_INFO

Part VIIFeatures Not Supported

Part VIIIEZ-USB.sys to CyUSB3.sys Migration Guide

Index

555659

? 2012 Cypress Semiconductor

Driver Overview51Driver Overview

The CYUSB3.SYS driver is licensed for distribution ONLY with Cypress USB products andproducts that employ Cypress USB chips. CyUSB3.sys is a kernel mode USB function driver,it is capable of communicating with any USB 2.0 andUSB3.0 compliant devices. The driver is general-purpose, understanding primitive USB commands, butnot implementing higher-level, USB device-class specific commands. For this reason, the driver is notcapable, for instance, of interfacing a USB mass storage class device to the Windows file system.Please note that this release does not include the USB3.0 bulk streaming interface. The driver would be ideal for communicating with a vendor-specific device from a custom USB applicationor to send low-level USB requests to any USB device for experimental or diagnostic applications. In order to use the driver to communicate with a device, Windows must match the device to the driver. The class library, CyAPI.lib and Cyusb.dll, provides a high-level programming interface to the driver. Thishelp file documents the low-level, more cumbersome and explicit programming interface.The driver supports following operating systems and platform.1. Windows XP 32 bit2. Windows Vista 32/64bit3. Windows 7 and 32/64 bit 4. Windows 8 Beta 32/64 bitCypress signed CyUSB3.sys driver for following Cypress VID/PID pairs.1. VID_04B4&PID_00F02. VID_04B4&PID_00F13. VID_04B4&PID_00F34. VID_04B4&PID_4720

Please note, the driver is signed for above mentioned pairs of Cypress VID/PID. If you modify CyUSB3.inf to add your own VID/PID, the driver will become unsigned. However, Windows OS will allow to installthe unsigned driver with warning messages on 32-bit and 64-bit platform. You can go for WHQL drivercertification with your own VID/PID once your product is ready.

Features

?Windows Driver Foundation (WDF) compliant ?Compatible with any USB 2.0 compliant device

?Compatible with Cypress USB 3.0 compliant device?Supports basic USB3.0 features.

?Supports Windows Plug and play and power management ?Supports USB Remote Wake-up

?Supports Control, Bulk, Interrupt and Isochronous transfers?Supports multiple USB devices connected at once

?Supports customizable driver GUID without re-building the driver

?Supports high bandwidth data transfers passing multiple packets per micro-frame

? 2012 Cypress Semiconductor

6Cypress CyUsb3.sys Programmer's Reference

? 2012 Cypress Semiconductor

Modifying CyUSB3.INF72Modifying CyUSB3.INF

The CYUSB3.INF file can be modified to accomplish several different objectives. These are: 1. Add a device's identifiers to the driver2. Replace Cypress strings that are displayed during driver installation3. Implement a custom GUID for the driver NOTE: x86 refers to the 32bit OS and amd64 refers to 64 bit OS. Add a device's identifiers to the driver The following steps describe the process of adding a device's vendor ID and product ID to the CYSUB3.INF file. 1. Locate the following sections [Device],[Device.NT],[Device.Ntx86] and [Device.Ntamd64] andremove the semicolon of each item under the each section ;%VID_XXXX&PID_XXXX.DeviceDesc%=CyUSB3, USB\\VID_XXXX&PID_XXXX 2. Change the VID_XXXX to contain the hexadecimal value of the VendorID for the device and change the PID_XXXX to contain the hexadecimal value of the ProductID for the device For example, a device with vendorID 0x04B4 and productID 0xDE01 would have a new entry in theabove listed sections like following %VID_04B4&PID_DE01.DeviceDesc%=CyUSB3, USB\\VID_04B4&PID_DE01 3. Change [String] section for Device Description according to the Vendor ID and Product ID. VID_XXXX&PID_XXXX.DeviceDesc=\ 4. Change the VID_XXXX to contain the hexadecimal value of the VendorID for the device Change the PID_XXXX to contain the hexadecimal value of the ProductID for the device For example, a device with vendorID 0x04B4 and productID 0xDE01 would have a new entry in the[Strings] section like the following VID_04B4&PID_DE01.DeviceDesc=\ Replace Cypress strings If you plan to do more than just add your device's VID/PID to the CYUSB3.INF file, it is stronglyrecommended that you create your own .INF file and a copy of CYUSB3.SYS that you have re-named.The remaining instructions assume that you have created your own .INF file to match your newly namedcopy of CYUSB3.SYS. The driver can be customized to report a company other than Cypress as its manufacturer and provider. 1. Locate the [Strings] section at the bottom of the CYUSB3.INF file.? 2012 Cypress Semiconductor

8Cypress CyUsb3.sys Programmer's Reference 2. Change the quoted CYUSB3_Provider string. 3. Change the quoted CYUSB3_DisplayName string. 4. Change the quoted CYUSB3_Company string. 5. Change the quoted CYUSB3_Description string. Implement a custom GUID Applications software usually accesses the driver using the driver's Global Unique IDentifier (GUID).Each driver in the Windows system should have a unique GUID. By employing distinct GUIDs, multipleinstances of CYUSB3.SYS from different hardware vendors can exist on a given system withoutcolliding. 1. To change the driver's GUID, 2. Use the GUIDGEN.EXE utility (distributed with Microsoft Visual Studio) to get a new GUID. 3. Locate the [Strings] section in the CyUSB3.inf file 4. Locate the line CYUSB3.GUID=\18AA60-7F6A-11d4-97DD-00010229B959}\ and replace the quoted GUID string with the new one you created. (Retain the curly braces.) Execute a script at start-upThe CYUSB3.SYS driver can be used to perform transfers to the default control endpoint (endpointaddress 0) when the device is started.

To configure the driver to perform a control transfer at startup

1. Use the CyControl.exe application to create a script file containing the control transfer commands.2. Save the script as a file named MyDevice.SPT

3. Place that script file in the same directory as the the driver's .INF file

A common use of this feature is to have the driver play a script which downloads a firmware image to theUSB device, thereby modifying its \f thisre-enumeration occurs with the same VID/PID as the original \again and again in an un-ending loop.

To avoid this endless loop scenario, the second personality should enumerate with a different VID/PIDthan the one which caused the script to play.

The .inf file can be modified to play a script when one VID/PID is enumerated and to simply load thedriver when a different VID/PID is detected.How to disable the CyScript feature To disable this feature the user needs to delete the key 'DriverEXECSCRIPT' from the registry.The following steps should be followed to delete the key.

? 2012 Cypress Semiconductor

Modifying CyUSB3.INF91. Execute the 'regedit.exe' application.2. Search for the 'DriverEXECSCRIPT'.3. Delete the key 'DriverEXECSCRIPT'.4. Close 'regedit.exe'.

The following is an excerpt from a .inf file that plays a script called MyDevice.spt when VID/PID of04B4/00F3 is enumerated. If VID/PID 0547/00F0 enumerates, the script is not played.

NOTE: For FX3 devices, the MyDevice.spt script will play only when the connected device supports FX3boot commands.Sample CYUSB3.INF file using the CyScript feature with VID-0x04B4 and PID-0x00F3 and0x00F0 ; Installation INF for the Cypress Generic USB Driver for OS unknown; Processor support for x86 based platforms.;

; (c) Copyright 2012 Cypress Semiconductor Corporation;

[Version]

Signature=\NDOWS NT$\Class=USB

ClassGUID={36FC9E60-C465-11CF-8056-444553540000}provider=%CYUSB3_ProviderêtalogFile=CYUSB3.cat

DriverVer=01/23/2012,1.0.0.01[SourceDisksNames]1=%CYUSB3_Install%,,,[SourceDisksFiles]CYUSB3.sys = 1

[DestinationDirs]CYUSB3.Files.Ext = 10,System32\\DriversMyDevice.Files.Ext = 10,System32\\MyDevice[ControlFlags]ExcludeFromSelect = *

[Manufacturer]

%CYUSB3_Provider%=Device,NT,NTx86,NTamd64

;for all platforms[Device.NT]

%VID_04B4&PID_00F3.DeviceDesc%=MyDevice, USB\\VID_04B4&PID_00F3%VID_04B4&PID_00F0.DeviceDesc%=CYUSB3, USB\\VID_04B4&PID_00F0;for x86 platforms[Device.NTx86]

%VID_04B4&PID_00F3.DeviceDesc%=MyDevice, USB\\VID_04B4&PID_00F3%VID_04B4&PID_00F0.DeviceDesc%=CYUSB3, USB\\VID_04B4&PID_00F0

? 2012 Cypress Semiconductor

10Cypress CyUsb3.sys Programmer's Reference;for x64 platforms[Device.NTamd64]

%VID_04B4&PID_00F3.DeviceDesc%=MyDevice, USB\\VID_04B4&PID_00F3%VID_04B4&PID_00F0.DeviceDesc%=CYUSB3, USB\\VID_04B4&PID_00F0[MyDevice]

CopyFiles=CYUSB3.Files.Ext,MyDevice.Files.ExtAddReg=CYUSB3.AddReg [MyDevice.HW]

AddReg=MyDevice.AddReg.Guid

[MyDevice.Services]

Addservice = CYUSB3,2,CYUSB3.AddService [MyDevice.NT]

CopyFiles=CYUSB3.Files.Ext, MyDevice.Files.ExtAddReg=CYUSB3.AddReg [MyDevice.NT.HW]

AddReg=MyDevice.AddReg.Guid

[MyDevice.NT.Services]

Addservice = CYUSB3,2,CYUSB3.AddService[MyDevice.NTx86]

CopyFiles=CYUSB3.Files.Ext, MyDevice.Files.ExtAddReg=CYUSB3.AddReg [MyDevice.NTx86.HW]

AddReg=MyDevice.AddReg.Guid

[MyDevice.NTx86.Services]

Addservice = CYUSB3,2,CYUSB3.AddService [MyDevice.NTamd64]

CopyFiles=CYUSB3.Files.Ext, MyDevice.Files.ExtAddReg=CYUSB3.AddReg [MyDevice.NTamd64.HW]

AddReg=MyDevice.AddReg.Guid

[MyDevice.NTamd64.Services]

Addservice = CYUSB3,2,CYUSB3.AddService [MyDevice.AddReg.Guid]

HKR,,DriverGUID,,%CYUSB3.GUID%HKR,,DriverEXECSCRIPT,,%MyDevice.EXECSCRIPT%[MyDevice.Files.Ext]MyDevice.spt

[CYUSB3.NT]

CopyFiles=CYUSB3.Files.ExtAddReg=CYUSB3.AddReg[CYUSB3.NT.HW]

? 2012 Cypress Semiconductor

Modifying CyUSB3.INF11AddReg=CYUSB3.AddReg.Guid

[CYUSB3.NT.Services]

Addservice = CYUSB3,2,CYUSB3.AddService

[CYUSB3.NTx86]

CopyFiles=CYUSB3.Files.ExtAddReg=CYUSB3.AddReg[CYUSB3.NTx86.HW]

AddReg=CYUSB3.AddReg.Guid

[CYUSB3.NTx86.Services]

Addservice = CYUSB3,2,CYUSB3.AddService[CYUSB3.NTamd64]

CopyFiles=CYUSB3.Files.ExtAddReg=CYUSB3.AddReg[CYUSB3.NTamd64.HW]

AddReg=CYUSB3.AddReg.Guid

[CYUSB3.NTamd64.Services]

Addservice = CYUSB3,2,CYUSB3.AddService

[CYUSB3.AddReg]

; Deprecating - do not use in new apps to identify a CYUSB3 driverHKR,,DevLoader,,*ntkern

HKR,,NTMPDriver,,CYUSB3.sys

; You may optionally include a check for DriverBase in your application to check for a CYUSB3 driverHKR,,DriverBase,,CYUSB3.sys

HKR,\arameters\aximumTransferSize\HKR,\arameters\ebugLevel\HKR,,FriendlyName,,%CYUSB3_Description%

[CYUSB3.AddService]

DisplayName = %CYUSB3_Description%ServiceType = 1 ; SERVICE_KERNEL_DRIVERStartType = 3 ; SERVICE_DEMAND_STARTErrorControl = 1 ; SERVICE_ERROR_NORMALServiceBinary = %\\System32\\Drivers\\CYUSB3.sysAddReg = CYUSB3.AddRegLoadOrderGroup = Base[CYUSB3.Files.Ext]CYUSB3.sys

[CYUSB3.AddReg.Guid]

HKR,,DriverGUID,,%CYUSB3.GUID%

;-------------- WDF Coinstaller installation[SourceDisksFiles]

WdfCoInstaller01009.dll=1 ; make sure the number matches with SourceDisksNames[DestinationDirs]

CoInstaller_CopyFiles = 11

? 2012 Cypress Semiconductor

12Cypress CyUsb3.sys Programmer's Reference[CYUSB3.NTamd64.CoInstallers]AddReg=CoInstaller_AddRegCopyFiles=CoInstaller_CopyFiles[CYUSB3.NTx86.CoInstallers]AddReg=CoInstaller_AddRegCopyFiles=CoInstaller_CopyFiles[CoInstaller_CopyFiles]WdfCoInstaller01009.dll

[CoInstaller_AddReg]

HKR,,CoInstallers32,0x00010000, \oInstaller01009.dll,WdfCoInstaller\[CYUSB3.NTamd64.Wdf]

KmdfService = CYUSB3, CYUSB3_wdfsect[CYUSB3.NTx86.Wdf]

KmdfService = CYUSB3, CYUSB3_wdfsect[CYUSB3_wdfsect]

KmdfLibraryVersion = 1.9

[Strings]

CYUSB3_Provider = \ypress\

CYUSB3_Company = \ypress Semiconductor Corporation\CYUSB3_Description = \ypress Generic USB3.0 Driver\CYUSB3_DisplayName = \ypress USB3.0 Generic\

CYUSB3_Install = \ypress CYUSB3.0 Driver Installation Disk\VID_04B4&PID_00F3.DeviceDesc=\ypress USB BootLoader\VID_04B4&PID_00F0.DeviceDesc=\ypress BULK LOOP\CYUSB3.GUID=\18AA60-7F6A-11d4-97DD-00010229B959}\CYUSB3_Unused = \MyDevice.EXECSCRIPT=\root\\system32\\MyDevice\\MyDevice.spt\

? 2012 Cypress Semiconductor

Matching Devices to the Driver133Matching Devices to the Driver

Usually matching of a USB device to the CYUSB3.SYS driver will need to be manually configured. Following are the steps user has to follow to install driver on Windows OS. Step A : Add the device's VendorID and ProductID to the CYUSB3.INF file.Step B : Force Windows to use the CYUSB3.SYS driver with the device. Though similar, these steps are slightly different for WinXP and Windows Vista and 7

? 2012 Cypress Semiconductor

14Cypress CyUsb3.sys Programmer's Reference3.1Windows XP

Usually, matching of a USB device to the CYUSB3.SYS driver will need to be manually configured.

Please follow below steps to update the INF file and driver installation on Windows XP.

Note: Please skip step B to install driver on 32-bit OS.

Step A : Please follow the below steps to add the device's VendorID and ProductID to the CYUSB3.INFfile.

1.After installation of the Cypress Suite USB installer, the driver file is located in a Driver

subdirectory of the install directory. (Default is C:\\Program Files\\Cypress\\FX3 HostSoftware\\Driver\\bin.).

2.Open the file CYUSB3.INF with a text editor (notepad.exe, for instance)

3.Locate the following sections [Device],[Device.NT],[Device.Ntx86] and [Device.Ntamd64] and

remove the semicolon of each item under the each section

;%VID_XXXX&PID_XXXX.DeviceDesc%=CyUsb3, USB\\VID_XXXX&PID_XXXX.

4.Change the VID_XXXX to contain the hexadecimal value of the VendorID for the device and change the PID_XXXX to contain the hexadecimal value of the ProductID for the device.

For example, a device with vendorID 0x04B4 and productID 0xDE01 would have a new entry inthe above listed sections like following:

%VID_04B4&PID_DE01.DeviceDesc%=CyUSB3, USB\\VID_04B4&PID_DE01

5.Change [String] section for Device Description according to the Vendor ID and Product ID. VID_XXXX&PID_XXXX.DeviceDesc=\er\

6.Change the VID_XXXX to contain the hexadecimal value of the VendorID for the device and change the PID_XXXX to contain the hexadecimal value of the ProductID for the device.

For example, a device with vendorID 0x04B4 and productID 0xDE01 would have a new entryin the [Strings] section like the following:

VID_04B4&PID_DE01.DeviceDesc=\3 Bulk loopback\

7.Save the file.

Step B : Please follow the below steps to force WindowsXP to use the cyusb3.sys driver with thedevice.

1.Connect the device to the PC

2.If Windows prompts for a driver or indicates that it needs a driver, direct the PC to use the

CYUSB3.SYS driver by steering it to the CYUSB3.INF file in the [InstallDir]\\Driver directory.

3.If Windows does not prompt for a driver, it has already matched the device to a driver itself. In

this case, you will need to see if the CYUSB3.SYS driver was selected and, if not, manuallyinstruct Windows to use that driver.

4.Right-click My Computer and select the Manage menu item.

? 2012 Cypress Semiconductor

Matching Devices to the Driver15

5.In the Computer Management window, select Device Manager

6.In the right window pane, click the + icon next to Universal Serial Bus controllers

7.Locate your device in the list and double click on it

8.Select the Driver tab in the Properties dialog that comes up

9.Click on the Driver Details button.

10.If the displayed driver file is CYUSB3.SYS, Windows has already matched the device to this

driver and you should click OK and Cancel . If not, proceed with the remaining steps.

11.Click OK

12.Click Update Driver

13.Select Install from a list or specific location (Advanced)

14.Click Next

15.Select Don't search. I will choose the driver to install.

16.Click Next

17.Click Have Disk

18.Click Browse

19.Navigate to the directory containing CYUSB3.SYS (wxp(Windows XP) and select x86(32-bit

OS) or x64(64-bit OS)) based on the platform you want to install driver on.

20.CYUSB3.INF should be automatically placed in the File name field

21.Click Open

22.Click OK

23.Click Next

24.It will popup message saying Unsigned driver, Please select 'Install driver software anyway'

and click ok.

25.Click Finish

26.Click Close

27.Don't re-boot your system if Windows suggests that you must. You may need to unplug and

re-plug your device, however.

? 2012 Cypress Semiconductor

26Cypress CyUsb3.sys Programmer's Reference5.5IOCTL_ADAPT_GET_ALT_INTERFACE_SETTING

Description

This command retrieves the alternate interface setting for a particular interface of the attached device.

A pointer to a byte indicating the interface number is passed as the lpInBuffer parameter to theDeviceIoControl( ) function.

A pointer to a byte into which the alternate interface setting will be reported is passed as the lpOutBufferparameter to the DeviceIoControl( ) function.

The length of the variables (1) is passed in the nInBufferSize and nOutBufferSize parameters.

Example

DWORD dwBytes = 0;UCHAR intfc = 0;UCHAR alt;

DeviceIoControl(hDevice, IOCTL_ADAPT_GET_ALT_INTERFACE_SETTING, &intfc, sizeof (alt), &alt, sizeof (alt), &dwBytes, NULL);

? 2012 Cypress Semiconductor

The IOCTL Interface275.6IOCTL_ADAPT_GET_CURRENT_FRAME

Description

This command returns the current frame number from the host controller driver.

A pointer to a 4-byte variable is passed as both the lpInBuffer and lpOutBuffer parameters to theDeviceIoControl( ) function.

The size of the variable (4) is passed in the nInBufferSize and nOutBufferSize parameters.

Example

DWORD dwBytes = 0;ULONG CurrentFrame;

DeviceIoControl(hDevice, IOCTL_ADAPT_GET_CURRENT_FRAME,

DeviceIoControl(hDevice, IOCTL_ADAPT_GET_CURRENT_FRAME, &CurrentFrame, sizeof (ULONG), &CurrentFrame, sizeof (ULONG), &dwBytes, NULL);

? 2012 Cypress Semiconductor

28Cypress CyUsb3.sys Programmer's Reference5.7IOCTL_ADAPT_GET_DEVICE_NAME

Description

This command retrieves the Product string descriptor value for the attached device.

A pointer to a character buffer is passed as both the lpInBuffer and lpOutBuffer parameters to theDeviceIoControl( ) function.

The length of the buffer is passed in the nInBufferSize and nOutBufferSize parameters.

Example

DWORD dwBytes = 0;ULONG len = 256;

UCHAR *buf = new UCHAR[len];

DeviceIoControl(hDevice, IOCTL_ADAPT_GET_DEVICE_NAME, buf, len, buf, len,

&dwBytes, NULL);

delete[] buf;

? 2012 Cypress Semiconductor

The IOCTL Interface295.8IOCTL_ADAPT_GET_DEVICE_POWER_STATE

Description

This IOCTL is no longer supported. It is available to keep backward compatibility with older interfacelibrary and application.

Microsoft WDF driver framework manages device power state internally.

? 2012 Cypress Semiconductor

30Cypress CyUsb3.sys Programmer's Reference5.9IOCTL_ADAPT_GET_DEVICE_SPEED

Description

This command attempts to report the current operating speed of the USB device. It uses the

IsDeviceHighSpeed routine, but this routine is only supported in Version 1 of the USBD interface.Windows 2K SP4, Windows XP and later all support Version 1 of the USBD interface. If the

IsDeviceHighSpeed routine is not available, DEVICE_SPEED_UNKNOWN is returned. The possiblereturn value of this IOCTL is defined in the cyioctl.h header file.

A pointer to a 4-byte variable is passed as both the lpInBuffer and lpOutBuffer parameters to theDeviceIoControl( ) function.

The size of the variable (4) is passed in the nInBufferSize and nOutBufferSize parameters.

Defines (cyioctl.h)

#define DEVICE_SPEED_UNKNOWN 0x00000000#define DEVICE_SPEED_LOW_FULL 0x00000001#define DEVICE_SPEED_HIGH 0x00000002

#define DEVICE_SPEED_SUPER 0x00000004

Example

DWORD dwBytes = 0;ULONG DevSpeed;

DeviceIoControl(hDevice, IOCTL_ADAPT_GET_DEVICE_SPEED, &DevSpeed, sizeof (ULONG), &DevSpeed, sizeof (ULONG), &dwBytes, NULL);

? 2012 Cypress Semiconductor

36Cypress CyUsb3.sys Programmer's Reference5.15IOCTL_ADAPT_RESET_PARENT_PORT

Description

This command resets the upstream port of the device it manages. After a successful reset, the busdriver reselects the configuration and any alternative interface settings that the device had before thereset occurred. All pipe handles, configuration handles and interface handles remain valid.

A null pointer is passed as both the lpInBuffer and lpOutBuffer parameters to the DeviceIoControl( )function.

Example

DWORD dwBytes;

DeviceIoControl(hDevice, IOCTL_ADAPT_RESET_PARENT_PORT, NULL, 0, NULL, 0,

&dwBytes, NULL);

? 2012 Cypress Semiconductor

The IOCTL Interface375.16IOCTL_ADAPT_RESET_PIPE

Description

This command resets an endpoint of the device, clearing any error or stall conditions on that endpoint.Pending data transfers are not cancelled by this command.

The address of a single byte is passed as the lpInBuffer parameter to the DeviceIoControl( ) function.

A null pointer is passed as the lpOutBuffer parameter.

Example

DWORD dwBytes;

UCHAR Address = 0x82;

DeviceIoControl(hDevice, IOCTL_ADAPT_RESET_PIPE, &Address, sizeof (Address) NULL, 0,

&dwBytes, NULL);

? 2012 Cypress Semiconductor

38Cypress CyUsb3.sys Programmer's Reference5.17IOCTL_ADAPT_SELECT_INTERFACE

Description

This command sets the alternate interface setting for the primary interface of the attached device.

A pointer to a byte indicating the alternate interface setting is passed as both the lpInBuffer andlpOutBuffer parameters to the DeviceIoControl( ) function.

The length of the variable (1) is passed in the nInBufferSize and nOutBufferSize parameters.

Example

DWORD dwBytes = 0;UCHAR alt = 2;

DeviceIoControl (hDevice, IOCTL_ADAPT_SELECT_INTERFACE, &alt, sizeof (alt), &alt, sizeof (alt), &dwBytes, NULL);

? 2012 Cypress Semiconductor

The IOCTL Interface395.18IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER

IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFERPrevious Top Next Description This command sends a control request to the default Control endpoint, endpoint zero. DeviceIoControl( ) is passed a pointer to a two-part structure as both the lpInBuffer and lpOutBufferparameters. This two-part structure contains a SINGLE_TRANSFER structure followed by a data buffer. The SINGLE_TRANSFER structure contains all the parameters for the control request. The buffer contains the transfer data. NOTE : Please note that this IOCTL return device configuration inclusive of both interface for USB3.0composite device. This is the limitation due to the USBDI bus interface. The USBDI doesn't supportUSB3.0 specific device configuration. Example union {struct {UCHAR Recipient:5;UCHAR Type:2;UCHAR Direction:1;} bmRequest; UCHAR bmReq;}; bmRequest.Recipient = 0; // DevicebmRequest.Type = 2; // VendorbmRequest.Direction = 1; // IN command (from Device to Host) int iXmitBufSize = sizeof(SINGLE_TRANSFER) + bufLen; // The size of the two-partstructureUCHAR *pXmitBuf = new UCHAR[iXmitBufSize]; // Allocate the memoryZeroMemory(pXmitBuf, iXmitBufSize); PSINGLE_TRANSFER pTransfer = (PSINGLE_TRANSFER)pXmitBuf; // The SINGLE_TRANSFER comesfirstpTransfer->SetupPacket.bmRequest = bmReq;pTransfer->SetupPacket.bRequest = ReqCode;pTransfer->SetupPacket.wValue = Value;pTransfer->SetupPacket.wIndex = Index;pTransfer->SetupPacket.wLength = bufLen;pTransfer->SetupPacket.ulTimeOut = TimeOut / 1000;pTransfer->Reserved = 0;pTransfer->ucEndpointAddress = 0x00; // Control pipepTransfer->IsoPacketLength = 0;pTransfer->BufferOffset = sizeof (SINGLE_TRANSFER);pTransfer->BufferLength = bufLen;? 2012 Cypress Semiconductor

40Cypress CyUsb3.sys Programmer's ReferenceDWORD dwReturnBytes;

DeviceIoControl (hDevice, IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER, pXmitBuf, iXmitBufSize, pXmitBuf, iXmitBufSize, &dwReturnBytes, NULL);

// Copy data into buf

UCHAR *ptr = pXmitBuf + sizeof (SINGLE_TRANSFER);memcpy(buf, ptr, dwReturnBytes);

? 2012 Cypress Semiconductor

本文来源:https://www.bwwdw.com/article/n206.html

Top