lejos.nxt
Interface I2CPort

All Superinterfaces:
BasicSensorPort, SensorConstants
All Known Implementing Classes:
RemoteSensorPort, SensorPort

public interface I2CPort
extends BasicSensorPort

Abstraction for a port that supports I2C sensors.

Author:
Lawrie Griffiths

Field Summary
static int ALWAYS_ACTIVE
           
static int LEGO_MODE
           
static int STANDARD_MODE
           
 
Fields inherited from interface lejos.nxt.SensorConstants
MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, TYPE_ANGLE, TYPE_CUSTOM, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE
 
Method Summary
 int i2cBusy()
          Check to see if the device is busy
 int i2cComplete(byte[] buffer, int numBytes)
          Complete the i2c transaction, and read any returned data.
 void i2cDisable()
          Disable the device.
 void i2cEnable(int mode)
          Enable the low level device
 int i2cStart(int address, int internalAddress, int numInternalBytes, byte[] buffer, int numBytes, int transferType)
          Start an i2c transaction.
 
Methods inherited from interface lejos.nxt.BasicSensorPort
getMode, getType, setMode, setType, setTypeAndMode
 

Field Detail

STANDARD_MODE

static final int STANDARD_MODE
See Also:
Constant Field Values

LEGO_MODE

static final int LEGO_MODE
See Also:
Constant Field Values

ALWAYS_ACTIVE

static final int ALWAYS_ACTIVE
See Also:
Constant Field Values
Method Detail

i2cEnable

void i2cEnable(int mode)
Enable the low level device

Parameters:
mode - One or more of the mode bits above.

i2cDisable

void i2cDisable()
Disable the device.


i2cBusy

int i2cBusy()
Check to see if the device is busy

Returns:
1 if busy 0 if idle

i2cStart

int i2cStart(int address,
             int internalAddress,
             int numInternalBytes,
             byte[] buffer,
             int numBytes,
             int transferType)
Start an i2c transaction.

Parameters:
address - The i2C address (note this is a 7 bit address)
internalAddress - The internal register address
numInternalBytes - The number of bytes in the internal address
buffer - The data to write to the device (null for reads)
numBytes - The number of bytes to transfer
transferType - 0 == read 1 == write
Returns:
0: no error -1: Invalid device -2: Device busy -4: Buffer size error. -5: Invalid register address size.

i2cComplete

int i2cComplete(byte[] buffer,
                int numBytes)
Complete the i2c transaction, and read any returned data.

Parameters:
buffer - The buffer for a read (null for write)
numBytes - Number of bytes to transfer
Returns:
>= 0 number of bytes returned -1: Invalid device -2: Device busy -3: I2C error -4: Buffer size error.