|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--stamp.peripheral.io.I2C
This class defines a physical bus and provides essential I2C protocol routines. The bus pins should be pulled up to Vdd through 4.7K resistors.
This class can be used as-is, but will usually be referenced by a specific device class that uses the I2C bus. Direct use of this class requires the programmer to have some understanding of the I2C bus and protocol. Consult Philips documentation for details:
http://www.semiconductors.philips.com/i2c/
Creating the bus requires two available pins: SDA (serial data) and SCL (serial clock).
I2C ioBus = new I2C(CPU.pin0, CPU.pin1); // SDA on pin 0; SCL on pin 1
Field Summary | |
static int |
ACK
|
static int |
NAK
|
protected int |
sclPin
|
protected int |
sdaPin
|
Constructor Summary | |
I2C(int sdaPin,
int sclPin)
Creates I2C bus object and intializes bus pins. |
Method Summary | |
int |
read(int ackBit)
Read 8-bit value from I2C device. |
void |
start()
Send I2C Start sequence. |
void |
stop()
Send I2C Stop sequence. |
boolean |
write(int i2cData)
Write 8-bit value to I2C device. |
Methods inherited from class java.lang.Object |
equals |
Field Detail |
public static final int ACK
public static final int NAK
protected int sdaPin
protected int sclPin
Constructor Detail |
public I2C(int sdaPin, int sclPin)
sdaPin
- I2C serial data pin (bi-directional)sclPin
- I2C serial clock pinMethod Detail |
public void start()
public boolean write(int i2cData)
i2cData
- Value to write to I2C devicepublic int read(int ackBit)
ackBit
- 0 to send Ack; 1 to send Nak after receipt of datapublic void stop()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |