FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Show Posts

You can view here all posts made by this member. Note that you can only see posts made in areas to which you currently have access.

Topics - DRN

Pages: [1]
1
Hi - I received LibMPSSE 1.0.4 from US customer support, thanks Cameron!
After fixing some problems in LibMPSSE (see details below), the library no longer goes into an infinite loop.
Now works OK for both 32-bit and 64-bit builds.
The AdaFruit FT232H board https://www.adafruit.com/product/2264 has a tiny switch which must be ON to enable I2C; I missed this and wasted some time...
It would be great if FTDI would fix the problems in the library detailed below.
All my fixes are marked with my initials DRN in the source.
Thanks,
Best Regards, Dave

As forum attachment limit is tiny:
the complete test project (with LibMPSSE corrections) is here
See also http://www.ftdicommunity.com/index.php?topic=894.msg2591#new

Details
Note:
- the device and cable work fine with an MCP2221 (Microchip USB-to-I2C/Qwiic adapter).
- testing uses AdaFruit FT232H Breakout above and SparkFun Micro Magnetometer - MMC5983MA (Qwiic) SEN-19921

BUG: FTDI code goes into infinite-loop until (1) below is corrected.

Note: I set channelConf as follows:
    channelConf.ClockRate = I2C_CLOCK_STANDARD_MODE;
    channelConf.LatencyTimer = 100;
    channelConf.Options = 0
        | I2C_DISABLE_3PHASE_CLOCKING
        | I2C_ENABLE_DRIVE_ONLY_ZERO /* pull-up resistors are on SEN-19921 sensor Qwiic board. */
        ;
    channelConf.Pin = channelConf.currentPinState = 0;
I also tried different Options flag values; always same result.


====================  FTDI code problems  ====================

1) Version 1.0.4 ftdi_mid.h line 87 comments out FT_InitChannel without explanation:
//FT_STATUS FT_InitChannel(FT_LegacyProtocol Protocol, FT_HANDLE handle,...);
Lack of declaration causes a compile warning in ftdi_i2c.c and apparently runtime infinite-loop error:
ftdi_i2c.c(393,11): warning C4013: 'FT_InitChannel' undefined; assuming extern returning int
The routine is still provided and global in ftdi_mid.c but with a DIFFERENT function signature.
Adding current/correct declaration in ftdi_mid.h corrects infinite-loop bug.

2) Doesn't compile with C++:
2a) ftdi_infra.h line 192 doesn't compile with C++ because there's a typedef of bool:
    typedef BOOL   bool;
2b) all headers are missing extern "C" for C++

3) test.c sets channelConf.Options = 100; without explanation.
100 is an illegal value according to the recently-added header documentation

4) New channelConf fields channelConf.pin and channelConf.currentPinState:
4a) test.c does not initialize these
4b) there is no documentation about how these should be set for I2C

5) Building 64-bit version shows improper conversion between pointers and unsigned int:
QwiicFT.cpp(49,41): warning C4311: 'type cast': pointer truncation from 'FT_HANDLE' to 'unsigned int'
QwiicFT.cpp(49,41): warning C4302: 'type cast': truncation from 'FT_HANDLE' to 'unsigned int'
QwiicFT.cpp(134,64): warning C4311: 'type cast': pointer truncation from 'FT_HANDLE' to 'unsigned int'
QwiicFT.cpp(134,64): warning C4302: 'type cast': truncation from 'FT_HANDLE' to 'unsigned int'

6) Current 1.0.4 version is not on web site.
Web site still has versions for Windows 2000 and XP!


====================  Program Output  ====================

Hello World!
ftd2xx.dll loaded OK!
Found at least one channel on FT232H
Information on channel number 0:
                Flags=0x2
                Type=0x8
                ID=0x4036014
                LocId=0x23
                SerialNumber=FTP6SN3W
                Description=FT232H
                ftHandle=0x0 (0 unless channel is open)

Version Check
libmpsse: 00010001
libftd2xx: 00030216

handle=0xdc83a0 status=0
MMC5983MA_IO_WindowsQwiic_C::init opened and initialized channel AOK
set_reg 0a Control register 1 <= 80
Wait >10mSec after reset
get_reg 2f Product ID => 30
set_reg 0a Control register 1 <= 00
set_reg 09 Control register 0 <= 10
set_reg 09 Control register 0 <= 01
get_reg 08 Device status => 11
get_reg 00 Xout [17:10] => 80
get_reg 01 Xout [9:2] => bc
get_reg 02 Yout [17:10] => 7a
get_reg 03 Yout [9:2] => 48
get_reg 04 Zout [17:10] => 77
get_reg 05 Zout [9:2] => 33
get_reg 06 Xout[1:0],Yout[1:0],Zout[1:0] => 94
set_reg 09 Control register 0 <= 08
set_reg 09 Control register 0 <= 01
get_reg 08 Device status => 11
get_reg 00 Xout [17:10] => 80
get_reg 01 Xout [9:2] => b9
get_reg 02 Yout [17:10] => 83
get_reg 03 Yout [9:2] => 0f
get_reg 04 Zout [17:10] => 88
get_reg 05 Zout [9:2] => de
get_reg 06 Xout[1:0],Yout[1:0],Zout[1:0] => 44
Compass:   0.08
set_reg 09 Control register 0 <= 10
set_reg 09 Control register 0 <= 01
get_reg 08 Device status => 11
get_reg 00 Xout [17:10] => 84
get_reg 01 Xout [9:2] => 22
get_reg 02 Yout [17:10] => 7f
get_reg 03 Yout [9:2] => 21
get_reg 04 Zout [17:10] => 77
get_reg 05 Zout [9:2] => 31
get_reg 06 Xout[1:0],Yout[1:0],Zout[1:0] => 90
set_reg 09 Control register 0 <= 08
set_reg 09 Control register 0 <= 01
get_reg 08 Device status => 11
get_reg 00 Xout [17:10] => 7d
get_reg 01 Xout [9:2] => 47
get_reg 02 Yout [17:10] => 7e
get_reg 03 Yout [9:2] => 77
get_reg 04 Zout [17:10] => 88
get_reg 05 Zout [9:2] => e8
get_reg 06 Xout[1:0],Yout[1:0],Zout[1:0] => 5c
Compass:  95.53
set_reg 09 Control register 0 <= 10
set_reg 09 Control register 0 <= 01
get_reg 08 Device status => 11
get_reg 00 Xout [17:10] => 80
get_reg 01 Xout [9:2] => 01
get_reg 02 Yout [17:10] => 82
get_reg 03 Yout [9:2] => b3
get_reg 04 Zout [17:10] => 77
get_reg 05 Zout [9:2] => 6a
get_reg 06 Xout[1:0],Yout[1:0],Zout[1:0] => e0
set_reg 09 Control register 0 <= 08
set_reg 09 Control register 0 <= 01
get_reg 08 Device status => 11
get_reg 00 Xout [17:10] => 81
get_reg 01 Xout [9:2] => 92
get_reg 02 Yout [17:10] => 7b
get_reg 03 Yout [9:2] => 3c
get_reg 04 Zout [17:10] => 88
get_reg 05 Zout [9:2] => c4
get_reg 06 Xout[1:0],Yout[1:0],Zout[1:0] => 8c
Compass: 191.83
set_reg 09 Control register 0 <= 10
set_reg 09 Control register 0 <= 01
get_reg 08 Device status => 11
get_reg 00 Xout [17:10] => 7d
get_reg 01 Xout [9:2] => 14
get_reg 02 Yout [17:10] => 7e
get_reg 03 Yout [9:2] => b4
get_reg 04 Zout [17:10] => 77
get_reg 05 Zout [9:2] => 1c
get_reg 06 Xout[1:0],Yout[1:0],Zout[1:0] => 34
set_reg 09 Control register 0 <= 08
set_reg 09 Control register 0 <= 01
get_reg 08 Device status => 11
get_reg 00 Xout [17:10] => 84
get_reg 01 Xout [9:2] => 65
get_reg 02 Yout [17:10] => 7f
get_reg 03 Yout [9:2] => 29
get_reg 04 Zout [17:10] => 89
get_reg 05 Zout [9:2] => 15
get_reg 06 Xout[1:0],Yout[1:0],Zout[1:0] => 3c
Compass: 273.57

2
I need to use FT232H to control an I2C bus, on Windows 10, in a C++ application.
I'm using the AdaFruit FT232H Breakout (Product ID: 2264) on a Windows 10 PC.
Using the latest FTDI DLL.

I've got a Qwiic sensor board connected to the breakout board's Qwiic connector.
The sensor board and cable work fine with a Microchip MCP2221 USB-I2C adapter so they're AOK.
But I can't access the I2C sensor using the FT232H - library goes into an infinite loop.

I understand I should use the FTDI MPSSE library.
On your forum I found you have released LibMPSSE 1.0.3 to your website:
https://ftdichip.com/software-examples/mpsse-projects/

I downloaded the following and incorporated it into my project:
https://ftdichip.com/wp-content/uploads/2022/07/LibMPSSE_1.0.3.zip

Unfortunately, inside I2C_InitChannel, FTDI's libMPSEE software goes into an infinite loop in FT_InitChannel.
The call stack is attached.

Any idea what is going on???
Is there an updated version of the library with bugfixes?
Thanks in advance for any help,
Best Regards, Dave


PS: Here's the program output:
Hello World!
ftd2xx.dll loaded OK!
Found at least one channel on FT232H
Information on channel number 0:
                Flags=0x2
                Type=0x8
                ID=0x4036014
                LocId=0x22
                SerialNumber=FTP6SN3W
                Description=FT232H
                ftHandle=0x0 (0 unless channel is open)

Version Check
libmpsse: 00010001
libftd2xx: 00030216

handle=0xc586c8 status=0

>>> Goes into infinite loop inside I2C_InitChannel...

PS: With an older version of the library, the channel initialized but I could not access
the I2C device (it always reported FT_DEVICE_NOT_FOUND).

Pages: [1]