AnsweredAssumed Answered

I2C3 On Imx6sl

Question asked by sandeep sharma on Feb 14, 2017
Latest reply on Feb 15, 2017 by sandeep sharma

Hi Experts,

 

We have an sensor connected to I2c3 of the IMx6sl board. I have to use i2c3 in master mode and sensor in Slave mode.I have made the necessary changes to dtb file and i can see device being probed.

 

root@imx6slzbha:~/system_init# cat /sys/class/i2c-dev/i2c-0/name
21a8000.i2c
mailto:root@imx6slzbha:~/system_init#

 

My Test Code:-

 

#define SLAVE_ADDR 0xD6 
#define I2C_DEVICE "/dev/i2c-0" 

 

int main(int argc,char **argv) {

int dev;
unsigned char res,res2;
int temperature ;
if ((dev = open(I2C_DEVICE, O_RDWR)) < 0){
perror("open failed");
exit(1);
}

if (ioctl(dev, I2C_SLAVE, SLAVE_ADDR) < 0){
perror("ioctl failed");
close(dev);
exit(1);
}
res = i2c_smbus_read_byte_data(dev, WHO_AM_I_M);
printf("Result= %d\n\r\n\r", res);
close(dev);
exit(0);;
}

 

I am getting error :- ioctl failed: Invalid argument

 

Can someone please guide me where I am wrong .

 

Regards

Sandeep S

Outcomes