LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FTDI FT4222.DLL calling

I am attempting to use the FTDI FT42222 usb to SPI/I2C/GPIO chip with LabVIEW.

FTDI provides two dll's that talk to the chip. After some trial and error, it appears that one dll uses the C calling convention, the other uses winapi convention. FTd2xx.dll and FT4222.dll are provided by FTDI. FTD2xx.dll are the generic USB open device calls and FT4222.dll are the FT4222 specific support.

With that figured out, I was able to successfully communicate via I2C.

Having that, I now would like to use the remaining GPIO pins, one for input, one for output.

So I started and can initialize the port with no errors returned. But, reading or writing to the pins returns an error.

I think it might be the way I'm calling the following:

LIBFT4222_API FT4222_STATUS FT4222_GPIO_Init(FT_HANDLE ftHandle, GPIO_Dir gpioDir[4]);
LIBFT4222_API FT4222_STATUS FT4222_GPIO_Write(FT_HANDLE ftHandle, GPIO_Port portNum, BOOL bValue);

Their docs show:

xx_STATUS       DWORD
FT_HANDLE    DWORD
GPIO_DIR        enum
GPIO_Port        enum
BOOL                unsigned char

So, I used the following in my library function node:

xx_STATUS        Numeric, Unsigned 32-bit Integer
FT_HANDLE     Numeric, Unsigned 32-bit Integer, Pass:Value
gpioDir[4]           Array, Unsigned 32-bit Integer, Array Data Pointer
                              (Here I pass in a 4 element U32)
portNum            Numeric, Unsigned 32-bit Integer, Pass:Value
bValue                Numeric, Unsigned 8-bit Integer, Pass:Value

I'm thinking since all works well for the I2C communication, that I've gotten the STATUS and HANDLE definitions correct.

Am I right in assuming the bools end up 8 bit integers and enums will end up being unsigned 32-bit?

Do I need to use the old trick using a cluster with the first element the array size to pass the gpioDir array?

0 Kudos
Message 1 of 16
(8,686 Views)

Hey MacDroid,

 

I see that both the GPIO_DIR and GPIO_Port inputs are enums, but you're using diffrernt data types in your Call Library Function Note. Can you explain why you chose an array for GPIO_DIR, but a U32 for the GPIO_Port?

 

 

Ty Prather
Technical Marketing Specialist
National Instruments
0 Kudos
Message 2 of 16
(8,654 Views)

I guess it's not clear from what I posted, but their docs show gpioDir as an array:

 

LibFT4222GPIOINIT.png

 

I have since got it working and each of the 4 elements of the array controls the direction of one of the 4 I/O pins.

 

It turns out to get the GPIO pins to work as GPIO in Mode 0 of the chip, you need to de-assign the default functions of the pins. In Mode 0, pins 0 & 1 are I2C SDA & SCL and pins 2 & 3 are wake and suspend. De-assigning wake and suspend allows GPIO control of pins 2 & 3, while I2C is still functional on pins 0 & 1.

 

Regards,

Mac

 

 

0 Kudos
Message 3 of 16
(8,627 Views)

After going back and reading your question again, I get what you are asking wrong.

 

I guessed that the enum results in a 32 bit, so I guessed the array would be an array of 32 bit values.

 

Does that make sense?

 

Mac

0 Kudos
Message 4 of 16
(8,593 Views)

Hey Mac,

 

That does make sense! I'm glad you were able to get it all figure out!

Ty Prather
Technical Marketing Specialist
National Instruments
0 Kudos
Message 5 of 16
(8,585 Views)

Can you please share the labview code.

I have some difficulties on creating a wrapper.

0 Kudos
Message 6 of 16
(8,334 Views)

Hi all,

I found that many people have a hard time to create any succesful communication with those dll. averyone that ware able to do, are not sharing the code. The example provided by the manufacturer are not complete and not fonctional. It's easy that they were not created by a LABview developer.

 

If anyone has a sucessfull communication, PLEASE share it so we can figure it out what is wrong.

 

Thanks

Benoit

Message 7 of 16
(8,137 Views)

Hey bseguin,

 

This thread has gotten somewhat old. You’ll probably have more success creating a new thread to keep discussing your issue with this dll. Be sure to include what you’ve tried so far and any pertinent information so other users will be more likely to lend a hand. Also, linking to this thread wouldn’t be a bad idea either. Hope you can get some help.

 

Respectfully,

Cason

Cassandra Longley
Senior Technical Support Engineer - FlexRIO, High Speed Serial and VRTS
0 Kudos
Message 8 of 16
(8,106 Views)

in this subject of the communication between a labview interface and an instrument,

i have to make a labview interface to permit the communication with an acquisition card via usb


i try to use the ftdi librarys :


i have to initialise this card

read some data from the card ; like initialisation  from 0x494E49 adress or a mesure from 0x4D4553 adress

 

send CRC....

 

--> i dont no how can i read a data from an exact adress using D2XX functions.


some one have idea in this subject or an exemple that can help me?

0 Kudos
Message 9 of 16
(7,948 Views)

and like to know if it s possible to make my la bview interface by:* instaling the ftdi driver at first

                                                                                                                      * doing the labview interface based on D2XX functions

                                       without any ni-Visa ?????

0 Kudos
Message 10 of 16
(7,944 Views)