|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Provides a high level interface to the I2C bus master, allowing bytes to be written and read from the bus.
Implementations are expected to use byte buffers in the following manner. When reading and writing to the bus the implementation will take a reference to the devices byte buffer. In this way devices can maintain their own buffers preventing future bus operations from overwriting recieved values. Furthermore, this removes any requirement for the I2CBusMaster to create new buffers that may possibly require garbage collection in the future.
All bus operations may throw an I2CBusException should the bus stall. This might be considered an indicator that the operation you were trying to perform did not complete successfully.
Method Summary | |
void |
capture(I2CDevice device)
Captures the BusMaster for exclusive access by a specific device. |
boolean |
isCaptured()
Indicates that the line driver is in use by another device. |
void |
read(I2CDevice device,
int id,
int[] buffer,
int count)
Reads data from the specified ID. |
void |
release(I2CDevice device)
Releases and frees the BusMaster for capture by another device. |
void |
start(I2CDevice device)
Start communication on the I2C bus. |
void |
stop(I2CDevice device)
Stops communication the I2C bus. |
void |
tick(I2CDevice device)
Ticks over the SCL line. |
void |
write(I2CDevice device,
int id,
int[] buffer,
int count)
Writes data to the specified ID. |
Method Detail |
public void start(I2CDevice device) throws I2CException
device
- the device calling the start() method. This device
must have first captured the BusMaster.I2CException
- throws an I2CException is the device has not
captured teh BusMaster.public void stop(I2CDevice device) throws I2CException
device
- the device calling the stop() method. This device
must have first captured the BusMaster.I2CException
- throws an I2CException is the device has not
captured the BusMaster.public void tick(I2CDevice device) throws I2CException
device
- the device calling the tick() method. This device
must have first captured the BusMaster.I2CException
- throws an I2CException is the device has not
captured the BusMaster.public void capture(I2CDevice device) throws I2CException
How this method deals with with a wait state is implementaion dependant, but it is suggested to implementors that this method should block until the I2C line is free for communitaction.
device
- the device wishing to capture the BusMasterI2CException
- Description of Exceptionpublic void release(I2CDevice device) throws I2CException
device
- the device wishing to release the BusMasterI2CException
- throws an I2CException is the device has not
captured teh BusMaster.public boolean isCaptured()
public void read(I2CDevice device, int id, int[] buffer, int count) throws I2CException, java.lang.ArrayIndexOutOfBoundsException
id
- the id we're addressing the bytes
to.buffer
- the buffer that the bytes will be
added to.count
- the number of bytes to read into
the buffer.device
- the device wishing to read the
BusMaster. This device must have first captured the BusMaster.I2CException
- throws an I2CException is the
device has not captured the BusMaster. Also thrown if the or if there
was some other problem reading from the bus.java.lang.ArrayIndexOutOfBoundsException
- if the count is larger than the
buffer, or the count os less than 1.public void write(I2CDevice device, int id, int[] buffer, int count) throws I2CException, java.lang.ArrayIndexOutOfBoundsException
id
- the id we're addressing the bytes
to.buffer
- the buffer the the bytes will be
written from.count
- the number of bytes ro write.device
- the device wishing to write the
BusMaster. This device must have first captured the BusMaster.I2CException
- throws an I2CException is the
device has not captured the BusMaster. or if there was some other
problem writing to the bus.java.lang.ArrayIndexOutOfBoundsException
- if the count is larger than the
buffer, or the count os less than 1.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |