| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

I2C

This version was saved 17 years, 4 months ago View current version     Page history
Saved by PBworks
on December 1, 2006 at 4:26:05 am
 

I've been working on an I2C bus driver for the WGT634U's GPIO pins. This I2C bus driver has worked (preliminary testing only) under Kamikaze r5435 with 2.6.17 kernel:

http://openwrt.pbwiki.com/f/i2c-bcm5365.c

I was able to flip the output bits on a PCF8574 chip with a user-space program talking to /dev/i2c-0.

 

Here are my steps to installing it:

  • copy or link the i2c-bcm5365.c file above into build_mipsel/linux/drivers/i2c/busses
  • edit build_mipsel/linux/drivers/i2c/busses/Makefile adding i2c-bcm5365.o line
  • edit build_mipsel/linux/drivers/i2c/busses/Kconfig adding I2C_BCM5365 stanza
  • edit package/kernel/modules/other.mk adding i2c-core, i2c-dev, i2c-algo-bit, and i2c-bcm5365 stanzas. Autoload priorities should be set so i2c-core loads first, and i2c-bcm5365 loads last.
  • make ARCH=mips menuconfig in the kernel build directory (see http://wiki.openwrt.org/BuildRoot#Customizingthekerneloptions ) and choose <m> for I2C, I2C_CHARDEV, I2C_ALGO_BIT, and I2C_BCM5365

 

  • make menuconfig in the top directory and choose <*> for i2c-core, i2c-dev, i2c-algo-bit, and i2c-bcm5365.
  • make in the top directory.
  • copy the new binary to the router with tftp

 

running lsmod on the router should show all four i2c-* modules loaded.

 

You can specify which gpio bits are used in /etc/modules.d/nn-i2c-bcm5365, e.g.

  • i2c-bcm5365 sclbit=0x10 sdabit=0x20

 

You must mknod /dev/i2c-0 c 89 0 to create the character device for user-space access to the bus.


 

Now available as an ipkg! I'll post steps to how I made it here soon... meanwhile, you can try to ipkg install kmod-i2c_2.6.17-brcm-1_mipsel.ipk. Then insmod i2c-core, insmod i2c-dev, insmod i2c-algo-bit and insmod i2c-bcm5365 . Make sure you mknod /dev/i2c-0 c 89 0 ! I haven't tried to see if the i2c bus works yet, I just wanted to get this up here. All the modules loaded fine, but I did have to ipkg -force-depends install ... (OpenWrt changed the kernel versioning since 5370). If this works/doesn't, let me (flyashi-@-gmail) know :) Thanks!

 

P.S. HUGE thanks to Chuck Harrison for this awesome driver!

P.P.S. If you have any programs to access I2C devices (PCF8574, other GPIO chips, ADC chips, etc.), it would be nice to post them here for everyone to use :) I'm going to write one for a thermistor chip to monitor the CPU temp :D


some command-line i2c programs

These have worked under recent kamikaze w/2.6.17 kernel

 

<device node> is typically /dev/i2c-0.

Note: <dev addr> above is in the range 0-127 (7-bit address). If your datasheet says "write address 0x40, read address 0x41" it is talking about 8-bit codes which include the read/write flag as LSB. The corresponding 7-bit <dev addr> is 0x20 (decimal 32).


 

WifiCar v2 uses I2C! http://yasha.okshtein.net/wificarv2.html

 

lcd4linux uses I2C to drive a standard (HD44780) LCD with a PCF8574 by default to display a lot of informations.

you have to modify the settings for plugins and size (see here)

Comments (0)

You don't have permission to comment on this page.