- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
is it possible that I can find somewhere a simple example how to utilize I2C in FX3? I need to write and read some data from external I2C sensor.
I found example in SDK examples UsbI2cDmaMode and UsbI2cRegMode but as far as for now I don't really understand it.
I have the following questions:
1) How from PC do you write data to be later written via I2C?
2) How later I use functions to read and write data via I2C? Do I have to create new thread?
Thank you in advance for any support,
Regards,
Krzysztof
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Krzystof,
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.
-Shashank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
What is Byte adress in CyFxUsbI2cTransfer() parameter
CyFxUsbI2cTransfer (
uint16_t byteAddress,
uint8_t devAddr,
uint16_t byteCount,
uint8_t *buffer,
CyBool_t isRead)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
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?
Regards,
Krzysztof
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
Did you solve the PC code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
-Shashank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I also tried to use the cyusb_linux GUI program to send the CY_FX_RQT_ID_CHECK (0xB0) bRequest to return the glFirmwareID. But this is also failing:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please try by setting the bmRequest type to 0xC0 instead of 0x40 (SETUPDATA0 field in the above image)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did anybody get this working on Windows?
Update:
I don't have a windows system, but I also get the same result with the pre-built firmware downloaded from:
http://www.cypress.com/file/340976/download
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
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.