Impact Acquire SDK C++
I2CControl Class Reference

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

#include <mvIMPACT_acquire.h>

Inheritance diagram for I2CControl:
[legend]

Public Member Functions

HOBJ hObj (void) const
 Returns a unique identifier for the component collection referenced by this object.
 
 I2CControl (Device *pDev)
 brief Constructs a new mvIMPACT::acquire::I2CControl object.
 
std::string I2CRead (int deviceAddress, int deviceSubAddress, int deviceSubAddressWidth, int byteCnt)
 Read data from an I2C device.
 
void I2CWrite (int deviceAddress, int deviceSubAddress, int deviceSubAddressWidth, const std::string &data)
 Write data to a I2C device.
 
const ComponentCollectionrestoreDefault (void) const
 Restores the default for every component of this collection.
 

Public Attributes

PropertyS I2CBuffer
 Defines the intermediate access buffer that allows the exchange of data between the I2C device and the application.
 
PropertyI I2CBufferLength
 An integer property controlling the length of the mapping between the I2C device and the mvIMPACT::acquire::I2CControl::I2CBuffer property.
 
PropertyI I2CDeviceAddress
 An integer property storing the address of the I2C device to communicate with.
 
PropertyI I2CDeviceSubAddress
 An integer property storing the sub-address of the I2C device to communicate with.
 
PropertyI I2CDeviceSubAddressWidth
 An enumerated integer property storing the sub-address width(in bits) of the I2C device to communicate with.
 
Method I2COperationExecute
 Calling this function will execute the operation selected by mvIMPACT::acquire::I2CControl::I2COperationMode.
 
PropertyII2COperationMode I2COperationMode
 An enumerated integer property to select the I2C operation.
 
PropertyII2COperationStatus I2COperationStatus
 Represents the I2C operation execution status.
 

Protected Attributes

HOBJ m_hRoot
 

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
I2CControl i2cc( pBF ); // assuming 'pBF' to be a valid 'Device*' instance to an mvBlueFOX device
if( i2cc.I2COperationMode.isValid() )
{
// direct property access
i2cc.I2CBufferLength.write( 0 );
i2cc.I2COperationMode.write( I2ComRead );
assert( ( i2cc.I2COperationExecute.call() == DMR_INVALID_PARAMETER ) && "Unexpected driver behaviour" );
assert( ( i2cc.I2COperationStatus.read() == I2CosNotEnoughData ) && "Unexpected driver behaviour" );
i2cc.I2CBufferLength.write( 1 );
// assuming we write to an invalid address
assert( ( i2cc.I2COperationExecute.call() == DMR_EXECUTION_FAILED ) && "Unexpected driver behaviour" );
assert( ( i2cc.I2COperationStatus.read() == I2CosFailure ) && "Unexpected driver behaviour" );
i2cc.I2COperationMode.write( I2ComWrite );
i2cc.I2CBuffer.writeBinary( string() );
assert( ( i2cc.I2COperationExecute.call() == DMR_INVALID_PARAMETER ) && "Unexpected driver behaviour" );
assert( ( i2cc.I2COperationStatus.read() == I2CosNotEnoughData ) && "Unexpected driver behaviour" );
{
char binData[2] = { 'A', 'B' };
i2cc.I2CBuffer.writeBinary( string(binData, sizeof(binData)) );
}
// assuming we write to an invalid address
assert( ( i2cc.I2COperationExecute.call() == DMR_EXECUTION_FAILED ) && "Unexpected driver behaviour" );
assert( ( i2cc.I2COperationStatus.read() == 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.I2CDeviceAddress.write( 0xA6 );
i2cc.I2CDeviceSubAddress.write( 0x04 );
i2cc.I2CDeviceSubAddressWidth.write( 8 );
{
char binData[9] = { 'D', 'E', 'A', 'D', ' ', 'B', 'E', 'E', 'F' };
i2cc.I2CBuffer.writeBinary( string( binData, sizeof( binData ) ) );
}
i2cc.I2COperationMode.write( I2ComWrite );
int I2COperationExecuteResult = i2cc.I2COperationExecute.call();
if( I2COperationExecuteResult != DMR_NO_ERROR )
{
printf( "'I2COperationExecute' write failed. Return value: %s(%d).\n", ImpactAcquireException::getErrorCodeAsString( I2COperationExecuteResult ).c_str(), I2COperationExecuteResult );
}
printf( "'I2COperationStatus' after write: %s.\n", i2cc.I2COperationStatus.readS().c_str() );
// Read some data. Similar condition as for write apply
const int bytesToRead = 4;
i2cc.I2CDeviceAddress.write( 0xA8 );
i2cc.I2CDeviceSubAddress.write( 0x00 );
i2cc.I2CDeviceSubAddressWidth.write( 8 );
i2cc.I2CBufferLength.write( bytesToRead ); // read 'bytesToRead' bytes
i2cc.I2COperationMode.write( I2ComRead );
i2cc.I2COperationExecute.call();
I2COperationExecuteResult = i2cc.I2COperationExecute.call();
if( I2COperationExecuteResult != DMR_NO_ERROR )
{
printf( "'I2COperationExecute' read failed. Return value: %s(%d).\n", ImpactAcquireException::getErrorCodeAsString( I2COperationExecuteResult ).c_str(), I2COperationExecuteResult );
}
printf( "'I2COperationStatus' after read: %s.\n", i2cc.I2COperationStatus.readS().c_str() );
if( i2cc.I2CBuffer.binaryDataBufferSize() != bytesToRead )
{
printf( "'I2CBuffer' reports %d bytes of data while %d bytes where expected.\n", i2cc.I2CBuffer.binaryDataBufferSize(), bytesToRead );
}
// usage of the convenience functions
i2cc.I2CWrite( 0xA4, 0x00, 8, string("TEST") );
const string i2cReadBuffer = i2cc.I2CRead( 0xA4, 0x00, 8, 4 );
}
else
{
printf( "I2CControl not available.\n" );
}
Properties for accessing features belonging to the I2C control(Device specific interface layout only)...
Definition mvIMPACT_acquire.h:22381
std::string getErrorCodeAsString(void) const
Returns a string representation of the error associated with the exception.
Definition mvIMPACT_acquire.h:288
@ DMR_INVALID_PARAMETER
An invalid parameter has been passed to a function.
Definition mvDriverBaseEnums.h:2659
@ DMR_NO_ERROR
The function call was executed successfully.
Definition mvDriverBaseEnums.h:2603
@ DMR_EXECUTION_FAILED
The execution of a method object or reading/writing to a feature failed.
Definition mvDriverBaseEnums.h:2816
@ I2CosNotEnoughData
During the execution of the last I2C operation the amount of data requested or sent was too small.
Definition mvDriverBaseEnums.h:3124
@ I2CosFailure
The last I2C operation did fail. The log-file might contain additional information.
Definition mvDriverBaseEnums.h:3113
@ I2ComWrite
Selects I2C write access.
Definition mvDriverBaseEnums.h:3101
@ I2ComRead
Selects I2C read access.
Definition mvDriverBaseEnums.h:3099
Note
This class will only be available if mvIMPACT::acquire::Device::interfaceLayout is set to mvIMPACT::acquire::dilDeviceSpecific before the device is opened.

Constructor & Destructor Documentation

◆ I2CControl()

I2CControl ( Device * pDev)
inlineexplicit

brief Constructs a new mvIMPACT::acquire::I2CControl object.

Parameters
[in]pDevA pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object.

Member Function Documentation

◆ hObj()

HOBJ hObj ( void ) const
inlineinherited

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()

std::string I2CRead ( int deviceAddress,
int deviceSubAddress,
int deviceSubAddressWidth,
int byteCnt )
inline

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::I2COperationStatus should be checked afterwards.

Parameters
[in]deviceAddressThe address of the I2C device to communicate with.
[in]deviceSubAddressThe sub-address of the I2C device to communicate with.
[in]deviceSubAddressWidthThe sub-address width(in bits) of the I2C device to communicate with.
[in]byteCntThe amount of bytes to read.

◆ I2CWrite()

void I2CWrite ( int deviceAddress,
int deviceSubAddress,
int deviceSubAddressWidth,
const std::string & data )
inline

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::I2COperationStatus should be checked afterwards.

Parameters
[in]deviceAddressThe address of the I2C device to communicate with.
[in]deviceSubAddressThe sub-address of the I2C device to communicate with.
[in]deviceSubAddressWidthThe sub-address width(in bits) of the I2C device to communicate with.
[in]dataThe data to write to the I2C device.

◆ restoreDefault()

const ComponentCollection & restoreDefault ( void ) const
inlineinherited

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.

Member Data Documentation

◆ I2CBuffer

PropertyS I2CBuffer

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

This property can store binary data.

◆ I2CBufferLength

PropertyI I2CBufferLength

An integer property controlling the length of the mapping between the I2C device and the mvIMPACT::acquire::I2CControl::I2CBuffer property.

◆ I2CDeviceAddress

PropertyI I2CDeviceAddress

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

◆ I2CDeviceSubAddress

PropertyI I2CDeviceSubAddress

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

When mvIMPACT::acquire::I2CControl::I2CDeviceSubAddressWidth is set to 0, this property will be ignored.

◆ I2CDeviceSubAddressWidth

PropertyI I2CDeviceSubAddressWidth

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.

◆ I2COperationExecute

Method I2COperationExecute

Calling this function will execute the operation selected by mvIMPACT::acquire::I2CControl::I2COperationMode.

◆ I2COperationMode

PropertyII2COperationMode I2COperationMode

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.

◆ I2COperationStatus

PropertyII2COperationStatus I2COperationStatus

Represents the I2C operation execution status.

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

◆ m_hRoot

HOBJ m_hRoot
protectedinherited