Mercurial > hg > ucis.core
diff USBLib/Communication/USBIO/USBIODevice.cs @ 46:053cc617af54
USBLib: added functions to clear USB endpoint halt state
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Sun, 30 Jun 2013 16:28:36 +0200 |
parents | 5a2b51b0d71b |
children | abe0d55a2201 |
line wrap: on
line diff
--- a/USBLib/Communication/USBIO/USBIODevice.cs Wed Jun 12 23:20:21 2013 +0200 +++ b/USBLib/Communication/USBIO/USBIODevice.cs Sun Jun 30 16:28:36 2013 +0200 @@ -27,6 +27,7 @@ static readonly int IOCTL_USBIO_CLASS_OR_VENDOR_OUT_REQUEST = _USBIO_IOCTL_CODE(13, METHOD_IN_DIRECT); static readonly int IOCTL_USBIO_RESET_DEVICE = _USBIO_IOCTL_CODE(21, METHOD_BUFFERED); static readonly int IOCTL_USBIO_BIND_PIPE = _USBIO_IOCTL_CODE(30, METHOD_BUFFERED); + static readonly int IOCTL_USBIO_RESET_PIPE = _USBIO_IOCTL_CODE(32, METHOD_BUFFERED); [DllImport("kernel32.dll", SetLastError = true)] static unsafe extern bool ReadFile(SafeFileHandle hFile, byte* lpBuffer, uint nNumberOfBytesToRead, out uint lpNumberOfBytesRead, IntPtr lpOverlapped); @@ -155,12 +156,18 @@ public override int BulkWrite(byte endpoint, byte[] buffer, int offset, int length) { return PipeWrite(endpoint, buffer, offset, length); } + public override void BulkReset(byte endpoint) { + PipeReset(endpoint); + } public override int InterruptRead(byte endpoint, byte[] buffer, int offset, int length) { return PipeRead(endpoint, buffer, offset, length); } public override int InterruptWrite(byte endpoint, byte[] buffer, int offset, int length) { return PipeWrite(endpoint, buffer, offset, length); } + public override void InterruptReset(byte endpoint) { + PipeReset(endpoint); + } public unsafe override int ControlRead(UsbControlRequestType requestType, byte request, short value, short index, byte[] buffer, int offset, int length) { return ControlTransfer(requestType, request, value, index, buffer, offset, length); } @@ -257,7 +264,8 @@ return (int)ret; } public void PipeReset(byte pipeID) { - throw new NotImplementedException(); + SafeFileHandle handle = GetHandleForPipe(pipeID); + DeviceIoControl(handle, IOCTL_USBIO_RESET_PIPE, IntPtr.Zero, 0, IntPtr.Zero, 0); } private unsafe int DeviceIoControl(SafeHandle hDevice, int IoControlCode, IntPtr InBuffer, int nInBufferSize, IntPtr OutBuffer, int nOutBufferSize) {