Created
August 4, 2014 09:29
-
-
Save sytsereitsma/d0d181f4bef76ca5f41e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HANDLE handle = ::CreateFileW (L"\\\\.\\ezusb-0", | |
GENERIC_READ | GENERIC_WRITE, | |
FILE_SHARE_READ | FILE_SHARE_WRITE, | |
0, | |
OPEN_EXISTING, | |
0, | |
0); | |
unsigned short pipe; | |
unsigned short commandCode; //Command code sent to device which has the IC on board | |
unsigned receivedLength; | |
const unsigned long kBulkWrite = 0x0800 + 20; | |
const unsigned long kWriteRegister = (FILE_DEVICE_UNKNOWN << 16) | (FILE_ANY_ACCESS << 14) | (kBulkWrite << 2) | METHOD_IN_DIRECT; | |
const unsigned long kBulkRead = 0x0800 + 19; | |
const unsigned long kReadData = (FILE_DEVICE_UNKNOWN << 16) | (FILE_ANY_ACCESS << 14) | (kBulkRead << 2) | METHOD_OUT_DIRECT; | |
//Pipe 0, Device Tx register command | |
pipe = 0; | |
commandCode = 0xBEEF; //Control code sent to device which has the IC on board | |
DeviceIoControl (handle, kWriteRegister, &pipe, 2, &commandCode, 2, &receivedLength); | |
//Pipe 1, Rx register command | |
pipe = 1; | |
commandCode = 0xDEAD; | |
DeviceIoControl (handle, kWriteRegister, &pipe, 2, &commandCode, 2, &receivedLength); | |
//Pipe 2, Receive data into buffer | |
pipe = 2; | |
unsigned char buffer [128]; | |
DeviceIoControl (handle, kReadData, &pipe, 2, &buffer, 128, &receivedLength); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment