android下面通过I2C TOOLS工具查看设备寄存器

mac2025-05-14  1

android下面通过I2C TOOLS工具查看设备寄存器

1.下载 i2c-tools-3.0.2.tar.bz2

2. 解压后,修改Makefile文件,选择arm的编译器,同时在tools的Module.mk文件中编译选项中添加-static静态编译选项,

不然生成的执行文件会提示无法找到的提示;静态-static 添加在-o的前面就行了。

3.一切顺利生成i2cdetect,i2cdump,i2cset,i2cget等命令工具;

4.adb push i2cdetect  /system/bin

   adb push i2cdump  /system/bin

   adb push i2cset   /system/bin

   adb push i2cget  /system/bin

 

-----------------------下面是关于这四个命令的用法举例

i2c-tools中含有四個執行檔

i2cdetect – 用來列舉I2C bus和上面所有的裝置i2cdump – 顯示裝置上所有register的值i2cget – 讀取裝置上某個register的值i2cset – 寫入裝置上某個register

以下是我用beagleboard得到的結果

/system/bin # i2cdetect -l i2c-0   i2c             s3c2410-i2c                             I2C adapter i2c-1   i2c             s3c2410-i2c                             I2C adapter i2c-2   i2c             s3c2410-i2c                             I2C adapter /system/bin # 看到有三条I2C总线 /system/bin # i2cdetect -y -r 0      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f 00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- 34 -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- /system/bin # 查看总线0上面有哪些设备以及设备地址; /system/bin # i2cdump -f -y 0 0x34 No size specified (using byte-data access)      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef 00: 38 70 00 21 00 00 00 00 00 00 00 00 00 00 00 00    8p.!............ 10: 05 00 5f 00 00 00 00 00 00 00 00 00 00 00 00 00    ?._............. 20: 00 00 00 16 00 00 00 68 ff 68 00 00 00 00 00 00    ...?...h.h...... 30: 61 02 42 c9 45 22 9d 08 a5 1f 68 5f fc 16 00 00    a?B?E"????h_??.. 40: d8 ff 03 01 00 00 00 00 08 08 02 00 60 00 00 00    ?.??....???.`... 50: cf 0e 00 00 0e 1f 00 00 00 00 00 00 00 00 71 04    ??..??........q? 60: a2 05 00 08 00 00 00 00 00 00 00 00 00 00 00 00    ??.?............ 70: 0c 27 a1 00 00 00 00 00 d0 02 00 00 0f 17 a2 00    ?'?.....??..???. 80: e0 fd 83 80 32 00 ff 00 00 00 00 00 00 00 00 21    ????2..........! 90: 07 a5 07 07 00 02 00 00 00 00 00 00 00 00 00 00    ????.?.......... a0: 00 00 00 00 00 01 1d 01 cd 06 00 00 0e 12 a2 0b    .....?????..???? b0: 00 00 00 00 00 00 00 00 00 14 80 ba d2 0d 00 00    .........?????.. c0: 01 01 02 04 07 0d 10 1a 24 2e 35 3d 49 54 5c 63    ????????$.5=IT\c d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................ e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................ f0: 41 00 80 03 00 00 00 00 00 00 00 00 00 00 00 00    A.??............ /system/bin # 读设备0x34的寄存器内容 /system/bin # i2cget -f -y 0 0x34 0x28 0xff /system/bin # 单独读0x28寄存器的值 /system/bin # /system/bin # /system/bin # i2cset -f -y 0 0x34 0x28 0xfb /system/bin # 单独写0x28寄存器的值 /system/bin # i2cget -f -y 0 0x34 0x28 0xfb /system/bin # 可以看出寄存器值已经由0xff改成为0xfb

最新回复(0)