have two i2c interfaces. clarification needed regarding with dependency of API to both interfaces.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
AMRA_4710126
Level 1
Level 1
CyU3PReturnStatus_t
SensorWrite (
        uint8_t slaveAddr,
        uint8_t highAddr,
        uint8_t lowAddr,
        uint8_t count,
        uint8_t *buf)
{
    CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
    CyU3PI2cPreamble_t preamble;    /* Validate the I2C slave address. */
    if ((slaveAddr != SENSOR_ADDR_WR) && (slaveAddr != I2C_MEMORY_ADDR_WR))
    {
        CyU3PDebugPrint (4, "I2C Slave address is not valid!\n");
        return 1;
    }    if (count > 64)
    {
        CyU3PDebugPrint (4, "ERROR: SensorWrite count > 64\n");
        return 1;
    }    /* Set up the I2C control parameters and invoke the write API. */
    preamble.buffer[0] = slaveAddr;
    preamble.buffer[1] = highAddr;
    //preamble.buffer[2] = lowAddr;
    preamble.length    = 2;
    preamble.ctrlMask  = 0x0000;    apiRetStatus = CyU3PI2cTransmitBytes (&preamble, buf, count, 0);
    SensorI2CAccessDelay (apiRetStatus);    return apiRetStatus;
}

CyU3PReturnStatus_t
SensorRead (
        uint8_t slaveAddr,
        uint8_t highAddr,
        uint8_t lowAddr,
        uint8_t count,
        uint8_t *buf)
{
    CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
    CyU3PI2cPreamble_t preamble;    /* Validate the parameters. */
    if ((slaveAddr != SENSOR_ADDR_RD) && (slaveAddr != I2C_MEMORY_ADDR_RD))
    {
        CyU3PDebugPrint (4, "I2C Slave address is not valid!\n");
        return 1;
    }
    if ( count > 64 )
    {
        CyU3PDebugPrint (4, "ERROR: SensorWrite count > 64\n");
        return 1;
    }    preamble.buffer[0] = slaveAddr & I2C_SLAVEADDR_MASK;        /*  Mask out the transfer type bit. */
    preamble.buffer[1] = highAddr;
    //preamble.buffer[2] = lowAddr;
    preamble.buffer[2] = slaveAddr;
    preamble.length    = 3;
    preamble.ctrlMask  = 0x0002;                                /*  Send start bit after third byte of preamble. */    apiRetStatus = CyU3PI2cReceiveBytes (&preamble, buf, count, 0);
    SensorI2CAccessDelay (apiRetStatus);    return apiRetStatus;
}

These are the read and write functions of i2c interface in fx3 (CYUSB3014) for camera sensor setting .
we need to use a LED driver (LP8556), that should be pre-configured the eprom memory via i2c interface. if suppose we need to make any modification in API for led driver it should not affect the camera. How can i do that? i am bit more confusing about that? can anyone guide me to reach out?
thanks in advance.
0 Likes
1 Solution
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi,

In each of the functions above, based on slave address you can use CyU3PI2cTransmitBytes/ CyU3PI2cReceiveBytes separately.

i.e, for ex: SensorWrite() can be as follows

CyU3PReturnStatus_t

SensorWrite (

        uint8_t slaveAddr,

        uint8_t highAddr,

        uint8_t lowAddr,

        uint8_t count,

        uint8_t *buf)

{

...

...

     if(slaveAddr == SENSOR_ADDR_WR)

     {

     ..

     }

     else if(slaveAddr == I2C_MEMORY_ADDR_WR)

     {

     ..

     }

...

...

}

Regards,

Hemanth

Hemanth

View solution in original post

0 Likes
1 Reply
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi,

In each of the functions above, based on slave address you can use CyU3PI2cTransmitBytes/ CyU3PI2cReceiveBytes separately.

i.e, for ex: SensorWrite() can be as follows

CyU3PReturnStatus_t

SensorWrite (

        uint8_t slaveAddr,

        uint8_t highAddr,

        uint8_t lowAddr,

        uint8_t count,

        uint8_t *buf)

{

...

...

     if(slaveAddr == SENSOR_ADDR_WR)

     {

     ..

     }

     else if(slaveAddr == I2C_MEMORY_ADDR_WR)

     {

     ..

     }

...

...

}

Regards,

Hemanth

Hemanth
0 Likes