LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to interface to Cypress FX2 USB

I tried posting this on the Hardware forum, but not getting a reply ... so, let me try to put this here on the LabVIEW forum and see if someone has the answer to this.
 
I have a custom device built around a Cypress CY17C68013 USB controller.  The Cypress controller uses a 2-step "re-numeration" process to first load its internal firmware followed by its driver.  A device unique VID/PID is programmed internally on a ROM, when the device is first connected it responds with this VID/PID and the custom firmware for the device is loaded into the device from a SYS file.  After that, the hardware automatically issues a USB RESET and changes the VID/PID to the Cypress IDs ... the reset causes the device to be re-detected and the new VID/PID now causes the Cypress driver (EZusb.sys) to be loaded as the Windows driver to access the device (which now has my custom firmware loaded).
 
I have that all working, and have created a Windows C++ application that can open a handle to the Cypress driver, and can read and write data to my device.
 
Now I want to access the device from within LabVIEW.   I have seen lots of posts on this board about this, but haven't seen any information that is helpful.  I have read ALL of the links from all of the posts.   There seems to have been a lot of posts, so this must be something many people have done (although most of the posts just end without a real answer).
 
I tried to use the VISA Driver Wizard ... and this was able to create an INF file, and I could see my device from within MAX.   But, when I send a command to my device, my device does not respond as my firmware does not get loaded into the device in this case through the re-numeration process when I have the VISA driver installed.   As soon as I attach the device the NiViUsbK.sys driver gets loaded as the device driver, without first loading my firmware.
 
Question:  I am wondering if it will be possible to just substitue the NiViUsbK.sys driver for the EZusb.sys driver in my INF files, and have the NI VISA driver loaded in the second phase of the re-numeration process in place of the Cypress EZusb.sys driver?  That seems like the simplest solution, but so far I have not been able to get it to work.   Is that possible?   Has anybody done that?   And... if I do that, will I then still be able to access my device through my C++ programs?   Because, I need both my C++ programs, and LabVIEW to be able to access the device and it would be a real hassle to have to keep un-installing and re-installing the drivers to use one program or the other!
 
 
Question:   It would be much cleaner and simpler if it is possible in LabVIEW to simply open a handle to the Cypress driver as can be done in C++ and then use THAT driver to communicate with my device from within LabVIEW instead of the NI VISA driver, if that is possible?  (I am new to LabVIEW,  and VERY early in the learning curve).
 
 
Thanks for any assistance or advice.
Larry
 
Message 1 of 2
(5,480 Views)
I think you should consider simply writing a wrapper DLL that you can call from LabVIEW. You can write the DLL in C/C++ to provide the basic functions like "Open", "Read", and "Write", and whatever else your device does. The DLL would call the driver in the same way as your current C++ code. In fact, you can then use this same DLL in your C++ code. This way you don't have to mess around with drivers and re-numerations. That, to me, seems to be the simplest solution.

Note that if you write the DLL in C++ you have to take care about possible "name-mangling" that occurs with C++ DLLs that LabVIEW won't understand. In essence you will need to prepend extern "C" to your function prototypes. There are a few KB articles on this, like this one.
0 Kudos
Message 2 of 2
(5,468 Views)