WinDriver provides you with an API for resetting your USB device: WD_UsbResetDevice() and WD_UsbResetDeviceEx() (added in version 5.0.4 of WinDriver). These functions cause the hub driver to reinitialize the device, while preserving the existing configuration. WD_UsbResetDeviceEx() — added in version 5.0.4 — enables you to distinguish between performing a soft reset — which is similar to the reset performed with the WD_UsbResetDevice() function, used in previous versions; Or a hard reset.
The differences between a soft reset and a hard reset, performed with
WD_UsbResetDeviceEx(), are as follows:
To use the hard reset option, set the WD_USB_HARD_RESET flag in the dwOptions field of the WD_USB_RESET_DEVICE structure, which is passed to WD_UsbResetDeviceEx(). By default, when the dwOptions field is set to 0, the function will perform a soft reset — i.e., the reset request will be issued only if the device is currently disabled. Following is an an example of using WD_UsbResetEx() to perform a hard reset:
WD_USB_RESET_DEVICE reset;
BZERO(resest);
reset.hDevice = hDevice; // The handle received from
// WD_UsbDeviceRegister()
reset.dwOptions = WD_USB_HARD_RESET;
WD_UsbResetDeviceEx(hWD, &reset);
NOTE: To prevent a system crash when performing hard reset, it is recommended to do the following: immediately after calling WD_UsbResetDeviceEx(), un-register the device (by calling WD_UsbDeviceUnregister()), scan for it (by calling WD_UsbScanDevice()) and then register it again (by calling WD_UsbDeviceRegister()). This will ensure that Windows will allocate all the resources for the device and will eliminate possible conflicts later on. |

