AnsweredAssumed Answered

Is there an example program for i2c write?

Question asked by OH SEOHWAN on Oct 18, 2017
Latest reply on Oct 19, 2017 by igorpadykov

I need to setup the i2c by connecting the camera to the parallel port.
I need to set the camera through i2c writing, but i want to know how to set i2c in i.mx6 saber borad.

 

example code

 

int main(int argc, char *argv[])
{
    int i, j, dev;
    char buf[8];
    if ((dev = open("/dev/i2c-0", O_RDWR)) < 0) {
        perror("open failed");
        exit(1);
    }

    if (ioctl(dev, I2C_SLAVE, SLAVE_ADDR) < 0) {
        perror("ioctl failed");
        close(dev);
        exit(1);
    }

//---------------------

i2c write

write(dev,buf,1) ????????

//---------------------


}

Outcomes