LaFonera Hardware i2c
From DD-WRT Wiki
Revision as of 03:45, 25 November 2007 (edit) Wildblue (Talk | contribs) m (removed typos) ← Previous diff |
Revision as of 02:24, 10 March 2008 (edit) (undo) MLange (Talk | contribs) (→Refrences) Next diff → |
||
Line 144: | Line 144: | ||
- | == | + | ==References== |
* http://www.lefinnois.net/wpen/index.php/2007/05/13/i2c-bus-for-la-fonera/ | * http://www.lefinnois.net/wpen/index.php/2007/05/13/i2c-bus-for-la-fonera/ | ||
+ | |||
+ | ==Things you can put on the I2C Bus== | ||
+ | * [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en021393|MCP23008 - 8-bit GPIO Expander] (+8 GPIO) | ||
+ | * [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en023499|MCP23017 - 16-bit GPIO Expander] (+16 GPIO) | ||
Revision as of 02:24, 10 March 2008
You are here: DD-WRT wiki mainpage / LaFonera / Hardware / i2c
Contents |
i2c bus for La Fonera
The goal for my first try to use Fonera’s GPIO is to get i2c working on the router. And now, it’s done. Kernel module and user space programs are here.
My kernel implementation use 4 GPIO on SW1 (1-2-5-6) near the Ethernet connector. Pin 1 and 2 are respectively used for sending and receiving SDA signals. 5 and 6, for SCL signals.
The GPIO are connected to a 75LS05 (TTL hex inverter) used as level adapter and buffer. You can see schematic here (PDF) (mirror).
On the software side, my module is based on i2c-parport-light. Linux i2c stack is very complete, all i have to do is to use bit-banging i2c API (2c-algo-bit module). My driver, i2c_gpio,
is available here: i2c-gpio-0.0.5.tar.gz (mirror). Take a look to the README file to get more information.
To test i2c bus, simply use i2cdetect from lm-sensors project. This tool can scan i2c bus to detect chips. Here is a adapted version for La Fonera as a ipkg source package: i2cdetect.tar.gz (mirror). This file contain also ds75ioctl. It’s a simple tool that can talk to DS75 thermal sensor.
Example :
insmod i2c_algo_bit i2c_debug=3 bit_test=1 insmod i2c_gpio inverted=1
In dmesg :
i2c-algo-bit.o: (0) scl=128, sda=16 i2c-algo-bit.o: (1) scl=128, sda=0 i2c-algo-bit.o: (2) scl=128, sda=16 i2c-algo-bit.o: (3) scl=0, sda=16 needed 1 jiffies i2c-algo-bit.o: (4) scl=128, sda=16 i2c-algo-bit.o: GPIO adapter passed test. : hw routines registered. i2c_adapter i2c-0: adapter GPIO adapter registered i2c-dev: adapter GPIO adapter registered as minor 0 gpio_i2c: module loaded gpio_i2c: inverted outputs
i2c bus seem to work well. Let’s try i2cdetect :
root@OpenWrt:/# i2cdetect -l i2c-0 i2c GPIO adapter Algorithm unavailable
We have a bus here, so let’s scan it :
root@OpenWrt:/# 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 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: XX XX XX XX XX XX XX XX XX XX XX XX XX 10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 20: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 30: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 40: XX XX XX XX XX XX XX XX 48 XX XX XX XX XX XX XX 50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 70: XX XX XX XX XX XX XX XX
Hey ! There is something at 0×48 :
root@OpenWrt:/# ds75ioctl -d /dev/i2c-0 -a 0x48 23.8150
23.81°C. It works !
PCB
Here is the PCB of i2c adapter for La Fonera.
Files
You can find Sources, binaries for OpenWrt Kamikaze 7.06, schematic and PCB here: http://www.lefinnois.net/fonerai2c/.
Mirror for files existing on 2007-11-25
/
/7.06/atheros-2.6/packages/
kmod-i2c-algos_2.6.19.2-atheros-1_mips.ipk
kmod-i2c-core_2.6.19.2-atheros-1_mips.ipk
kmod-i2cgpio_2.6.19.2-atheros-1_mips.ipk
/7.07/atheros-2.6/packages/
kmod-i2c-algos_2.6.21.5-atheros-1_mips.ipk
kmod-i2c-core_2.6.21.5-atheros-1_mips.ipk
kmod-i2cgpio_2.6.21.5-atheros-1_mips.ipk
/Packages/
kmod-i2c-algos_2.6.19.2-atheros-1_mips.ipk
kmod-i2c-core_2.6.19.2-atheros-1_mips.ipk
kmod-i2cgpio_2.6.19.2-atheros-1_mips.ipk
References
Things you can put on the I2C Bus
- - 8-bit GPIO Expander (+8 GPIO)
- - 16-bit GPIO Expander (+16 GPIO)
this page was made by wildblue!