04-06-2010 05:29 AM
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
Solved! Go to Solution.
04-06-2010 05:44 AM
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
04-06-2010 07:00 AM
Thanks a lot!!!
I tried by myself but I could not find it...
Regards
Francesco
04-08-2010 08:01 AM
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
04-08-2010 08:06 AM
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.
06-15-2010 04:43 AM
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.
06-15-2010 05:37 AM
Hi Tintin75,
what about sharing some example code 🙂 ???
thanks
Francesco
06-15-2010 06:23 AM
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
06-15-2010 06:55 AM
Really good job!!
thanks
Francesco
10-18-2011 05:45 PM
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