FTDI Community

General Category => Discussion - Software => Topic started by: allenhuffman on April 27, 2023, 10:43:46 PM

Title: FT4222_I2CMaster_ReadEx() to send a STOP without reading data?
Post by: allenhuffman on April 27, 2023, 10:43:46 PM
Since the bug in the FTDI I2C chip presents using FT4222_I2CMaster_GetStatus() after a write (unless you can wait long enough to know the write has completed), I came up with a workaround.

We blindly write our our message (without knowing if anything saw it and ACK'd it), then we go to read our special protocol.

We read the first two bytes (a start code, and number of data bytes) like this:

Code: [Select]
// Read two bytes (Start Code, Number of Data Bytes).
ft4222Status = FT4222_I2CMaster_ReadEx (ftHandle, deviceAddress, START, buffer, 2, &sizeTransferred);

Initially, I thought we might be able to use GetStatus() hear and see if the READ was ACK'd, but it will return a BUS_BUSY due to the ReadEx being in the middle (no STOP bit yet). At least that's what it looks like -- always BUS_BUSY until I do the second ReadEx.

I do a check like this:

Code: [Select]
// Fake it. Reads from non-responding devices will return FFs.
if ((buffer[0] == 0xff) && (buffer[1] == 0xff))
{
    // Nothing responded, or other issue.
}

...BUT, this means I never got to the second half of the ReadEx that completes it, with the STOP:

Code: [Select]
ft4222Status = FT4222_I2CMaster_ReadEx (ftHandle, deviceAddress, STOP, &buffer[2], messageSize-2, &sizeTransferred);
/code]

How can I just send the "STOP"? I tried this (ReadEx with 0 bytes) and that doesn't do it:

[code]// Fake it. Reads from non-responding devices will return FFs.
if ((buffer[0] == 0xff) && (buffer[1] == 0xff))
{
    // Nothing responded, or other issue.
    FT4222_I2CMaster_ReadEx (ftHandle, deviceAddress, STOP, buffer, 0, &sizeTransferred);
}

Looking at the I2C line in my Saleae analyzer, I see no STOP bit, though the next write/read is still able to happen.

How can I send a STOP without reading data? Is that possible?
Title: Re: FT4222_I2CMaster_ReadEx() to send a STOP without reading data?
Post by: FTDI Community on May 03, 2023, 09:05:56 AM
Hello,

Sorry, FT4222H does not support sending a STOP without reading data.

Best Regards

FTDI Community