|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjcontrol.comm.I2C
public class I2C
Controls I2C devices connected to JControl.
The I2C bus is a de facto standard for on board inter integrated circuit communication
invented by Phillips.
Many chips are supporting this bus, including the JControl RTC on
some Boards.
Currently JControl only works as I2C busmaster, so it can only send data
and send requests for data actively. It can't poll the bus as slave and reply for
requests of other masters. It is a simple hardware layer implementation so any
bus error and any lost arbitration results in an IOException after
some retries. To avoid blocking there is contrary to the specification a bus timeout
also resulting in an IOException.
Another bus system based on I2C is the SM (system management) bus available on some PC motherboards, for monitoring tempeartures and controlling fans.
| all |
| Field Summary | |
|---|---|
static int |
MODE_10BIT
Selects I2C mode with 10-bit addresses. |
static int |
MODE_7BIT
Selects I2C mode with 7-bit addresses (default). |
| Constructor Summary | |
|---|---|
I2C(int address)
Constructs a new I2C object for 7-bit addresseing. |
|
I2C(int address,
int mode)
Constructs a new I2C object. |
|
| Method Summary | |
|---|---|
void |
close()
Closes this I2C instance, further reads or writes are not possible. |
char |
read()
Just reads a single byte from the I2C device. |
int |
read(byte[] cmd,
byte[] data,
int startindex,
int length)
Writes a command stream to a I2C device and reads a reply in the same transaction. |
int |
read(byte[] data,
int startindex,
int length)
Reads a data stream from a I2C device. |
int |
write(byte[] cmd,
byte[] data,
int startindex,
int length)
Writes a command stream and a data stream to a I2C device in the same transaction. |
int |
write(byte[] data,
int startindex,
int length)
Writes a data stream to a I2C device. |
void |
write(char data)
Just writes a single byte to the I2C device. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, notifyAll, wait |
| Field Detail |
|---|
public static final int MODE_10BIT
public static final int MODE_7BIT
| Constructor Detail |
|---|
public I2C(int address)
address - 7-bit address of the the device to send data to
public I2C(int address,
int mode)
address - of the the device to send data tomode - bus mode (addressing etc)MODE_7BIT,
MODE_10BIT| Method Detail |
|---|
public void close()
close in interface BasicInputStreamclose in interface BasicOutputStreamBasicOutputStream.close()
public char read()
throws IOException
read in interface BasicInputStreamIOException - if an error occursBasicInputStream.read()
public int read(byte[] cmd,
byte[] data,
int startindex,
int length)
throws IOException
cmd - the buffer with command to write (all bytes of array, null for command omission)data - the buffer to write received datastartindex - the index to start writing the array (and reading from to I2C)length - number of bytes to write; the array is accessed from startindex to
startindex+length-1, it may be partially filled according to the
I2C slave device
IOException - if an error occurs
public int read(byte[] data,
int startindex,
int length)
throws IOException
read in interface BasicInputStreamdata - the buffer to fillstartindex - the index to start filling the array (with data read from I2C)length - number of bytes to read; the array is filled from startindex to
startindex+length-1, it may be partially filled according to the
I2C slave device
IOException - if an error occurs
public int write(byte[] cmd,
byte[] data,
int startindex,
int length)
throws IOException
cmd - the buffer with command to write (all bytes of array, null for command omission)data - the buffer to read data to transmitstartindex - the index to start reading the array (and writing to I2C)length - number of bytes to read; the array is accessed from startindex to
startindex+length-1
IOException - if an error occurs
public int write(byte[] data,
int startindex,
int length)
throws IOException
write in interface BasicOutputStreamdata - the buffer that holds the data to writestartindex - the index to start reading the array (and writing to I2C)length - number of bytes to write; the array is read from startindex to
startindex+length-1
IOException - if an error occurs
public void write(char data)
throws IOException
write in interface BasicOutputStreamdata - I2C Data to transmit (range 0...255)
IOException - if an error occursBasicOutputStream.write(char)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||