LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CY3240-I2CUSB

Solved!
Go to solution

Hi All,

do someone ever tried to use the Cypress CY3240 USB-to-I2C bridge in a Labwindows program?

I am lookong for C drivers but I cannot find any.

Thanks for the attention and regards

 

Francesco

 

 

0 Kudos
Message 1 of 12
(6,942 Views)

Google gave the following result: http://www.cypress.com/?rID=3421

 

On this site, you can find a file called examples.zip, which provides examples in C

0 Kudos
Message 2 of 12
(6,941 Views)
Solution
Accepted by fradep

Thanks a lot!!!

I tried by myself but I could not find it...

Regards

 

Francesco

 

0 Kudos
Message 3 of 12
(6,933 Views)

Wolfgang,

the result from google is actually a project for PSoC Designer. I don't think it is meant for C compilers like CVI. 

I was looking for something different: is there anyone who has used this device as an USB-I2C bridge into a LabWindows program?

Thank you very much

 

Francesco

 

 

0 Kudos
Message 4 of 12
(6,898 Views)

Hi Francesco,

 

You are right, I didn't explore the C source code too seriously. But one option certainly is to directly contact the company itself.

0 Kudos
Message 5 of 12
(6,895 Views)

Hi All,

 

I have been unsing successfully the Cypress CY3240 USB2IIC in a LabWindows/CVI environment. It was not simple ate the beginning but found a way to do so. In fact there is no driver but an ActiveX prog. that deals with I/O communication to the USB bridge. You need to activate/register the ActiveX (embbeded in to a .exe file delivered with the C++/# examples that you could donwload from Cypress website)

 

Once you register the activeX, you'll be able to create into LabWindows/CVI and ActiveX controller and then communicate with the bridge.

there is some Variant to ... translation to do but it's quite easy.

 

Best reagrds and good luck.

0 Kudos
Message 6 of 12
(6,751 Views)

Hi Tintin75,

what about sharing some example code 🙂 ???

thanks

 

Francesco

 

0 Kudos
Message 7 of 12
(6,743 Views)

Hello,

 

Here are more details informations that i hop would help you.

 

The software examples in visual C++, C# could be found there ( Application Note 27079 😞

 

http://www.cypress.com/?id=1031&rtID=5&rID=47

 

Download the examples files and use the USB2IIC.exe to create and register the ActiveX under windows (works ok with Windows7): USB2IIC.exe /regsrv.

 

Once you have done that the ActiveX server is load in the computer memory and could be found by the the LabWindows/CVI ActiveX controller wizard.

An instrument is created and you could therefor use the function generated to connect transparently to the I2C bridge.

 

I have written a LabWindows/CVI program that copy the one provided in the AN27079. I could send it if necessary (by email, or any other mean: i'm new to this forum and i don't know how we could upload source files), but the main points are summarized below.

 

In the main function, call the ActiveX server/object created by the LabWindows/CVI controller wizard:

 

 //Connect to ActiveX server
 status=USB2IIC_NewIUSB2IICcom_Exe (NULL, 1, LOCALE_NEUTRAL, 0, &USB2IIC_hdl);
 
 if(status==0){//If the handle is valid, Initialized the USB to ICC Bridge communications
  status=USB2IIC_IUSB2IICcom_ExeInitUSB2IIC (USB2IIC_hdl, NULL, 0);
 

  //Retreive here the list of connected bridge to the activeX controller 
  status=USB2IIC_IUSB2IICcom_ExeGetBridgeList(USB2IIC_hdl,NULL,&CA_Bridge_List);
  
  if(status==0){
   CA_VariantGet1DArrayBuf (&CA_Bridge_List, CA_VariantGetType(&CA_Bridge_List), &Bridge_List, 10, &nbdev);
   if(nbdev==0){

     //Bridge Unconnected: affect Callback functions
    

   }
   else{

    //Bridge already connected: do not affect Callback functions
      }

 

I had written some "packaged" function, to avoid dealing with the CA_Variant each time. here are the example to send a retreived data on the I2C bus using the CY3240 USB2IIC bridge. Note that those function are compatible with registered I2C devices (like controlers, digital potentiometers, ADC, etc...), they should be rewritten for I2C memories, in which the intrenal organization differs from the previous ones.

 

/******************************************************************************
/*Senddata: Send Value to Register offset                  *
/******************************************************************************/
// caServerObjHandle is the ActiveX object handle,

// BridgeID is the identifier of the USB2IIC bridge connected (several bridge could be connected)

// devAdd is the I2C device address

// regAdd is an array of 1 BYTE that contains the register address

// data is an BYTE containing the data to write in the the register regAdd.

 

int Senddata(CAObjHandle caServerObjHandle, char *BridgeID, int devAdd, BYTE *regAdd, BYTE data)
{
VARIANT CA_rdData,CA_wrData;  
BYTE rData;
BYTE *readData,writeData[1023];

 

//Compute CA_wrData Array
writeData[0]=*regAdd; //register address
writeData[1]=data;  //Value to write
CA_VariantSet1DArray (&CA_wrData, CAVT_UCHAR, 2, writeData);//Variant array
     
//Send CA_wrData Variant to Device address
USB2IIC_IUSB2IICcom_ExeSendIICdata(caServerObjHandle,NULL,BridgeID,devAdd,CA_wrData,NULL);
     
Delay(.1); //Wait for data to be writen
     
//Verify writed data
CA_VariantSet1DArray (&CA_wrData, CAVT_UCHAR, 1, regAdd);
//Send Device and Register address first
USB2IIC_IUSB2IICcom_ExeSendIICdata(caServerObjHandle,NULL,BridgeID,devAdd,CA_wrData,NULL);
     
//Read data on Bus
USB2IIC_IUSB2IICcom_ExeReadIICdata (caServerObjHandle, NULL, BridgeID, devAdd,1, &CA_rdData, NULL);
CA_VariantGet1DArray (&CA_rdData, CA_VariantGetType(&CA_rdData), &readData, NULL);
data=*readData;
 
if (data==*readData) //succeed
  return 1;
else //error
  return -1;
}

 

/******************************************************************************
/*Readbyte: Read byte from I2C device           *
/******************************************************************************/
// caServerObjHandle is the ActiveX object handle,

// BridgeID is the identifier of the USB2IIC bridge connected (several bridge could be connected)

// devAdd is the I2C device address

// regAdd is an array of 1 BYTE that contains the register address

 

int Readdata(CAObjHandle caServerObjHandle, char *BridgeID, int devAdd, BYTE *regAdd) 
{
VARIANT CA_rdData,CA_wrData;  
BYTE rData;
BYTE *readData,writeData[1023];

int status;

 

CA_VariantSet1DArray (&CA_wrData, CAVT_UCHAR, 1, regAdd);
//Send Device and Register address first
USB2IIC_IUSB2IICcom_ExeSendIICdata(caServerObjHandle,NULL,BridgeID,devAdd,CA_wrData,NULL);
      
//Read data on Bus
status=USB2IIC_IUSB2IICcom_ExeReadIICdata (caServerObjHandle, NULL, BridgeID, devAdd,1, &CA_rdData, NULL);
if (status==0){ //succeed
  CA_VariantGet1DArray (&CA_rdData, CA_VariantGetType(&CA_rdData), &readData, NULL);
  rData=*readData;
  return rData;
 }
else //error
  return -1;
}

 

Hope that will help you in your design.

 

I'm still having trouble to affect default function if the bridge is not allready connected when the program runs. so If you are able to solve this issue i'll be please to have the solution you'll find or any enhancement you found.

 

Tintin75

0 Kudos
Message 8 of 12
(6,738 Views)

Really good job!!

thanks

 

Francesco

0 Kudos
Message 9 of 12
(6,729 Views)

Hey ! Unfortunately the examples were removed from the server, and I can not find the ActiveX file (i.e. USB2IIC.exe). Is there any way you can share it, if you still have the files ? tnx, ya

0 Kudos
Message 10 of 12
(5,626 Views)