3 Replies Latest reply on Apr 23, 2019 5:30 AM by YatheeshK_36

    CYAPI.lib is not detecting in fx-2 device

    ThM_3776866

      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[i];

      if (endpt->Attributes == 2)

      {

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

      {// BULK : In-EndPoint

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

      {

      InEndpt_I2C = (CCyBulkEndPoint *)USBDevice->EndPoints[i];;

      }

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

      {

      InEndpt_TS = (CCyBulkEndPoint *)USBDevice->EndPoints[i];;

      }

      }

      else

      {// BULK : Out-EndPoint

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

      {

      OutEndpt_I2C = (CCyBulkEndPoint *)USBDevice->EndPoints[i];;

      }

      }

      }

      }

      }

      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.