User Tools

Site Tools


i2c

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
i2c [2018/08/13 13:32] midas_zhoui2c [2025/10/14 06:22] (current) – external edit 127.0.0.1
Line 3: Line 3:
    
 ===1. 用i2cdetect -l 命令来列出所有I2C总线=== ===1. 用i2cdetect -l 命令来列出所有I2C总线===
 +<code bash>
 root@Widora:/# i2cdetect -l root@Widora:/# i2cdetect -l
 i2c-0   i2c          10000900.i2c                 I2C adapt i2c-0   i2c          10000900.i2c                 I2C adapt
 +</code>
  
-用i2cdetect -F 0 来查看I2C 0号总线启用的功能 +===2. 用i2cdetect -F 0 来查看I2C 0号总线启用的功能=== 
 +<code bash>
 root@Widora:/# i2cdetect -F 0 root@Widora:/# i2cdetect -F 0
 Functionalities implemented by /dev/i2c-0: Functionalities implemented by /dev/i2c-0:
Line 26: Line 27:
 I2C Block Write                  yes I2C Block Write                  yes
 I2C Block Read                   yes I2C Block Read                   yes
 +</code>
  
- +===3. 查看I2C 0号总线上挂载的设备=== 
-===2. 查看I2C 0号总线上挂载的设备===+<code bash>
 root@Widora:/# i2cdetect -y 0 root@Widora:/# i2cdetect -y 0
       1  2  3  4  5  6  7  8  9  a  b  c  d  e  f       1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
Line 39: Line 41:
 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 70: -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
 +</code>
 其中标识为UU的设备(地址分别为0x1a和0x34)表示内核已经加载了相应的驱动,而地址为0x48的I2C设备尚未被内核所驱动。 其中标识为UU的设备(地址分别为0x1a和0x34)表示内核已经加载了相应的驱动,而地址为0x48的I2C设备尚未被内核所驱动。
  
-3. 在sysfs文件中可看具体I2C设备名称+===4. 在sysfs文件中可已被内核驱动的I2C设备名称=== 
 +<code bash>
 root@Widora:/# ls /sys/bus/i2c/devices root@Widora:/# ls /sys/bus/i2c/devices
 0-001a  0-0034  i2c-0 0-001a  0-0034  i2c-0
Line 49: Line 52:
 root@Widora:/# cat /sys/bus/i2c/devices/0-0034/name root@Widora:/# cat /sys/bus/i2c/devices/0-0034/name
 codec_wm8960 codec_wm8960
 +</code>
  
-4. 用i2cdump -y 0 0x48 W 命令来读取地址为0x48的I2C设备(LM75温度传感器)所有寄存器中的内容+===5. 用i2cdump -y 0 0x48 W 命令来读取地址为0x48的I2C设备(LM75温度传感器)所有寄存器中的内容=== 
 +<code bash>
 root@Widora:/# i2cdump -y 0 0x48 W root@Widora:/# i2cdump -y 0 0x48 W
       1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef       1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
Line 60: Line 65:
 50: 1e 00 4b 00 ff ff ff ff 1e 00 4b 00 ff ff ff ff    ?.K.....?.K..... 50: 1e 00 4b 00 ff ff ff ff 1e 00 4b 00 ff ff ff ff    ?.K.....?.K.....
 60: 1e 00 4b 00 ff ff ff ff 1e 00 4b 00 ff ff ff ff    ?.K.....?.K..... 60: 1e 00 4b 00 ff ff ff ff 1e 00 4b 00 ff ff ff ff    ?.K.....?.K.....
 +</code>
 +
 +===6. 用i2cget -y 0 0x48 0 w 命令来读取地址为0x48的I2C设备0号寄存器中的内容===
  
i2c.1534167169.txt.gz · Last modified: (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki