Tx1 linux built-in i2c Tool
1. I2c scan:
The i2cdetect-l command can be used to view the I2C bus on TX1. The returned result shows that TX1 contains seven I2C buses.
Ubuntu @ tegra-ubuntu:/proc/device-tree $ i2cdetect-l
I2c-0 unknown Tegra I2C adapter N/
I2c-1 unknown Tegra I2C adapter N/
I2c-2 unknown Tegra I2C adapter N/
I2c-3 unknown Tegra I2C adapter N/
I2c-4 unknown Tegra I2C adapter N/
I2c-5 unknown Tegra I2C adapter N/
I2c-6 unknown Tegra I2C adapter N/
2. I2C device query if an I2C slave device is mounted on the bus, you can use i2cdetect to scan all devices on an I2C bus. Enter i2cdetect-y 2 on the console. The result is as follows.
Ubuntu @ tegra-ubuntu:/proc/device-tree $ sudo i2cdetect-y 2
0 1 2 3 4 5 6 7 8 9 a B c d e f
00 :--------------------------
10 :--------------------------------
20 :--------------------------------
30 :--------------------------------
40 :--------------------------------
50: 50 -- 57 ----------------
60 :--------------------------------
70 :----------------
Note 1:-y is an optional parameter. If the-y parameter exists, there is a user interaction process, meaning that you want to stop using the I2C bus. If this parameter is written, there is no interaction process. This parameter is generally used in the script. NOTE 2: two devices, PCF8574 and AT24C04, are mounted on the I2C bus. The slave address 0x50 is board configure, And the slave address 0x57 is AT24C04.
3. You can use the i2cdump command to export the register content of an I2C device. For example, if you enter i2cdump-y 2 0x50, you can obtain the following information:
Ubuntu @ tegra-ubuntu:/proc/device-tree $ sudo i2cdump-y 2 0x50
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a B c d e f 0123456789 abcdef
00: 01 00 0d 00 84 08 e8 03 04 4a 00 00 00 00 00 ?.?.????? J ......
10: 00 00 35 02 36 39 2d 38 32 31 38 30 2d 31 30 .. 5? 699-82180-10
20: 30 30 2d 34 31 30 20 4a 2e 30 ff 00-410 J.0 ......
30: ff 35 2d 66 4b 04 00 36 2d 66 4b 04 00 00 00... 5-fK ?. 6-fK ?...
40: 00 00 00 00 37 2d 66 4b 04 00 30 33 32 32 31... 7-fK ?. 032321
50: 36 31 33 30 35 36 35 ff 6130565 .........
60: ff ................
70: ff ................
80: ff ................
90: ff 4e 56 43 42 1c 00 4d 31 00 ...... NVCB ?. M1 ..
A0: 35 2d 66 4b 04 00 36 2d 66 4b 04 00 37 2d 66 4b 5-fK ?. 6-fK ?. 7-fK
B0: 04 00 ff ?...............
C0: ff ................
D0: ff ................
E0: ff ................
F0: ff 96 ...............?
In the i2cdump-y 2 0x50 command,-y indicates canceling the user interaction process and directly executing the command; 2 indicates the I2C bus number; 0x50 indicates the I2C device slave address, select the configuration Chip's 256-byte content.
4. if a byte is written into the I2C device, enter the instruction i2cset-y 2 0x50 0x00 0x13-y to indicate the curve user interaction process, direct execution of command 2 represents the I2C bus number
0x50 represents the I2C device address. Here, select the 256-byte content of AT24C04.
0x00 indicates the memory address
0x13 indicates the specific content in the memory address
5. Read the register content [plain] view plaincopy
- Pi @ raspberrypi :~ $ I2cget-y20x500x00
- 0x13
If a byte is read from the device by I2C, run i2cget-y 2 0x50 0x00 to obtain the following feedback.
-Y represents the curve user interaction process, and direct execution of command 2 represents the I2C bus number
0x50 represents the I2C device address. Here, select the 256-byte content of AT24C04.
0x00 indicates the memory address