Этот код у меня работает c FT245BM ...
//---------- Rx thread exec function -------------------------
DWORD WINAPI ReaderAndStatusProc(LPVOID lpV)
{
#define NUM_READSTAT_HANDLES 2
#define USB_BYTES_TO_RX 256
FT_STATUS ftStatus;
DWORD BytesRead = 0;
DWORD EventDWord;
DWORD RxBytes;
DWORD TxBytes;
DWORD buf_pos;
DWORD dwRes;
static DWORD TimeoutCnt = 0;
HANDLE hArray[NUM_READSTAT_HANDLES];
char Buf[1024];
BOOL fThreadDone = FALSE;
hArray[0] = hNotifyEvent;
hArray[1] = hRxUSBExitEvent;
TimeoutCnt = 0;
while(!fThreadDone)
{
//FT_GetStatus(hUSB,&RxBytes,&TxBytes,&EventDWord);
dwRes = ::WaitForMultipleObjects(NUM_READSTAT_HANDLES, hArray, FALSE, 1);
switch(dwRes)
{
case WAIT_OBJECT_0:
ftStatus = FT_GetStatus (hUSB,&RxBytes,&TxBytes,&EventDWord);
if(ftStatus == FT_OK && RxBytes > 0)
{
TimeoutCnt = 0;
gfTimeout = FALSE;
while(RxBytes > 0)
{
FT_Read(hUSB,Buf,RxBytes < USB_BYTES_TO_RX ? RxBytes : USB_BYTES_TO_RX,&BytesRead);
RxBytes -= BytesRead;
//---------------------------
BytesRXed += BytesRead;
for(buf_pos = 0; buf_pos < BytesRead; buf_pos++)
rx_decoder(Buf[buf_pos]);
//---------------------------
}
}
break;
case WAIT_OBJECT_0 + 1: // thread exit event
fThreadDone = TRUE;
break;
case WAIT_TIMEOUT:
if(TimeoutCnt < 500)
TimeoutCnt ++;
else
{
gfTimeout = TRUE;
}
break;
}
}
//-------------------
FT_Close(hUSB);
CloseHandle(hNotifyEvent);
return 1;
}
//----------------------------------------------------------------------------
int SendToUSB(int addr,int command,int n,unsigned char * data)
{
FT_STATUS ftStatus;
DWORD RxBytes;
DWORD TxBytes;
DWORD EventDWord;
DWORD BytesWritten = 0;
DWORD Timeout = 0;
int bytes_to_tx;
unsigned char * data_to_tx;
if(hUSB == NULL || uc_tx_coder_func == NULL)
return 0;
uc_tx_coder_func(addr,command,n,data,&bytes_to_tx,&data_to_tx);
for(;;)
{
ftStatus = FT_GetStatus(hUSB,&RxBytes,&TxBytes,&EventDWord);
if(ftStatus == FT_OK && TxBytes == 0)
{
ftStatus = FT_Write(hUSB,data_to_tx,bytes_to_tx,&BytesWritten);
break;
}
else
{
Timeout++;
if(Timeout > 100000)
return 0;
}
}
return 1;
}