Ready for review
Disconnect / Reconnect USB Devices
During runtime you can remove or re-enumerate USB Class drivers. Note that this interface is a non standard
API. Seco extended the OHCI driver with that interface to help customers with problems on different
USB devices with unspecified problems.
#define FILE_DEVICE_USB 0x0000B001
#define IOCTL_DISCONNECT_PORT CTL_CODE(FILE_DEVICE_USB, 0x401, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_RECONNECT_PORT CTL_CODE(FILE_DEVICE_USB, 0x402, METHOD_BUFFERED, FILE_ANY_ACCESS)
void Disconnect_USB_Port(int portno) // 0,1
{
HANDLE hDeviceUSB = CreateFile( TEXT("HCD1:"), GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
unsigned long ReEnumeratePorts = 1 << portno; // 1 = Port 1 2 = Port 2 3=both
DeviceIoControl( hDeviceUSB, IOCTL_DISCONNECT_PORT, &ReEnumeratePorts, sizeo(ReEnumeratePorts), NULL, 0, &returned, NULL);
CloseHandle(hDeviceUSB);
}
void Reconnect_USB_Port(int portno) // 0,1
{
HANDLE hDeviceUSB = CreateFile( TEXT("HCD1:"), GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
unsigned long ReEnumeratePorts = 1 << portno; // 1 = Port 1 2 = Port 2 3=both
DeviceIoControl( hDeviceUSB, IOCTL_RECONNECT_PORT, &ReEnumeratePorts, sizeo(ReEnumeratePorts), NULL, 0, &returned, NULL);
CloseHandle(hDeviceUSB);
}