Impact Acquire SDK Python
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

 __init__ (self, pDev)
 
 I2CRead (self, deviceAddress, deviceSubAddress, deviceSubAddressWidth, byteCnt)
 Read data from an I2C device.
 
 I2CWrite (self, deviceAddress, deviceSubAddress, deviceSubAddressWidth, data)
 Write data to a I2C device.
 

Properties

 I2CBuffer = property(lib_mvIMPACT_acquire.I2CControl_I2CBuffer_get, doc=)
 Defines the intermediate access buffer that allows the exchange of data between the I2C device and the application.
 
 I2CBufferLength = property(lib_mvIMPACT_acquire.I2CControl_I2CBufferLength_get, doc=)
 An integer property controlling the length of the mapping between the I2C device and the mvIMPACT.acquire.I2CControl.I2CBuffer property.
 
 I2CDeviceAddress = property(lib_mvIMPACT_acquire.I2CControl_I2CDeviceAddress_get, doc=)
 An integer property storing the address of the I2C device to communicate with.
 
 I2CDeviceSubAddress = property(lib_mvIMPACT_acquire.I2CControl_I2CDeviceSubAddress_get, doc=)
 An integer property storing the sub-address of the I2C device to communicate with.
 
 I2CDeviceSubAddressWidth = property(lib_mvIMPACT_acquire.I2CControl_I2CDeviceSubAddressWidth_get, doc=)
 An enumerated integer property storing the sub-address width(in bits) of the I2C device to communicate with.
 
 I2COperationExecute = property(lib_mvIMPACT_acquire.I2CControl_I2COperationExecute_get, doc=)
 Calling this function will execute the operation selected by mvIMPACT.acquire.I2CControl.I2COperationMode.
 
 I2COperationMode = property(lib_mvIMPACT_acquire.I2CControl_I2COperationMode_get, doc=)
 An enumerated integer property to select the I2C operation.
 
 I2COperationStatus = property(lib_mvIMPACT_acquire.I2CControl_I2COperationStatus_get, doc=)
 Represents the I2C operation execution status.
 
 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 

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
i2cc = acquire.I2CControl(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(acquire.I2ComRead)
assert i2cc.I2COperationExecute.call() == acquire.DMR_INVALID_PARAMETER, "Unexpected driver behaviour"
assert i2cc.I2COperationStatus.read() == acquire.I2CosNotEnoughData, "Unexpected driver behaviour"
i2cc.I2CBufferLength.write(1)
# assuming we write to an invalid address
assert i2cc.I2COperationExecute.call() == acquire.DMR_EXECUTION_FAILED, "Unexpected driver behaviour"
assert i2cc.I2COperationStatus.read() == acquire.I2CosFailure, "Unexpected driver behaviour"
i2cc.I2COperationMode.write(acquire.I2ComWrite)
pBuf = '\x41\x42' # 'A' and 'B'
i2cc.I2CBuffer.writeBinary(pBuf)
# assuming we write to an invalid address
assert i2cc.I2COperationExecute.call() == acquire.DMR_EXECUTION_FAILED, "Unexpected driver behaviour"
assert i2cc.I2COperationStatus.read() == acquire.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)
pBuf = '\x44\x45\x41\x44\x20\x42\x45\x45\x46' # The good old 'DEAD BEEF' in HEX notation
i2cc.I2CBuffer.writeBinary(pBuf)
i2cc.I2COperationMode.write(acquire.I2ComWrite)
I2COperationExecuteResult = i2cc.I2COperationExecute.call()
if I2COperationExecuteResult != acquire.DMR_NO_ERROR:
print("'I2COperationExecute' write failed. Return value: {0}({1}).".format(acquire.ImpactAcquireException.getErrorCodeAsString(I2COperationExecuteResult), I2COperationExecuteResult))
print("'I2COperationStatus' after write: {0}.".format(i2cc.I2COperationStatus.readS()))
# Read some data. Similar condition as for write apply
bytesToRead = 4
i2cc.I2CDeviceAddress.write(0xA8)
i2cc.I2CDeviceSubAddress.write(0x00)
i2cc.I2CDeviceSubAddressWidth.write(8)
i2cc.I2CBufferLength.write(bytesToRead) # read 'bytesToRead' bytes
i2cc.I2COperationMode.write(acquire.I2ComRead)
i2cc.I2COperationExecute.call()
I2COperationExecuteResult = i2cc.I2COperationExecute.call()
if I2COperationExecuteResult != acquire.DMR_NO_ERROR:
System.out.println(String.format("'I2COperationExecute' read failed. Return value: %s(%d).", ImpactAcquireException.getErrorCodeAsString(I2COperationExecuteResult), I2COperationExecuteResult))
print("'I2COperationStatus' after read: {0}.".format(i2cc.I2COperationStatus.readS()))
if i2cc.I2CBuffer.binaryDataBufferSize() != bytesToRead:
print("'I2CBuffer' reports {0} bytes of data while {1} bytes where expected.".format(i2cc.I2CBuffer.binaryDataBufferSize(), bytesToRead))
# usage of the convenience functions
i2cc.I2CWrite(0xA4, 0x00, 8, "TEST")
i2cReadBuffer = i2cc.I2CRead(0xA4, 0x00, 8, 4)
else:
print("I2CControl not available.")
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

◆ __init__()

__init__ ( self,
pDev )

Reimplemented from ComponentCollection.

Member Function Documentation

◆ I2CRead()

I2CRead ( self,
deviceAddress,
deviceSubAddress,
deviceSubAddressWidth,
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.I2COperationStatus 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()

I2CWrite ( self,
deviceAddress,
deviceSubAddress,
deviceSubAddressWidth,
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.I2COperationStatus 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.

Property Documentation

◆ I2CBuffer

I2CBuffer = property(lib_mvIMPACT_acquire.I2CControl_I2CBuffer_get, doc=)
static

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

I2CBufferLength = property(lib_mvIMPACT_acquire.I2CControl_I2CBufferLength_get, doc=)
static

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

◆ I2CDeviceAddress

I2CDeviceAddress = property(lib_mvIMPACT_acquire.I2CControl_I2CDeviceAddress_get, doc=)
static

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

◆ I2CDeviceSubAddress

I2CDeviceSubAddress = property(lib_mvIMPACT_acquire.I2CControl_I2CDeviceSubAddress_get, doc=)
static

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

I2CDeviceSubAddressWidth = property(lib_mvIMPACT_acquire.I2CControl_I2CDeviceSubAddressWidth_get, doc=)
static

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

I2COperationExecute = property(lib_mvIMPACT_acquire.I2CControl_I2COperationExecute_get, doc=)
static

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

◆ I2COperationMode

I2COperationMode = property(lib_mvIMPACT_acquire.I2CControl_I2COperationMode_get, doc=)
static

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 may be: mvIMPACT.acquire.I2ComRead, mvIMPACT.acquire.I2ComWrite.

◆ I2COperationStatus

I2COperationStatus = property(lib_mvIMPACT_acquire.I2CControl_I2COperationStatus_get, doc=)
static

◆ thisown

thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
static