Robostix i2c-io

Many people have requested the ability to read the robostix ADC lines and GPIO lines from the gumstix. i2c-io allows this to happen.

i2c-io consists of two parts, i2c-io.hex which is installed on the robostix, and the i2c-io program which runs on the gumstix. There are two precompiled versions of i2c-io available:
 * i2c-io-2.6.11.tar.gz
 * i2c-io-2.6.15.tar.gz. Note that the 2.6.15 version also works under 2.6.17, and 2.6.18 prior to SVN revision 1185.
 * i2c-io-2.6.18-1185.tar.gz. For SVN revisions 1185 and onwards.

Installing i2c-io on the robostix
You need to install the i2c BootLoader first. Then execute this command: i2c-load --reset 0x0b write i2c-io.hex

This will download the i2c-io-hex file to the robostix. When the i2c-io program is running, the red LED will flash twice quickly, followed by a longer pause. This sequence will repeat about once per second.

Using i2c-io
The i2c-io program has the following online help: Usage: i2c-io [options] i2c-addr cmd [cmd-options] Manipulate robostix I/O pins

The following commands are supported: Info Retrieves information about the robostix program Get port.pin Retrieves the value of a pin Set port.pin val Sets the value of a pin SetDir port.pin dir Sets the direction of a pin ReadReg regIdx Reads an 8 bit register WriteReg regIdx val Writes a value into an 8 bit register port.pin specifies a port using a letter (A-G) and a pin (0-7) For example, C.3 means Port C pin 3 The port may also be specified using the special port ADC The following arguments may be used to modify the behaviour --hex (or -x) Print ReadReg results in hex --decimal (or -d) Print ReadReg results in decimal --version Print the version information for this program --verbose Print additional information --help Prints this information

i2c-io i2c-addr Info
The Info command prints some version information about the robostix portion of the i2c-io program: version: 1 minVersion: 1 SVN Revision: 793
 * 1) i2c-io 0x0b info

i2c-io i2c-addr Get port.pin
Retrieves the value detected on the indicated port and pin. The port can be the letters from A thru G, or ADC. For ports A thru G, the pin can have the range 0 thru 7. For the ADC port, the pin can have the values 0 thru 31. 0 thru 7 correspond to reading pins AD0 thru AD7 in single ended modes. For values 8 thru 31, refer to the ATMega128 datasheet.

One thing to be careful about, on the robostix there are pin numbers in the range 1 thru 8 on the top side of the board. These will be off by one. If you look on the back side of the board, you'll see PC0 thru PC7 and AD0 thru AD7. The numbers here are the pin number being referred to.

When reading an ADC port, the 10-bit value (in the range 0 thru 1023) is printed. For other ports only the value 0 or 1 is printed.

i2c-io i2c-addr Set port.pin value
Sets the value output on a port. If the pin is configured as an output pin, then this will cause the pin to drive at 0v (for an output of 0) or 5v (for an output of 1). If the pin is configured as an input pin, the setting the pin to 1 enables a pullup resistor, and setting the pin to 0 disables the pullup resistor.

'value' can also be the strings on or off (on=1, off=0). Only ports A thru G are valid.

i2c-io i2c-addr SetDir port.pin dir
Sets the direction of the indicated GPIO pin. 'dir' may be 0 or 1, or in or out (in=0, out=1).

i2c-io i2c-addr GetDir port.pin
Returns the direction of the indicated pin

i2c-io i2c-addr ReadReg register
Reads a value from a 'register' on the robostix. The registers can be specified using a symbolc name (i.e. portf) or a number.

i2c-io i2c-addr WriteReg register value
Writes a value into a 'register' on the robostix. The registers can be specified using a symbolc name (i.e. portf) or a number.

Examples
This will turn the Blue LED on: i2c-io 0x0b setdir g.3 out i2c-io 0x0b set g.3 0

And this will turn the Blue LED off: i2c-io 0x0b set g.3 1

This will also turn the Blue LED on using the writereg command: i2c-io 0x0b writereg ddrg 0x18 i2c-io 0x0b writereg portg 0

And this will turn the Blue LED off: i2c-io 0x0b writereg portg 0x08

Source code
The source code for the i2c-io is available from SVN, You'll also need the robostix/Common and robostix/Shared directories to build the robostix side of i2c-io, and the robostix/gumstix/Common and robostix/gumstix/i2c-io directories to build the gumstix side of things.

API
There is a C library available for i2c-io called i2c-io-api.

Troubleshooting
There are some steps for testing the i2c hardware connection on the Robostix i2c test page.