CYAPI.lib is not detecting in fx-2 device

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ThM_3776866
Level 4
Level 4
First like received First like given Welcome!

Hi all,

I working fx-2 and fx-3 cypress EV board.  I created one C++ console application in PC visual studio-17. I include CyAPI.h header and CyAPI.lib library realtive path in C/C++ and linker properties. its build successful and i added below code in my c++ file

int main(void)

{

CCyBulkEndPoint *OutEndpt_I2C = NULL, *InEndpt_I2C = NULL, *InEndpt_TS = NULL;

CCyUSBDevice *USBDevice = NULL;

UCHAR DevCnt = 0;

int i = 0, numOfEpts = 0;

CCyUSBEndPoint *endpt = NULL;

USBDevice = new CCyUSBDevice(NULL);

if (0 == (DevCnt = USBDevice->DeviceCount()))

{

printf("\n\n\n*** Cypress Device Not Connected ***\n\n\n");

//exit(-1);

return false;

}

printf("\n*** Number of Cypress Devices are (%d)***\n", DevCnt);

for (i = 0; i < USBDevice->DeviceCount(); i++)

{

if (USBDevice->Open(i))

{

if (0x04b4 == USBDevice->VendorID && 0x00F0 == USBDevice->ProductID)

{

printf("\n\n\n*** Cypress Device Connected ***\n\n\n");

break;

}

USBDevice->Close();

}

}

if (USBDevice != NULL)

{

USBDevice->Reset();

numOfEpts = USBDevice->EndPointCount();

for (i = 0; i < numOfEpts; i++)

{

endpt = USBDevice->EndPoints;

if (endpt->Attributes == 2)

{

if ((endpt->Address & 0x80) && (endpt->bIn))

{// BULK : In-EndPoint

if ((endpt->Address & 0x7F) == 0x01)

{

InEndpt_I2C = (CCyBulkEndPoint *)USBDevice->EndPoints;;

}

else if ((endpt->Address & 0x7F) == 0x02)

{

InEndpt_TS = (CCyBulkEndPoint *)USBDevice->EndPoints;;

}

}

else

{// BULK : Out-EndPoint

if ((endpt->Address & 0x7F) == 0x01)

{

OutEndpt_I2C = (CCyBulkEndPoint *)USBDevice->EndPoints;;

}

}

}

}

}

return true;

}

This code is working fine and detecting fx-3 device correctly, if i connect fx-2 device its showing " printf("\n\n\n*** Cypress Device Not Connected ***\n\n\n"); " .

Q1. is it fx2 need different lib file?

Q2. in given SDK have cpp lib and inc file its working properly. if you have any CPP code with fx2 lib please let me know.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Hello,

I tried executing your code and it worked fine. It successfully detected FX2 device. I have attached a CyAPI.lib file(x86) from FX3 SDK to this response. Please link this lib file and try it on your side.

Best Regards

Yatheesh

View solution in original post

0 Likes
3 Replies
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello,

Can you please check if the FX2 device is coming up in device manager and is getting detected by the control center application.

Best Regards

Yatheesh

0 Likes
ThM_3776866
Level 4
Level 4
First like received First like given Welcome!

Yes sir it is detecting on both control center and device manager.

0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

I tried executing your code and it worked fine. It successfully detected FX2 device. I have attached a CyAPI.lib file(x86) from FX3 SDK to this response. Please link this lib file and try it on your side.

Best Regards

Yatheesh

0 Likes