de.wagner_ibw.iow.spi
Class SPI

java.lang.Object
  |
  +--de.wagner_ibw.iow.spi.SPI
All Implemented Interfaces:
SpecialModeFunction

public class SPI
extends java.lang.Object
implements SpecialModeFunction

Implementation of the SPI special mode function.

Author:
Thomas Wagner

Field Summary
 
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
SPI(int mode)
          Constructor for IO-Warrior 24.
SPI(int mode, int clock)
          Constructor for IO-Warrior 56.
 
Method Summary
 java.lang.String checkCompatibility(int id, int Revision, int specialModes)
          Checks if it is possible to activate this special mode function.
 int[] getDisableReport()
          Returns the report that disables the special mode function.
 int[] getEnableReport()
          Returns the report that enables the special mode function.
 int[] getIowSpecialBits(int deviceIdentifier)
          Returns an array of bitmask(s) for port 0...1, 0...3 or 0...6 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 id for this implementation.
 boolean matchReportId(int reportId)
          Checks if this implementation is interested in this report.
 void removeSPIDevice()
          Removes the spi device implementation.
 void reportReceived(int[] readBuffer)
          Callback method is called when a matching report was received.
 void setIowDevice(AbstractIowDevice iow)
          Sets the reference to the underlying iow device for write report operations.
 void setSPIDevice(AbstractSPIDevice dev)
          Adds the spi device implementation (e.g. an instance of M95020.java).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SPI

public SPI(int mode)
Constructor for IO-Warrior 24.

Parameters:
mode - SPI special mode function mode byte.

SPI

public SPI(int mode,
           int clock)
Constructor for IO-Warrior 56.

Parameters:
mode - SPI special mode function mode byte.
clock - SPI sepcial mode function clock byte.
Since:
0.9.5
Method Detail

setSPIDevice

public void setSPIDevice(AbstractSPIDevice dev)
Adds the spi device implementation (e.g. an instance of M95020.java).

Parameters:
dev - Instance of an spi device implemenation.

removeSPIDevice

public void removeSPIDevice()
Removes the spi device implementation.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

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, 0...3 or 0...6 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 (AbstractIowDevice.IOW24ID<(code>, AbstractIowDevice.IOW24ID or AbstractIowDevice.IOW56ID).
Returns:
Array of int that contains bitmask(s) for special mode function bits.

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 id 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(AbstractIowDevice iow)
Description copied from interface: SpecialModeFunction
Sets the reference to the underlying 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 Revision,
                                           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 IO-Warrior device.
Revision - Rev of the current IO-Warrior device.
specialModes - Special modes from the current IO-Warrior 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.