de.wagner_ibw.iow.i2c
Class I2C

java.lang.Object
  |
  +--de.wagner_ibw.iow.i2c.I2C
All Implemented Interfaces:
SpecialModeFunction

public class I2C
extends java.lang.Object
implements SpecialModeFunction

Implementation of the I2C special mode function.

Author:
Thomas Wagner

Field Summary
private  java.util.Vector devices
          Vector of i2c devices.
private  AbstractIowDevcie iow
          Reference to the underlying IOW device.
(package private) static java.lang.String name
          Name of this special mode function.
 
Fields inherited from interface de.wagner_ibw.iow.SpecialModeFunction
SMF_CPS_ID, SMF_I2C_ID, SMF_LCD_ID, SMF_LED_ID, SMF_RC5_ID, SMF_SMX_ID, SMF_SPI_ID
 
Constructor Summary
I2C()
          Constructor
 
Method Summary
 void addI2CDevice(I2CDevice dev)
          Adds i2c device implementation (e.g. an instance of LM75.java).
 java.lang.String checkCompatibility(int id, int rev, int specialModes)
          Checks if it is possible to activate this special mode function.
 boolean equals(java.lang.Object o)
          Indicates whether some other I2C object is "equal to" this one.
 int[] getDisableReport()
          Returns the report that disables the special mode function.
 int[] getEnableReport()
          Returns the report that enables the special mode function.
 int[] getIow24SpecialBits()
           
 int[] getIow40SpecialBits()
           
 int[] getIowSpecialBits(int deviceIdentifier)
          Returns an array of bitmask(s) for port 0...1 or 0...3 if this special mode function runs on this iow device.
 java.lang.String getName()
          Returns the name of the special mode function.
 int[] getReportIds()
          Returns the report id(s) which the implementation is interested in.
 int getSpecialModeFuncionId()
          Returns the special mode function for this implementation.
 int hashCode()
          Returns a hash code value for this special mode function object.
 boolean matchReportId(int reportId)
          Checks if this implementation is interested in this report.
 void removeI2CDevice(I2CDevice dev)
          Removes i2c device implementation.
 void reportReceived(int[] readBuffer)
          Callback method is called when a matching report was received.
 void setIowDevice(AbstractIowDevcie iow)
          Sets the reference to an iow device for write report operations.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

static final java.lang.String name
Name of this special mode function.

See Also:
Constant Field Values

iow

private AbstractIowDevcie iow
Reference to the underlying IOW device.


devices

private java.util.Vector devices
Vector of i2c devices.

Constructor Detail

I2C

public I2C()
Constructor

Method Detail

addI2CDevice

public void addI2CDevice(I2CDevice dev)
                  throws java.lang.IllegalArgumentException
Adds i2c device implementation (e.g. an instance of LM75.java).

Parameters:
dev - Instance of an i2c device implemenation.
Throws:
java.lang.IllegalArgumentException - if the i2c slave address was already assigned.

removeI2CDevice

public void removeI2CDevice(I2CDevice dev)
Removes i2c device implementation.

Parameters:
dev - Instance of an i2c device implemenation.

equals

public boolean equals(java.lang.Object o)
Indicates whether some other I2C object is "equal to" this one. Criteria is the special mode function's name.

Overrides:
equals in class java.lang.Object
Returns:
True if this object is the same as the obj argument; false otherwise.
Since:
0.9.4

hashCode

public int hashCode()
Returns a hash code value for this special mode function object. It is derived from the special mode funtion's name.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.
Since:
0.9.4

toString

public java.lang.String toString()
Returns a string representation of the object. It consists of a list of added i2c devices.

Overrides:
toString in class java.lang.Object
Returns:
a string consisting of an i2c devices list.

getDisableReport

public int[] getDisableReport()
Description copied from interface: SpecialModeFunction
Returns the report that disables the special mode function.

Specified by:
getDisableReport in interface SpecialModeFunction
Returns:
Special mode function disable report.

getEnableReport

public int[] getEnableReport()
Description copied from interface: SpecialModeFunction
Returns the report that enables the special mode function.

Specified by:
getEnableReport in interface SpecialModeFunction
Returns:
Special mode function enable report.

getIowSpecialBits

public int[] getIowSpecialBits(int deviceIdentifier)
Description copied from interface: SpecialModeFunction
Returns an array of bitmask(s) for port 0...1 or 0...3 if this special mode function runs on this iow device. Returns a array of lenght zero if no bits used by this special mode function. 1 means this bit is dedicated by special mode function. 0 means this bit is free for normal pin io operations.

Specified by:
getIowSpecialBits in interface SpecialModeFunction
Parameters:
deviceIdentifier - Iow device identifier (AbstractIowDevcie.IOW24ID or AbstractIowDevcie.IOW40ID).
Returns:
Array of int that contains bitmask(s) for special mode function bits.

getIow24SpecialBits

public int[] getIow24SpecialBits()

getIow40SpecialBits

public int[] getIow40SpecialBits()

getReportIds

public int[] getReportIds()
Description copied from interface: SpecialModeFunction
Returns the report id(s) which the implementation is interested in.

Specified by:
getReportIds in interface SpecialModeFunction
Returns:
Int array of special mode function id(s).

getSpecialModeFuncionId

public int getSpecialModeFuncionId()
Description copied from interface: SpecialModeFunction
Returns the special mode function for this implementation.

Specified by:
getSpecialModeFuncionId in interface SpecialModeFunction
Returns:
Special mode function id (SMF_LCD_ID,SMF_RC5_ID,SMF_I2C_ID,SMF_CPS_ID,SMF_SPI_ID).

matchReportId

public boolean matchReportId(int reportId)
Description copied from interface: SpecialModeFunction
Checks if this implementation is interested in this report.

Specified by:
matchReportId in interface SpecialModeFunction
Parameters:
reportId - Report id of the received report.
Returns:
True if it fits or false if not.

reportReceived

public void reportReceived(int[] readBuffer)
Description copied from interface: SpecialModeFunction
Callback method is called when a matching report was received.

Specified by:
reportReceived in interface SpecialModeFunction
Parameters:
readBuffer - Read buffer from a received report.

setIowDevice

public void setIowDevice(AbstractIowDevcie iow)
Description copied from interface: SpecialModeFunction
Sets the reference to an iow device for write report operations.

Specified by:
setIowDevice in interface SpecialModeFunction
Parameters:
iow - Instance of an iow device.

checkCompatibility

public java.lang.String checkCompatibility(int id,
                                           int rev,
                                           int specialModes)
Description copied from interface: SpecialModeFunction
Checks if it is possible to activate this special mode function. This depends on id and/or rev of the iow device and/or already activated special mode functions.

Specified by:
checkCompatibility in interface SpecialModeFunction
Parameters:
id - Id of the current iow device.
rev - Rev of the current iow device.
specialModes - Special modes from the current iow device.
Returns:
Error string if special mode function is not available. Returns null if special mode function is available.

getName

public java.lang.String getName()
Description copied from interface: SpecialModeFunction
Returns the name of the special mode function.

Specified by:
getName in interface SpecialModeFunction
Returns:
Name of the special mode function.