Linux I2C工具查看配置I2C设备【转】

简介:

转自:http://blog.chinaunix.net/uid-26895763-id-3478882.html

 

在處理音訊相關的問題時,我通常會找個方法來讀寫codec中register的值。幸好linux上也有這樣的工具 – i2c tools。先到lm-sensors下載soure code,然後cross compile成arm的執行檔,就可以放到板子來試試看了。
i2c-tools中含有四個執行檔


i2cdetect – 用來列舉I2C bus和上面所有的裝置
i2cdump – 顯示裝置上所有register的值
i2cget – 讀取裝置上某個register的值
i2cset – 寫入裝置上某個register
以下是我用beagleboard得到的結果


root@android:/temp # ./i2cdetect -l
i2c-1 i2c OMAP I2C adapter I2C adapter
i2c-2 i2c OMAP I2C adapter I2C adapter
i2c-3 i2c OMAP I2C adapter I2C adapter
原來beagleboad上有三組I2C bus。
i2cdetect也可以用來看bus上有那些裝置


root@android:/temp # ./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 UU UU UU -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
這表示bus上有四備裝置,位址分別是0×48, 0×49, 0x4a, 0x4b。
我們要找的是codec,beagleboard上的codec是TI的TPS65950,從technical reference manual可以得知codec在I2C上的位址是0×49。
然後用i2cdump來看codec中所有register的值
[


root@android:/temp # ./i2cdump -f -y 1 0x49
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: 00 00 00 00 00 00 00 00 00 00 0f 0f 0f 0f 00 00 ..........????..
10: 3f 3f 3f 3f 25 00 00 00 00 32 32 32 32 00 00 55 ????%....2222..U
20: 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 00 ...........?....
30: 13 00 00 00 00 79 11 00 00 00 06 00 44 69 02 00 ?....y?...?.Di?.
40: 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 1b ....2..........?
50: 00 00 03 f0 05 00 00 00 1a 1a 00 e1 93 00 00 00 ..???...??.??...
60: 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?...............
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80: 00 00 00 00 00 2f 00 09 10 ff ff ff ff ff ff ff ...../.??.......
90: ff 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ........?.......
a0: 00 00 00 00 00 00 00 00 00 00 04 18 50 01 44 05 ..........??P?D?
b0: 00 00 00 00 fe ff 03 00 00 00 ff ff 03 00 00 00 ....?.?.....?...
c0: 03 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 ?....?..........
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: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
再來我用i2cset來改變headset gain看看會不會改變播放的音量。先用以下的指令來播放wav檔,我是用sample rate 44.1k的檔案,其它sample rate的wav可能無法播放。


root@android:/temp # ./tinymix 13 1
root@android:/temp # ./tinymix 45 1
root@android:/temp # ./tinymix 48 1
root@android:/temp # ./tinyplay 440.wav
Playing sample: 2 ch, 44100 hz, 16 bit
headset gain的register的位址是0×23,在播放的過程中打開另一個adb shell,用i2cset來增加gain


root@android:/temp # ./i2cset -f -y 1 0x49 0x23 5
音量果然變大了!

i2cget的用法類似i2cget,這裡就不多做說明了。


本博客转载自台湾朋友的文章:http://3sec.kilab.tw/?p=260










本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/sky-heaven/p/6035641.html,如需转载请自行联系原作者

相关文章
|
17天前
|
Linux
Linux操作系统调优相关工具(三)查看IO运行状态相关工具 查看哪个磁盘或分区最繁忙?
Linux操作系统调优相关工具(三)查看IO运行状态相关工具 查看哪个磁盘或分区最繁忙?
21 0
|
1天前
|
Oracle Java 关系型数据库
Linux环境安装配置JDK11
Linux环境安装配置JDK11
15 0
|
1天前
|
Ubuntu Linux
Linux(Ubuntu)系统临时IP以及静态IP配置(关闭、启动网卡等操作)
请注意,以上步骤是在临时基础上进行配置的。如果要永久保存静态IP地址,通常还需要修改 `/etc/network/interfaces`文件,以便在系统重启后保持配置。同时,确保备份相关配置文件以防止出现问题。
11 1
|
2天前
|
JSON Unix Linux
Linux系统之jq工具的基本使用
Linux系统之jq工具的基本使用
29 2
|
2天前
|
监控 安全 Linux
Linux系统之安装ServerBee服务器监控工具
【4月更文挑战第22天】Linux系统之安装ServerBee服务器监控工具
41 2
|
3天前
|
编解码 Linux 数据安全/隐私保护
linux工具之curl与wget高级使用
linux工具之curl与wget高级使用
|
3天前
|
Ubuntu Linux 测试技术
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试(下)
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试
35 1
|
3天前
|
运维 网络协议 Linux
Linux(28) Linux双网卡配置为连接到Linux主机的PC提供外网访问
Linux(28) Linux双网卡配置为连接到Linux主机的PC提供外网访问
30 1
|
4天前
|
Ubuntu 网络协议 Linux
Linux(20) Ubuntu 20.04 网络接口自动切换路由配置
Linux(20) Ubuntu 20.04 网络接口自动切换路由配置
27 0
|
4天前
|
Linux
Linux(9)Debain EC25 quectel-CM usbnet0开机自动联网配置
Linux(9)Debain EC25 quectel-CM usbnet0开机自动联网配置
15 0