i2c-tools
- obsahují nástroje i2cdetect
, i2cget
a i2cset
Příklad použití I2C sběrnice:
Pro vlastní zápis a čtení je možné použít balíček i2c-tools. Nejprve detekujeme, zda máme na sběrnici něco připojeno:
root@OpenWrt:/# i2cdetect -y 0 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
Ano máme, konkrétně na adrese 0x50, jdeme tedy zapisovat a následně číst.
root@OpenWrt:/# i2cget -y 0 0x50 0 b 0x00 root@OpenWrt:/# i2cget -y 0 0x50 1 b 0x01 root@OpenWrt:/# i2cget -y 0 0x50 2 b 0x02 root@OpenWrt:/# i2cget -y 0 0x50 3 b 0x03 root@OpenWrt:/# i2cget -y 0 0x50 4 b 0x11 root@OpenWrt:/# i2cset -y 0 0x50 4 0x04 b root@OpenWrt:/# i2cget -y 0 0x50 4 b 0x04
http://blog.jfila.cz/2014/11/zprovozneni-spi-na-openwrt.html