I tried to enable I2C device, and failed to read WHO_AM_I reg with wiringPi interface, which return -1 instead of device ID.
---------------------code piece------------------
if(-1 == wiringPiSetup () ) {
printf(“wiringPi setup error\n”);
return -1 ;
}
fd = wiringPiI2CSetup (SlaveAddress);
if(fd < 0) {
printf("wiringPii2csetup slaveaddress1 error\n");
return -1 ;
}
res = wiringPiI2CReadReg8(fd, WHO_AM_I);
printf("whoami:%d\n", res);
And I can use i2cdect to probe my device address, and i2cget(WHO_AM_I) also return right device ID.
can anyone help me here?
Thanks,
Tiger