- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi
CyU3PI2cPreamble_t works well if the i2c address is only 2-4 bytes width. but if the register address width is longer than 8 bytes, it is hard to use this structure.
who know how configure CyU3PI2cPreamble_t if the register length longer then 8 bytes.
for example, if i want to read register address 0x123456789acbde1234, the value with is 10byes, how to configure?
i tried to separate write/read sequence using following two functions. but cannot work seems due to clock-stretching. who can help here?
CyU3PReturnStatus_t
GW5200_SensorReadNB(uint8_t SlaveAddr, uint8_t *buf, int n)
{
CyU3PReturnStatus_t apiRetStatus=CY_U3P_SUCCESS;
CyU3PI2cPreamble_t preamble;
int i = 0;
preamble.buffer[0] = SlaveAddr;//0x21;
preamble.length = 1;
preamble.ctrlMask = 0x0000;//After the second byte,need to restart the I2C communication
apiRetStatus = CyU3PI2cReceiveBytes (&preamble, buf, n,0);
if (apiRetStatus == CY_U3P_SUCCESS)
{
IMX390_GW_delay(800);
}
else
CyU3PDebugPrint (4, "GW5200_SensorReadNB failed Error Code = %d\n",apiRetStatus);
#if 1
CyU3PDebugPrint (4, "read:");
for(i = 0; i < n; i++)
{
CyU3PDebugPrint (4, "0x%x ", buf);
}
CyU3PDebugPrint (4, "\r\n");
#endif
return apiRetStatus;
}
CyU3PReturnStatus_t
GW5200_SensorWriteNB(uint8_t SlaveAddr,uint16_t count, uint8_t *buf)
{
CyU3PReturnStatus_t apiRetStatus=CY_U3P_SUCCESS;
CyU3PI2cPreamble_t preamble;
int i = 0;
preamble.buffer[0] = SlaveAddr; /* Slave address: Write operation */
preamble.length = 1;
preamble.ctrlMask = 0x0000;
apiRetStatus = CyU3PI2cTransmitBytes (&preamble, buf, count, 0);
if (apiRetStatus == CY_U3P_SUCCESS)
{
IMX390_GW_delay(800); /* known issue for SDK I2C */
}
else
{
CyU3PDebugPrint (4, "GW5200_SensorWriteNB error!\r\n");
}
#if 0
CyU3PDebugPrint (4, "write:");
for(i = 0; i < count; i++)
{
CyU3PDebugPrint (4, "0x%x ", buf);
}
CyU3PDebugPrint (4, "\r\n");
#endif
return apiRetStatus;
}
thanks
xingxing
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Edited:
Xingxing,
Unfortunately, FX3 cannot write/read to your i2c slave, since it has 11-byte address even the i2c slave supports clock stretching.
The I2C block on FX3 can handle upto the preamble of 64 bits (8 bytes). This preamble includes the slave address, R/W command, possible internal address and repeated start command. Preamble Values more than 8 bytes are not supported.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The I2C block on FX3 can handle upto the preamble of 64 bits (8 bytes). This preamble includes the slave address, R/W command, possible internal address and repeated start command. Preamble Values more than 8 bytes are not supported.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks your reply.
the i2c slave deivce support clock-stretching, is there any special setting for fx3 to support clock-stretching device?
thanks
xingxing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
if i want this process, how to configure preamble ?
START-0xDA-0x33-0x05-0x00-0x00-0x00-0xa1-0x00-0x80-0x01-0x01-0xa2-STOP-START-0xDB-(read)0x33-0x41-0x02.....0x78-STOP
thanks
xingxing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Edited:
Xingxing,
Unfortunately, FX3 cannot write/read to your i2c slave, since it has 11-byte address even the i2c slave supports clock stretching.
The I2C block on FX3 can handle upto the preamble of 64 bits (8 bytes). This preamble includes the slave address, R/W command, possible internal address and repeated start command. Preamble Values more than 8 bytes are not supported.