#include #pragma comment(lib, "FTD2XX.lib") #include "FTD2XX.h" #include #include #include int main(int argc, char* argv[]) { #define OneSector 128*1024 FT_HANDLE ftHandle; FT_STATUS ftStatus; UCHAR Mask = 0xff; UCHAR Mode; UCHAR LatencyTimer = 16; //default setting is 16; Best perfomance is 2 DWORD InTransferSize = 64*1024; //SetUSBParameters DWORD OutTransferSize = 1024; //SetUSBParameters DWORD EventDWord; DWORD RxBytes; DWORD TxBytes; DWORD BytesReceived; unsigned char RxBuffer[OneSector]; WORD alt = 0; WORD neu = 0; int p = 0; WORD temp; int i = 0; SetPriorityClass (GetCurrentProcess(), REALTIME_PRIORITY_CLASS); /* REALTIME_PRIORITY_CLASS------highest HIGH_PRIORITY_CLASS ABOVE_NORMAL_PRIORITY_CLASS NORMAL_PRIORITY_CLASS BELOW_NORMAL_PRIORITY_CLASS IDLE_PRIORITY_CLASS------lowest */ ftStatus = FT_Open(0, &ftHandle); if(ftStatus == FT_OK) { printf("Successfull open channel A! \n"); } else { printf("Unsuccessfull open channel A! \n"); } Mode = 0x00; //reset mode ftStatus = FT_SetBitMode(ftHandle, Mask, Mode); Mode = 0x40; //Sync FIFO mode ftStatus = FT_SetBitMode(ftHandle, Mask, Mode); if (ftStatus == FT_OK) { printf("Set the bit mode to: Sync Mode \n"); ftStatus = FT_SetLatencyTimer(ftHandle, LatencyTimer); ftStatus = FT_SetUSBParameters(ftHandle,InTransferSize,OutTransferSize); ftStatus = FT_SetFlowControl(ftHandle,FT_FLOW_RTS_CTS,0,0); } else { printf("Can't set bit mode! \n"); } ftStatus = FT_Purge(ftHandle, FT_PURGE_RX | FT_PURGE_TX); if(ftStatus == FT_OK) { printf("Successfull purge! \n"); } else { printf("Unsuccessfull purge!! \n"); } FILE* outfile1; outfile1 = fopen("D:\\Results.txt", "w"); while(kbhit() != 1) { ftStatus = FT_GetStatus(ftHandle,&RxBytes,&TxBytes,&EventDWord); if((ftStatus == FT_OK) && (RxBytes < OneSector)) { ftStatus = FT_Read(ftHandle,RxBuffer,RxBytes,&BytesReceived); if ((ftStatus == FT_OK) && (RxBytes > 0)) { p = 0; while(p+1