|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--cork.device.AbstractDevice | +--cork.net.i2c.AbstractI2CDevice
All I2C capable devices should use this base class for communitcating with the I2C bus.
Constructor Summary | |
protected |
AbstractI2CDevice(int address)
Constructor for the AbstractDevice object |
Method Summary | |
void |
capture()
Captures the BusMaster for exclusive access by a specific device. |
void |
destroy()
Provides notification that bus is about to be destroyed. |
I2CBusMaster |
getBusMaster()
Gets the bus master this device is using. |
int |
getDeviceAddress()
Gets the I2C device address for this device. |
abstract I2CDevice |
getI2CDevice()
This must be implemented by all I2C devices, and must return it's own instance. |
boolean |
isCaptured()
Indicated that the line driver is in use by another device. |
void |
read(int id,
int[] buffer,
int count)
Reads data from the specified ID. |
void |
release()
Releases and frees the BusMaster for capture by another device. |
void |
start()
Start communication on the I2C bus. |
void |
stop()
Stops communication the I2C bus. |
void |
tick()
Ticks over the SCL line. |
void |
write(int id,
int[] buffer,
int count)
Writes data to the specified ID. |
Methods inherited from class cork.device.AbstractDevice |
addEventListener, removeEventListener, sendDeviceEvent |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface cork.device.Device |
getDeviceDestription, getDeviceName |
Constructor Detail |
protected AbstractI2CDevice(int address)
address
- Description of ParameterMethod Detail |
public void destroy()
The default implementation of this method does nothing.
public final void start() throws I2CException
I2CException
- throws an I2CException is the device has not
captured teh BusMaster.public final void stop() throws I2CException
I2CException
- throws an I2CException is the device has not
captured the BusMaster.public final void tick() throws I2CException
I2CException
- throws an I2CException is the device has not
captured the BusMaster.public final void capture() 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.
I2CException
- throws an I2CException is the capture method
produced an error, or was unable to capture the BusMaster for some
reason.public final void release() throws I2CException
I2CException
- throws an I2CException is the device has not
previously captured the BusMaster.public final void read(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.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 final void write(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.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.public abstract I2CDevice getI2CDevice()
public final int getDeviceAddress()
The address is an array to support future expansion of devices to the new I2C protocol that allows 2 byte addresses. For most devices the array will have a length of 1.
getDeviceAddress
in interface I2CDevice
public final I2CBusMaster getBusMaster()
getBusMaster
in interface I2CDevice
public final boolean isCaptured()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |