- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In the CX3 Denebola Eval board, how to work with registers in I2C instead of using API? For scanning the I2C bus, we need to iterate from 0x00 to 0x7F to understand how much the slave device is connected. Is it possible we can try simple code?
1. CyU3PI2cWaitForAck(API -waits for an ACK handshake from the slave) receiving CY_U3P_SUCCESS status for NAK devices too. my code will be :
CyU3PReturnStatus_t MyI2C_SensorWrite(uint8_t slaveAddress, uint16_t count, uint8_t *buf)
{
CyU3PReturnStatus_t status = CY_U3P_SUCCESS;
CyU3PI2cPreamble_t preamble;
preamble.buffer[0] = slaveAddress;
preamble.length = 1;
preamble.ctrlMask = 0x0000;
status = CyU3PI2cTransmitBytes (&preamble, buf , count ,0);
CyU3PThreadSleep(1);
if (status == CY_U3P_SUCCESS)
{
CyU3PDebugPrint(4,"\r\n buff=0x%x");
// break;
}
status = CyU3PI2cWaitForAck(&preamble, 200); //waiting for slaveAddress ack
if (status == CY_U3P_SUCCESS)
{
CyU3PDebugPrint(4,"\r\n ack");
}
return status;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Please refer to the firmware generated by the CX3 Configuration tool to understand the read/write to sensor registers.
Please refer to this KBA Steps to Setup up MIPI CSI Camera Solution with CX... - Infineon Developer Community . Please refer to the below reference code snippet
CyU3PReturnStatus_t I2C_SensorWrite(uint16_t regAddr, uint16_t count, uint8_t *buf)
{
CyU3PReturnStatus_t status = CY_U3P_SUCCESS;
CyU3PI2cPreamble_t preamble;
uint8_t cnt=0;
for(cnt=0; cnt<3 ; cnt++)
{
preamble.buffer[1] = CY_U3P_GET_MSB (regAddr);
preamble.buffer[2] = CY_U3P_GET_LSB (regAddr);
preamble.buffer[0] = SENSOR_I2C_WRITE_ADDRESS; /* Slave address: write operation */
preamble.length = 3;
preamble.ctrlMask = 0x0000;
status = CyU3PI2cTransmitBytes (&preamble, buf, count,0);
CyU3PThreadSleep(1);
if (status == CY_U3P_SUCCESS)
{
break;
}
else
CyU3PDebugPrint(4,"\r\nImageSensorSensorWrite Failed addr=0x%x",regAddr);
}
return status;
}
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Please refer to the firmware generated by the CX3 Configuration tool to understand the read/write to sensor registers.
Please refer to this KBA Steps to Setup up MIPI CSI Camera Solution with CX... - Infineon Developer Community . Please refer to the below reference code snippet
CyU3PReturnStatus_t I2C_SensorWrite(uint16_t regAddr, uint16_t count, uint8_t *buf)
{
CyU3PReturnStatus_t status = CY_U3P_SUCCESS;
CyU3PI2cPreamble_t preamble;
uint8_t cnt=0;
for(cnt=0; cnt<3 ; cnt++)
{
preamble.buffer[1] = CY_U3P_GET_MSB (regAddr);
preamble.buffer[2] = CY_U3P_GET_LSB (regAddr);
preamble.buffer[0] = SENSOR_I2C_WRITE_ADDRESS; /* Slave address: write operation */
preamble.length = 3;
preamble.ctrlMask = 0x0000;
status = CyU3PI2cTransmitBytes (&preamble, buf, count,0);
CyU3PThreadSleep(1);
if (status == CY_U3P_SUCCESS)
{
break;
}
else
CyU3PDebugPrint(4,"\r\nImageSensorSensorWrite Failed addr=0x%x",regAddr);
}
return status;
}
Rashi