FTDI chip matlab programming: how to pass the pointer value

3 Ansichten (letzte 30 Tage)
wei
wei am 17 Apr. 2014
Bearbeitet: wei am 17 Apr. 2014
Hi all,
I try to use an FTDI chip to communicate with an I2C slave device. I have already succeed in loading the libMPSSE.dll libraries by changing the header file of libMPSSE_i2c.h which I learn from this forum. But I still have problem to pass the void handle pointer to I2C_OpenChannel function to get the channel handle number. The function should give back the acquired channel handle to the pointer, but my code cannot show that change. My code is as below:
In ftd2xx.h ( which is included in libMPSSE_i2c.h)
typedef unsigned long PVOID;
typedef PVOID FT_HANDLE;
Function definition in libMPSSE.dll:
FTDI_API FT_STATUS I2C_OpenChannel(uint32 index, FT_HANDLE *handle);
After the function, the Ft_handle should be updated and contain the channel handle num. This ft_handle will be used next for other channel operations
Function interpretation in Matlab libfunctionsview:
[ulong, ulongPtr]=I2C_OpenChannel(ulong,ulongPtr);
My Matlab application code:
myhandle=uint32(0);
myhandle_ptr=libpointer('ulongPtr',myhandle);
[status,myhandle_ptr]=calllib('libMPSSE','I2C_OpenChannel',uint32(1),myhandle_ptr)
Both myhandle and myhandle_ptr still keep the initial value of 0 without update from OpenChannel function call. How could I find a way to pass a pointer to the function, let the function change the pointer's reference and get the real channel handle number?
I am still not very familiar with the pointer argument pass in Matlab. Awaiting for any input. Thank you in advance.

Antworten (0)

Kategorien

Mehr zu Instrument Control Toolbox Supported Hardware finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by