I am having some trouble communicating with a chip over I2C and I'm wondering if I'm doing something wrong when setting up the FT4222 chip.
Some overview of my circuit, I have the FT4222 chip connected to my computer over USB, and I want to use it to communicate to other chips on circuit over I
2C. The first chip to communicate with is a PCA9570, a four pin GPIO chip, that controls two LEDs and two reset pins for other chips on the board. Initially, the PCA9570 is high on all four outputs, so my first job is to tell the PCA9570 to set those outputs low.
I'm building the software on Mac OS X 10.13.4, with g++:
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Here's an overview of the software:
I find any available chips...
FT_CreateDeviceInfoList(&numOfDevices)
... connect to the first one...
FT_OpenEx(locationId, FT_OPEN_BY_LOCATION, &ftHandle);
... Initialize I2C...
FT4222_I2CMaster_Init(ftHandle, 400);
... and reset I2C.
FT4222_I2CMaster_Reset(ftHandle);
All of these succeed with
FT_OK return codes. A call to
FT4222_I2CMaster_GetStatus returns 0x20 (controller idle).
The PCA9570's data sheet (
https://www.nxp.com/docs/en/data-sheet/PCA9570.pdf) specifies running these commands. First, I send the general I2C reset (sending 0x06 to 0x00):
uint8 buffer = 0x06;
uint16 sizeTransferred;
FT4222_STATUS status = FT4222_I2CMaster_Write(ftHandle, 0x00, &buffer, 1, &sizeTransferred);
This succeeds and another call to
FT4222_I2CMaster_GetStatus still returns 0x20 (controller idle).
Now, I send the command to pull all pins low on the GPIO chip:
uint8 pins = 0x00;
uint16 sizeTransferred;
FT4222_STATUS status = FT4222_I2CMaster_Write(ftHandle, GPIO_CHIP_ADDR, &pins, 1, &sizeTransferred);
The status for this is still
FT_OK, but the LEDs are still on. Also, the next call to
FT4222_I2CMaster_GetStatus returns 0x3e.
So, how can I best debug why my I2C commands are not going through?