2016-08-02 174 views
0

我寫了一個訪問FPGA上的LED的代碼。無論如何,我不能成功編譯Visual Studio中的下面的代碼:'USB_Close':標識符未找到...'len':未聲明的標識符...

#ifdef STATS_LIBRARY_EXPORTS 
# define LIBRARY_API __declspec(dllexport) 
#else 
# define LIBRARY_API __declspec(dllimport) 
#endif 

#include <windows.h> 
#include "stdafx.h" 
#include <iostream> 
#include <fstream> 
#include <conio.h> 
#include <time.h> 
#include <bitset> 
#include <stdio.h> 

#include "C:\Cypress\Cypress Suite USB 3.4.7\CyAPI\inc\CyAPI.h" 





_declspec(dllexport) int excite_LED(bool start, int on) { 


int i; 
USB_Open(); 
for(i=0; i<100; i++) // blink the LEDs for a few seconds 
{ 
USB_BulkWrite(2, &i, 1); // send one single byte (= the value of i) to FIFO2 
Sleep(50); // and wait 50ms 


BulkOutPipe2->XferData((PUCHAR)&i, len); // send one byte (the value of i) to FIFO2 


//Send command to FPGA 
//status = !BulkOutPipe2->XferData(fpgaCommunicator, fpgaCommunicatorBytes); 


} 
USB_Close(); 

} 

我收到以下錯誤:

left of '->XferData' must point to class/struct/union/generic type 
identifier "USB_Open" is undefined 
identifier "USB_Close" is undefined 
identifier "USB_BulkWrite" is undefined 
identifier "len" is undefined 
identifier "BulkOutPipe2" is undefined 
cannot open source file "stdafx.h" 
'USB_Open': identifier not found 
'USB_Close': identifier not found 
'USB_BulkWrite': identifier not found 
'len': undeclared identifier 
'BulkOutPipe2': undeclared identifier 

如何解決我的代碼來擺脫這些錯誤的?

回答

0

BulkOutPipe2是對端點3許多樣品在一個共同的定義,但它不是在CyAPI.h設定,所以你需要自己設置它:

#define BulkOutPipe2 USBDevice->EndPoints[3] 

,你需要初始化: CCyUSBDevice * USBDevice = new CCyUSBDevice(NULL,...);

萊恩也沒有定義:

LONG len= 512000; 

USB_BulkWrite(和其他USB_)看起來像usb_bulk_write,這是的libusb API的一部分。但是你正在嘗試使用CyApi(這是很多不同的),所以刪除這些方法調用。

+0

謝謝你的幫助!如何確定newCCYUSBDevice的第二個參數(NULL,...)? –

+0

根據文檔,第二個參數用你想要的id定義設備。如果你只有一個,你可以離開它,只需要CCyUSBDevice(NULL)。 –