I2cregmode/i2cdmamode are the simplest examples available. I think you just need to familiarize yourself with Fx3 firmware flow.
In the i2cregmode, there is a CyFxUsbI2cTransfer() function defined that performs the i2c read/write operations using the CyU3PI2cReceiveBytes() and CyU3PI2cTransmitBytes() API calls.
And this functions is called inside the CyFxUSBSetupCB() function which is a callback function for USB EP0 commands.
There are vendor requests defined for i2c read (CY_FX_RQT_I2C_EEPROM_READ) and write (CY_FX_RQT_I2C_EEPROM_WRITE). These vendor commands are recevied from the PC.
You can call the CyFxUsbI2cTransfer() function from anywhere in the code based on your requirement.
You can use the existing thread itself for your i2c read/write calls.
Thank you for the answer!
Can you tell me how now I should write data from the PC? So that they are properly interpreted by FX3?
CY_FX_RQT_I2C_EEPROM_READ and CY_FX_RQT_I2C_EEPROM_WRITE are vendor commands sent out on EP0 from host to device.
The Fx3 already has code to interpret them and take appropriate action (read/write to i2c). You can send these Ep0 requests from the Control Center application.
Are there any examples on how to send CY_FX_RQT_I2C_EEPROM_READ and CY_FX_RQT_I2C_EEPROM_WRITE from Linux?
Is there a device driver which will do this, or is there a user space program on top of libusb which can do this?
I appears that this can be done using libusb_control_transfer.
However, in my case it will timeout when the FX3 calls CyU3PUsbSendEP0Data (I'm using CY_FX_RQT_ID_CHECK to read the glFirmwareID).
Did anybody get this working on Windows?
I don't have a windows system, but I also get the same result with the pre-built firmware downloaded from:
The result using the Cypress GUI is the same as in the image above. I would have expected to read the firmware id, which I observe on the FX3 serial port:
=3A: Device initialized. Firmware ID: 20 33 58 46 0 43 32 49
=3B: Device initialized. Firmware ID: 20 33 58 46 0 43 32 49
Did anybody get this to work on any platform?
CyU3PUsbSendEP0Data will simply hang. Using CY_FX_RQT_I2C_EEPROM_READ CyFxUsbI2cTransfer will return CY_U3P_SUCCESS, but the following CyU3PUsbSendEP0Data will timeout.
Are there any chipsets which will not work with the FX3? I have tried both VIA and Intel and I get no data.
Please try by setting the bmRequest type to 0xC0 instead of 0x40 (SETUPDATA0 field in the above image)