2016-08-02 172 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)。 –