i2cset:向i2c設(shè)備某個(gè)寄存器寫入值
Usage: i2cset [-f] [-y] [-m MASK] [-r] [-a] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]
I2CBUS is an integer or an I2C bus name
ADDRESS is an integer (0x03 - 0x77, or 0x00 - 0x7f if -a is given)
MODE is one of:
c (byte, no value)
b (byte data, default)
w (word data)
i (I2C block data)
s (SMBus block data)
Append p for SMBus PEC
f:強(qiáng)制訪問
y:指令執(zhí)行自動(dòng)yes,否則會(huì)提示確認(rèn)執(zhí)行Continue? [Y/n] Y,不加參數(shù)y會(huì)有很多執(zhí)行提示,可以幫助判斷
r:寫入后立即回讀寄存器的值,并將結(jié)果與寫入的值進(jìn)行比較
i2cbus:總線編號(hào)
chip-address:i2c設(shè)備地址
data-address:i2c寄存器地址
value 要寫入的值
mode:指定讀取的大小,b字節(jié),w字,s是SMBus塊,i是i2c塊
設(shè)置i2c-1上0x20器件的0x77寄存器值為0x3f
./i2cset -f -y 1 0x20 0x77 0x3f
i2cget:讀取i2c設(shè)備某個(gè)寄存器的值
Usage: i2cget [-f] [-y] [-a] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]
I2CBUS is an integer or an I2C bus name
ADDRESS is an integer (0x03 - 0x77, or 0x00 - 0x7f if -a is given)
MODE is one of:
b (read byte data, default)
w (read word data)
c (write byte/read byte)
Append p for SMBus PEC
f:強(qiáng)制訪問
y:關(guān)閉交互模式,不會(huì)提示警告信息
i2cbus:總線編號(hào)
chip-address:i2c設(shè)備地址
data-address:i2c寄存器地址
mode:指定讀取的大小,b字節(jié),w字,s是SMBus塊,i是i2c塊
讀取i2c-1上0x20器件的0x77寄存器值
./i2cget -f -y 1 0x20 0x77
i2cdump:讀取某個(gè)i2c設(shè)備所有寄存器的值
Usage: i2cdump [-f] [-y] [-r first-last] [-a] I2CBUS ADDRESS [MODE [BANK [BANKREG]]]
I2CBUS is an integer or an I2C bus name
ADDRESS is an integer (0x03 - 0x77, or 0x00 - 0x7f if -a is given)
MODE is one of:
b (byte, default)
w (word)
W (word on even register addresses)
s (SMBus block)
i (I2C block)
c (consecutive byte)
Append p for SMBus PEC
r:指定寄存器范圍,只能掃描從 first 到 last 區(qū)域
f:強(qiáng)制訪問設(shè)備
y:關(guān)閉人機(jī)交互模式
i2cbus:總線編號(hào)
address:指定設(shè)備地址
mode:指定讀取的大小,b字節(jié),w字,s是SMBus塊,i是i2c塊
讀取i2c1上0x38器件的所有寄存器
./i2cdump -f -y -a 1 0x38
一般寄存器都是8位地址的,i2cdump、i2cget、i2cset 也是設(shè)置讀取8位的地址,如果一次超過8位,需要用 i2ctransfer。
i2ctransfer:一次性讀寫多個(gè)字節(jié)
Usage: i2ctransfer [-f] [-y] [-v] [-V] [-a] I2CBUS DESC [DATA] [DESC [DATA]]...
I2CBUS is an integer or an I2C bus name
DESC describes the transfer in the form: {r|w}LENGTH[@address]
1) read/write-flag 2) LENGTH (range 0-65535) 3) I2C address (use last one if omitted)
DATA are LENGTH bytes for a write message. They can be shortened by a suffix:
= (keep value constant until LENGTH)
+ (increase value by 1 until LENGTH)
- (decrease value by 1 until LENGTH)
p (use pseudo random generator until LENGTH with value as seed)
查看系統(tǒng)上存在的 i2c 總線及其設(shè)備地址
ls /sys/bus/i2c/devices/
可以在這里查看實(shí)際的設(shè)備,然后對比 i2c-tools 掃描出來的對不對。
-
嵌入式
+關(guān)注
關(guān)注
5088文章
19159瀏覽量
306517 -
寄存器
+關(guān)注
關(guān)注
31文章
5359瀏覽量
120819 -
命令
+關(guān)注
關(guān)注
5文章
692瀏覽量
22065
發(fā)布評(píng)論請先 登錄
相關(guān)推薦
評(píng)論