|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface I2CMaster
Interface to a class that provides master control of an I2C bus.
Method Summary | |
---|---|
void |
setFrequency(int frequency)
Sets the frequency of the I2C bus clock. |
void |
transfer(int deviceAddress,
byte[] writeBuffer,
byte[] readBuffer)
Transfer data between the master and a slave device at the specified address. |
Method Detail |
---|
void setFrequency(int frequency) throws IOException
The allowable frequencies are determined by the underlying hardware.
The standard frequencies are 100 kHz (100000) and 400 kHz (400000); however, mostI2C devices will work at a large range of frequencies.
Typically the I2C bus fequency should only set once, during system initialization.
The default frequency is 100 kHz.
frequency
- frequency of the I2C clock (SCL) in Hertz.
IOException
void transfer(int deviceAddress, byte[] writeBuffer, byte[] readBuffer) throws IOException
This method may be used to write-only, read-only or write-then-read. Each of these operations is performed as a single transaction on the I2C bus. The write-then-read operation issues a repeated-start command between the write and the read. The calling thread will block until the entire transfer is complete or fails.
Implementing classes must synchronize access to ensure only one thread can have a transfer pending at a time.
Users of this method do not need to be concerned about synchronizing threads; that is the responsibility of the class implementing this interface.
deviceAddress
- I2C address of the slave device.
writeBuffer
- A buffer of bytes to be written to the slave device.
readBuffer
- A buffer to receive bytes from a slave device.
IOException
|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |