Friday, 5 October 2018

Tinkering OpenWRT (15) : Use I2C Bus



Step 1: Do as the official document says

# opkg update 
# opkg install kmod-i2c-gpio-custom kmod-i2c-core 
# insmod i2c-dev 
# insmod i2c-gpio-custom bus0=0,26,12 
# dmesg | grep gpio 
Mar 23 09:01:23 openwrt kern.info kernel: [ 52.910000] Custom GPIO-based I2C driver version 0.1.1 
Mar 23 09:01:23 openwrt kern.info kernel: [ 52.910000] i2c-gpio i2c-gpio.0: using pins 26 (SDA) and 12 (SCL)
Im using my AR9331 board, and Im using GPIO 26 and 12 as my SDA and SCL repectively.
And then what? The official doc just stops here?

Step 2 : Wiring

AR9331        Slave
SDA              SDA
SCL               SCL
GND             GND       <= this is very important

Step 3 : install i2c-tools

# opkg update && opkg install i2c-tools

Step 3 : install i2c-tools
# i2cdetect 0 

WARNING! This program can confuse your I2C bus, cause data loss and worse! 
I will probe file /dev/i2c-0. 
I will probe address range 0x03-0x77. Continue? [Y/n] y
       0 1 2 3 4 5 6 7 8 9 a b c d e f 
00: -- -- -- -- -- -- -- -- 08 -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- 
48 -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- 

try this...
# i2cget 0 0x48 0 w




ref:
https://wiki.openwrt.org/doc/hardware/port.i2c
https://www.cnblogs.com/fastwave2004/articles/4250604.html     !!!!
http://linux-adm5120.sourceforge.net/openwrt/i2c/

No comments:

Post a Comment