Specifications
Interfacing to external I
2
C slave devices
Technically the correct name for this two-wire serial bus is Inter-IC bus or I
2
C, though it is sometimes
written as I2C.
Information on this popular two-wire hardware interface is readily available on the web;
http://www.i2c-bus.org/
is one starting point you could use. In particular look for a document called
“The I
2
C-bus and how to use it (including specifications).”
I2C uses two pins:
• SCL – Serial Clock Line
• SDA – Serial Data line (bidirectional)
Because both the value and direction (input versus output) of the SCL and SDA pins must be rapidly
and precisely controlled, dedicated I2C support functions have been added to SNAPpy.
• i2cInit(enablePullups) – Prepare for I
2
C operations (call this to setup for I
2
C)
• i2cWrite(byteStr, retries, ignoreFirstAck) – Send data over I
2
C to another device
• i2cRead(byteStr, numToRead, retries, ignoreFirstAck) – Read data from device
• getI2cResult() – used to check the result of the other functions
These routines are covered in more detail in section 7 of this document.
By using these routines, your SNAPpy script can operate as an I
2
C bus master, and can interact with
I
2
C slave devices.
When performing I
2
C interactions, fixed IO pin assignments are used. For example, on an RF100 the
following IO pins are used:
• GPIO 17 is always used as the I
2
C SDA (data) line
• GPIO 18 is always used as the I
2
C SCL (clock) line
Note! – These pins are only dedicated if you are actually using the I
2
C functions. If not, they remain
available for other functions.
Refer to the platform-specific section for your hardware (located at the back of this manual) for the pin
assignments for your platform.
Unlike CBUS and SPI, I
2
C does not use separate “chip select” lines. The initial data bytes of each I
2
C
transaction specify an “I
2
C address.” Only the addressed device will respond. So, no additional GPIO
pins are needed.
The specifics of which bytes to send to a given I
2
C slave device (and what the response will look like)
depend on the I
2
C device itself. You will have to refer to the manufacturer’s data sheet for any given
device to which you wish to interface.
Page 38 of 202 SNAP Reference Manual Document Number 600-0007K