StevenJC |
08-12-2019 12:10 PM |
Adding I2C devices for embedded 4.9.89 linux
Having trouble talking to new devices. From user space:
Code:
const char *i2cDevice1 = "/dev/i2c-1";
int i2cAddr = 0x59;
int fdI2c1 = open(i2cDevice1, O_RDWR); /* this works */
if (ioctl(fdI2c1, I2C_SLAVE, i2cAddr) < 0) {
printf("I2C Error 2. Bye.\n");
return 0;
} /* this works */
if (write(fdI2c1, buf, 2) != 2) {
printf("I2C Error 3. Bye.\n");
return 0;
} /* this FAILS */
Tried simply tweaking the Device Tree Source (.dts file) in linux-4.9.89/arch/arm/boot/dts by adding max3107 block below:
Code:
&i2c2 {
clock-frequency = <400000>;
max3107@58 {
compatible = "maxim, 3107";
reg = <0x58>;
};
};
and rebuilt kernel and dtb. This did not seem to do anything since I still get the same error from my code and the i2cdetect utility still doesn't see a device 0x59.
Code:
# i2cdetect -y -r 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Suggestions?
|