Impact Acquire SDK Java
I2CControl Class Reference

Properties for accessing features belonging to the I2C control(Device specific interface layout only). More...

Inheritance diagram for I2CControl:
[legend]

Public Member Functions

synchronized void delete ()
 
PropertyS getI2CBuffer ()
 Defines the intermediate access buffer that allows the exchange of data between the I2C device and the application.
 
PropertyI getI2CBufferLength ()
 An integer property controlling the length of the mapping between the I2C device and the mvIMPACT.acquire.I2CControl.getI2CBuffer() property.
 
PropertyI getI2CDeviceAddress ()
 An integer property storing the address of the I2C device to communicate with.
 
PropertyI getI2CDeviceSubAddress ()
 An integer property storing the sub-address of the I2C device to communicate with.
 
PropertyI getI2CDeviceSubAddressWidth ()
 An enumerated integer property storing the sub-address width(in bits) of the I2C device to communicate with.
 
Method getI2COperationExecute ()
 Calling this function will execute the operation selected by mvIMPACT.acquire.I2CControl.getI2COperationMode().
 
PropertyI getI2COperationMode ()
 An enumerated integer property to select the I2C operation.
 
PropertyI getI2COperationStatus ()
 Represents the I2C operation execution status.
 
int hObj ()
 Returns a unique identifier for the component collection referenced by this object.
 
 I2CControl (Device pDev)
 brief Constructs a new mvIMPACT.acquire.I2CControl object.
 
String I2CRead (int deviceAddress, int deviceSubAddress, int deviceSubAddressWidth, int byteCnt)
 Read data from an I2C device.
 
void I2CWrite (int deviceAddress, int deviceSubAddress, int deviceSubAddressWidth, String data)
 Write data to a I2C device.
 
ComponentCollection restoreDefault ()
 Restores the default for every component of this collection.
 

Protected Member Functions

void finalize ()
 
 I2CControl (long cPtr, boolean cMemoryOwn)
 

Static Protected Member Functions

static long swigRelease (ComponentCollection obj)
 
static long swigRelease (I2CControl obj)
 

Protected Attributes

transient boolean swigCMemOwn
 

Detailed Description

Properties for accessing features belonging to the I2C control(Device specific interface layout only).

Properties in this class will only be available if a device has a local I2C bus and this is configured for access from an application. Right now this is only the case for mvBlueFOX-MLC devices.

mvBlueFOX specific:

For mvBlueFOX devices

  • clock stretching is supported
  • bus master is supported

The following I2C addresses will be blocked for access from an application:

i2c address rangeaffected devices
0x20-0x3Fall mvBlueFOX devices
0x66-0x67all mvBlueFOX devices
0x90-0x91mvBlueFOX-200w only
0xA0-0xA3all mvBlueFOX devices
0xA6-0xA7all mvBlueFOX devices
0xBA-0xBBmvBlueFOX-202a and mvBlueFOX-205 only
import java.nio.ByteBuffer; // needed for binary data exchange!
// more code and a class definition must follow here...
I2CControl i2cc = new I2CControl( pDev ); // assuming 'pBF' to be a valid 'Device*' instance to an mvBlueFOX device
{
// direct property access
assert i2cc.getI2COperationExecute().call() == TDMR_ERROR.DMR_INVALID_PARAMETER : "Unexpected driver behaviour";
assert i2cc.getI2COperationStatus().read() == TI2COperationStatus.I2CosNotEnoughData : "Unexpected driver behaviour";
// assuming we write to an invalid address
assert i2cc.getI2COperationExecute().call() == TDMR_ERROR.DMR_EXECUTION_FAILED : "Unexpected driver behaviour";
assert i2cc.getI2COperationStatus().read() == TI2COperationStatus.I2CosFailure : "Unexpected driver behaviour";
{
final int BUF_SIZE = 2;
byte[] data_bytes = new byte[BUF_SIZE];
data_bytes[0] = 'A';
data_bytes[1] = 'B';
ByteBuffer data = ByteBuffer.allocateDirect( BUF_SIZE );
data.put( data_bytes );
i2cc.getI2CBuffer().writeBinary( data );
}
// assuming we write to an invalid address
assert i2cc.getI2COperationExecute().call() == TDMR_ERROR.DMR_EXECUTION_FAILED : "Unexpected driver behaviour";
assert i2cc.getI2COperationStatus().read() == TI2COperationStatus.I2CosFailure : "Unexpected driver behaviour";
// Write some data. This will only work if several conditions are met:
// - there is a device that can be written to at address 0xA6
// - the sub-address 0x04 is valid
// - the device is designed to work with 8 bit sub-addresses
// - the device can deal with 9 bytes in a single command
i2cc.getI2CDeviceAddress().write( 0xA6 );
i2cc.getI2CDeviceSubAddress().write( 0x04 );
{
final int BUF_SIZE = 9;
byte[] data_bytes = new byte[BUF_SIZE];
data_bytes[0] = 'D';
data_bytes[0] = 'E';
data_bytes[0] = 'A';
data_bytes[0] = 'D';
data_bytes[0] = ' ';
data_bytes[0] = 'B';
data_bytes[0] = 'E';
data_bytes[0] = 'E';
data_bytes[0] = 'F';
ByteBuffer data = ByteBuffer.allocateDirect( BUF_SIZE );
data.put( data_bytes );
i2cc.getI2CBuffer().writeBinary( data );
}
i2cc.getI2COperationMode().write( TI2COperationMode.I2ComWrite );
int I2COperationExecuteResult = i2cc.getI2COperationExecute().call();
if( I2COperationExecuteResult != TDMR_ERROR.DMR_NO_ERROR )
{
System.out.println( String.format( "'I2COperationExecute' write failed. Return value: %s(%d).", ImpactAcquireException.getErrorCodeAsString( I2COperationExecuteResult ), I2COperationExecuteResult ) );
}
System.out.println( String.format( "'I2COperationStatus' after write: %s.", i2cc.getI2COperationStatus().readS() ) );
// Read some data. Similar condition as for write apply
final int bytesToRead = 4;
i2cc.getI2CDeviceAddress().write( 0xA8 );
i2cc.getI2CDeviceSubAddress().write( 0x00 );
i2cc.getI2CBufferLength().write( bytesToRead ); // read 'bytesToRead' bytes
i2cc.getI2COperationMode().write( TI2COperationMode.I2ComRead );
I2COperationExecuteResult = i2cc.getI2COperationExecute().call();
if( I2COperationExecuteResult != TDMR_ERROR.DMR_NO_ERROR )
{
System.out.println( String.format( "'I2COperationExecute' read failed. Return value: %s(%d).", ImpactAcquireException.getErrorCodeAsString( I2COperationExecuteResult ), I2COperationExecuteResult ) );
}
System.out.println( String.format( "'I2COperationStatus' after read: %s.", i2cc.getI2COperationStatus().readS() ) );
if( i2cc.getI2CBuffer().binaryDataBufferSize() != bytesToRead )
{
System.out.println( String.format( "'I2CBuffer' reports %d bytes of data while %d bytes where expected.", i2cc.getI2CBuffer().binaryDataBufferSize(), bytesToRead ) );
}
// usage of the convenience functions
i2cc.I2CWrite( 0xA4, 0x00, 8, "TEST" );
final String i2cReadBuffer = i2cc.I2CRead( 0xA4, 0x00, 8, 4 );
}
else
{
System.out.println( "I2CControl not available." );
}
boolean isValid()
Checks if the internal component referenced by this object is still valid.
Definition Component.java:418
Properties for accessing features belonging to the I2C control(Device specific interface layout only)...
Definition I2CControl.java:255
void I2CWrite(int deviceAddress, int deviceSubAddress, int deviceSubAddressWidth, String data)
Write data to a I2C device.
Definition I2CControl.java:400
PropertyI getI2CBufferLength()
An integer property controlling the length of the mapping between the I2C device and the mvIMPACT....
Definition I2CControl.java:369
String I2CRead(int deviceAddress, int deviceSubAddress, int deviceSubAddressWidth, int byteCnt)
Read data from an I2C device.
Definition I2CControl.java:385
Method getI2COperationExecute()
Calling this function will execute the operation selected by mvIMPACT.acquire.I2CControl....
Definition I2CControl.java:314
PropertyI getI2CDeviceSubAddressWidth()
An enumerated integer property storing the sub-address width(in bits) of the I2C device to communicat...
Definition I2CControl.java:345
PropertyI getI2COperationStatus()
Represents the I2C operation execution status.
Definition I2CControl.java:323
PropertyI getI2CDeviceSubAddress()
An integer property storing the sub-address of the I2C device to communicate with.
Definition I2CControl.java:354
PropertyI getI2CDeviceAddress()
An integer property storing the address of the I2C device to communicate with.
Definition I2CControl.java:329
PropertyS getI2CBuffer()
Defines the intermediate access buffer that allows the exchange of data between the I2C device and th...
Definition I2CControl.java:363
PropertyI getI2COperationMode()
An enumerated integer property to select the I2C operation.
Definition I2CControl.java:308
int call(StringVector params)
Calls an underlying driver function.
Definition Method.java:129
PropertyI write(int value, int index)
Writes one value to the property.
Definition PropertyI.java:350
int read(int index)
Reads a value from a property.
Definition PropertyI.java:198
void writeBinary(java.nio.ByteBuffer pBuf, int index)
Writes a block of binary data to one entry of the property.
Definition PropertyS.java:401
long binaryDataBufferSize(int index)
Returns the size(in bytes) needed for the binary representation of the string buffer.
Definition PropertyS.java:88
String readS(int index, String format)
Reads data from this property as a string.
Definition Property.java:293
Valid I2C operation modes.
Definition TI2COperationMode.java:15
static final int I2ComWrite
Selects I2C write access.
Definition TI2COperationMode.java:19
static final int I2ComRead
Selects I2C read access.
Definition TI2COperationMode.java:17
Note
This class will only be available if mvIMPACT.acquire.Device.getInterfaceLayout() is set to mvIMPACT.acquire.TDeviceInterfaceLayout.dilDeviceSpecific before the device is opened.

Constructor & Destructor Documentation

◆ I2CControl() [1/2]

I2CControl ( long cPtr,
boolean cMemoryOwn )
protected

◆ I2CControl() [2/2]

I2CControl ( Device pDev)

brief Constructs a new mvIMPACT.acquire.I2CControl object.

Parameters
pDev[in] A pointer to a mvIMPACT.acquire.Device object obtained from a mvIMPACT.acquire.DeviceManager object.

Member Function Documentation

◆ delete()

synchronized void delete ( )

Reimplemented from ComponentCollection.

◆ finalize()

void finalize ( )
protected

Reimplemented from ComponentCollection.

◆ getI2CBuffer()

PropertyS getI2CBuffer ( )

Defines the intermediate access buffer that allows the exchange of data between the I2C device and the application.

This property can store binary data.

◆ getI2CBufferLength()

PropertyI getI2CBufferLength ( )

An integer property controlling the length of the mapping between the I2C device and the mvIMPACT.acquire.I2CControl.getI2CBuffer() property.

◆ getI2CDeviceAddress()

PropertyI getI2CDeviceAddress ( )

An integer property storing the address of the I2C device to communicate with.

◆ getI2CDeviceSubAddress()

PropertyI getI2CDeviceSubAddress ( )

An integer property storing the sub-address of the I2C device to communicate with.

When mvIMPACT.acquire.I2CControl.getI2CDeviceSubAddressWidth() is set to 0, this property will be ignored.

◆ getI2CDeviceSubAddressWidth()

PropertyI getI2CDeviceSubAddressWidth ( )

An enumerated integer property storing the sub-address width(in bits) of the I2C device to communicate with.

Valid values for this property are:

  • 0
  • 8
  • 16
Note
This property must be set to 0 for devices not supporting a sub-address.

◆ getI2COperationExecute()

Method getI2COperationExecute ( )

Calling this function will execute the operation selected by mvIMPACT.acquire.I2CControl.getI2COperationMode().

◆ getI2COperationMode()

PropertyI getI2COperationMode ( )

An enumerated integer property to select the I2C operation.

The selected operation is executed when mvIMPACT.acquire.I2CControl.I2COperationExecute is called.

Valid values for this property are defined by the enumeration mvIMPACT.acquire.TI2COperationMode.

◆ getI2COperationStatus()

PropertyI getI2COperationStatus ( )

Represents the I2C operation execution status.

Valid values for this property are defined by the enumeration mvIMPACT.acquire.TI2COperationStatus.

◆ hObj()

int hObj ( )
inherited

Returns a unique identifier for the component collection referenced by this object.

This handle will always reference an object of type mvIMPACT.acquire.ComponentList.

Returns
A unique identifier for the component referenced by this object.

◆ I2CRead()

String I2CRead ( int deviceAddress,
int deviceSubAddress,
int deviceSubAddressWidth,
int byteCnt )

Read data from an I2C device.

This is a convenience function that wraps the property access a little. In order to find out if the command has been executed successfully mvIMPACT.acquire.I2CControl.getI2COperationStatus() should be checked afterwards.

Parameters
deviceAddress[in] The address of the I2C device to communicate with.
deviceSubAddress[in] The sub-address of the I2C device to communicate with.
deviceSubAddressWidth[in] The sub-address width(in bits) of the I2C device to communicate with.
byteCnt[in] The amount of bytes to read.

◆ I2CWrite()

void I2CWrite ( int deviceAddress,
int deviceSubAddress,
int deviceSubAddressWidth,
String data )

Write data to a I2C device.

This is a convenience function that wraps the property access a little. In order to find out if the command has been executed successfully mvIMPACT.acquire.I2CControl.getI2COperationStatus() should be checked afterwards.

Parameters
deviceAddress[in] The address of the I2C device to communicate with.
deviceSubAddress[in] The sub-address of the I2C device to communicate with.
deviceSubAddressWidth[in] The sub-address width(in bits) of the I2C device to communicate with.
data[in] The data to write to the I2C device.

◆ restoreDefault()

ComponentCollection restoreDefault ( )
inherited

Restores the default for every component of this collection.

Calling this function will restore the default value for every component belonging to this collection.

Note
The caller must have the right to modify the component. Otherwise an exception will be thrown.
Returns
A const reference to the component.

◆ swigRelease() [1/2]

static long swigRelease ( ComponentCollection obj)
staticprotectedinherited

◆ swigRelease() [2/2]

static long swigRelease ( I2CControl obj)
staticprotected

Member Data Documentation

◆ swigCMemOwn

transient boolean swigCMemOwn
protectedinherited