But NOT using EZ-USB which I suspect is messing my programme up. Perhaps it does not allow for the extra memory in the FX2LP. I have written code to download a program (in hex or iic format) to RAM or EEPROM, but that was when the FX2 was running vend-ax (or our software, which is derived from it). I just need to get a file handle and then use some library functionto send 0xA0 commands to fill memory (bracketed by setting and clearing Reset bit in CPUCS).
Or has someone already written this :-)
I tried using SetupDiGetClassDevs() with various GUID:
static GUID GUID_0xe0317cca = {0xe0317cca, 0xbb7c, 0x4e2a, 0x9f, 0x28, 0xa6,
0x98, 0xe6, 0x0e, 0xde, 0x99};static GUID GUID_0x36FC9E60 = {0x36FC9E60, 0xC465, 0x11CF, 0x80, 0x56, 0x44,
0x45, 0x53, 0x54, 0x00, 0x00};And keep getting ERROR_NO_MORE_ITEMS even for interface number zero.
hCypress = CreateFile(\\\\.\\ezusb-0,GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,NULL);
yields a good handle but then
DeviceIoControl( hCypress, IOCTL_ADAPT_GET_DRIVER_VERSION,
&Ver, sizeof(Ver), &Ver, sizeof(Ver), &BytesReturned, NULL)fails with "The parameter is incorrect".
I also tried the thing I really wanted to do and it failed with "The parameter is incorrect":
{const unsigned iPage = 0;
const size_t BufferLength = 64;
const unsigned __int16 MemoryAddress = BufferLength * iPage;
const size_t InfoBlockSize = sizeof(SINGLE_TRANSFER) + BufferLength;
char InfoBlock[InfoBlockSize];
PSINGLE_TRANSFER pInfoBlock = (PSINGLE_TRANSFER)InfoBlock;
union
{struct
{UCHAR Recipient:5;
UCHAR Type:2;
UCHAR Direction:1;
} Bits;
UCHAR Byte;
} Request;
Request.Bits.Recipient = TGT_DEVICE;
Request.Bits.Type = REQ_VENDOR;
Request.Bits.Direction = DIR_FROM_DEVICE;
memset(InfoBlock,0,sizeof(InfoBlock));
pInfoBlock->SetupPacket.bmRequest = Request.Byte;
pInfoBlock->SetupPacket.bRequest = VR_ANCHOR_LOAD_INTERNAL;
pInfoBlock->SetupPacket.wVal.lowByte = LSByte(MemoryAddress);
pInfoBlock->SetupPacket.wVal.hiByte = MSByte(MemoryAddress);
pInfoBlock->SetupPacket.wIndex = 0x0000;
pInfoBlock->SetupPacket.wLen.lowByte = LSByte(BufferLength);
pInfoBlock->SetupPacket.wLen.hiByte = MSByte(BufferLength);
pInfoBlock->SetupPacket.ulTimeOut = 2; // Seconds ?
pInfoBlock->ucEndpointAddress = 0x00; // Endpoint 0
pInfoBlock->IsoPacketOffset = 0;
pInfoBlock->BufferOffset = sizeof(SINGLE_TRANSFER);
pInfoBlock->BufferLength = BufferLength;
DWORD BytesReturned = 0;
if ( ! DeviceIoControl( hCypress, IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER,
pInfoBlock, InfoBlockSize,
pInfoBlock, InfoBlockSize,
&BytesReturned, NULL) ) {const LastErrorC LastError;
cerr