* [[:|Wiki Home]]
* [[:cheat_sheet|Cheat Sheet]]
* [[:compiling_on_virtualbox|Precompiled virtual tools]]
* [[:carambola_where_to_start|Where to start]]
* [[:carambola_connecting|Connecting to carambola]]
* [[:carambola_using_and_customizing|Using and Customizing]]
* [[:carambola_demo_projects|Demo projects/examples]]
* [[:carambola_hardware|Hardware]]
====== About ======
This topic covers how to connect I2C device to Carambola. For this tutorial I will use [[http://www.ti.com/product/pcf8575|PCF8575 16 bit I/O expander]].
{{:cimg1339_.jpg?direct&500|}}
====== Schematics ======
In order to connect I2C device I will need few passive components. See attached schematics.
{{:carambola_i2c.png?direct&500|}}
There is also power selection jumper (5V or 3.3V) and SPI pin header. Discard these for this subject.
====== Preparing Carambola ======
* run ''make menuconfig'' and select these packages:
Kernel modules
I2C support
kmod-i2c-gpio
Utilities
i2c-tools package
* Type ''make'' and rebuild firmware
* Reflash
* If you are unfamiliar with these steps read [[carambola_where_to_start|Where to start]]
====== Testing ======
Connect to Carambola with fresh firmware and type ''i2cdetect -y 0''. You should see something like:
root@OpenWrt:/# i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
====== Read data ======
root@OpenWrt:/# i2cget -y 0 0x20 0x00 w
0xffff
====== Write data ======
root@OpenWrt:/# i2cset -y 0 0x20 0x00 0xff
====== Issues ======
These utilities were written to work with I2C memory devices and lack of full I2C support. Biggest issue - it is possible only communicate with devices that have 2 bytes in I2C protocol. Although I2C on hardware level supports up to 7 (I am not exactly sure right now) bytes for both directions.