Class PvDeviceI2CBus
Provides I2C bus communication interface for device serial ports.
Implements
Inherited Members
Namespace: eBUSDotNetReceive
Assembly: eBUSDotNetReceive.dll
Syntax
public class PvDeviceI2CBus : IDisposable
Remarks
This class enables I2C protocol communication through a device's serial port, supporting various transfer modes including burst read/write and master transmit/receive.
Constructors
View SourcePvDeviceI2CBus()
Constructor.
Declaration
public PvDeviceI2CBus()
Fields
View SourceswigCMemOwn
Determines who is responsible for deleting the underlying C++ object.
Declaration
protected bool swigCMemOwn
Field Value
| Type | Description |
|---|---|
| bool |
Properties
View SourceIsOpened
Gets whether the I2C bus is currently opened.
Declaration
public bool IsOpened { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
View SourceBurstRead(byte, byte[], uint, out uint)
Performs a burst read operation from an I2C slave device.
Declaration
public PvResult BurstRead(byte aSlaveAddress, byte[] aBuffer, uint aBufferSize, out uint aBytesRead)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte[] | aBuffer | Buffer to receive the read data. |
| uint | aBufferSize | Maximum number of bytes to read. |
| uint | aBytesRead | Number of bytes actually read. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
BurstRead(byte, byte[], uint, out uint, bool)
Performs a burst read operation from an I2C slave device.
Declaration
public PvResult BurstRead(byte aSlaveAddress, byte[] aBuffer, uint aBufferSize, out uint aBytesRead, bool aFastMode)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte[] | aBuffer | Buffer to receive the read data. |
| uint | aBufferSize | Maximum number of bytes to read. |
| uint | aBytesRead | Number of bytes actually read. |
| bool | aFastMode | If true, use fast mode (400 kHz), otherwise standard mode (100 kHz). Default is true. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
BurstWrite(byte, byte[], uint)
Performs a burst write operation to an I2C slave device.
Declaration
public PvResult BurstWrite(byte aSlaveAddress, byte[] aBuffer, uint aBufferSize)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte[] | aBuffer | Buffer containing data to write. |
| uint | aBufferSize | Number of bytes to write. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
BurstWrite(byte, byte[], uint, bool)
Performs a burst write operation to an I2C slave device.
Declaration
public PvResult BurstWrite(byte aSlaveAddress, byte[] aBuffer, uint aBufferSize, bool aFastMode)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte[] | aBuffer | Buffer containing data to write. |
| uint | aBufferSize | Number of bytes to write. |
| bool | aFastMode | If true, use fast mode (400 kHz), otherwise standard mode (100 kHz). Default is true. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
Close()
Closes the I2C bus connection.
Declaration
public PvResult Close()
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
Dispose()
Dispose.
Declaration
public void Dispose()
Dispose(bool)
Dispose
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing |
~PvDeviceI2CBus()
Destructor.
Declaration
protected ~PvDeviceI2CBus()
IndirectBurstRead(byte, byte, byte[], uint, out uint)
Performs an indirect burst read operation with offset addressing.
Declaration
public PvResult IndirectBurstRead(byte aSlaveAddress, byte aOffset, byte[] aBuffer, uint aBufferSize, out uint aBytesRead)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte | aOffset | The register offset/address to read from. |
| byte[] | aBuffer | Buffer to receive the read data. |
| uint | aBufferSize | Maximum number of bytes to read. |
| uint | aBytesRead | Number of bytes actually read. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
IndirectBurstRead(byte, byte, byte[], uint, out uint, bool)
Performs an indirect burst read operation with offset addressing.
Declaration
public PvResult IndirectBurstRead(byte aSlaveAddress, byte aOffset, byte[] aBuffer, uint aBufferSize, out uint aBytesRead, bool aFastMode)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte | aOffset | The register offset/address to read from. |
| byte[] | aBuffer | Buffer to receive the read data. |
| uint | aBufferSize | Maximum number of bytes to read. |
| uint | aBytesRead | Number of bytes actually read. |
| bool | aFastMode | If true, use fast mode (400 kHz), otherwise standard mode (100 kHz). Default is true. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
IndirectBurstRead(byte, byte, byte[], uint, out uint, bool, bool)
Performs an indirect burst read operation with offset addressing.
Declaration
public PvResult IndirectBurstRead(byte aSlaveAddress, byte aOffset, byte[] aBuffer, uint aBufferSize, out uint aBytesRead, bool aFastMode, bool aUseCombinedFormat)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte | aOffset | The register offset/address to read from. |
| byte[] | aBuffer | Buffer to receive the read data. |
| uint | aBufferSize | Maximum number of bytes to read. |
| uint | aBytesRead | Number of bytes actually read. |
| bool | aFastMode | If true, use fast mode (400 kHz), otherwise standard mode (100 kHz). Default is true. |
| bool | aUseCombinedFormat | If true, use combined format for address and data. Default is true. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
IndirectBurstWrite(byte, byte, byte[], uint)
Performs an indirect burst write operation with offset addressing.
Declaration
public PvResult IndirectBurstWrite(byte aSlaveAddress, byte aOffset, byte[] aBuffer, uint aBufferSize)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte | aOffset | The register offset/address to write to. |
| byte[] | aBuffer | Buffer containing data to write. |
| uint | aBufferSize | Number of bytes to write. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
IndirectBurstWrite(byte, byte, byte[], uint, bool)
Performs an indirect burst write operation with offset addressing.
Declaration
public PvResult IndirectBurstWrite(byte aSlaveAddress, byte aOffset, byte[] aBuffer, uint aBufferSize, bool aFastMode)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte | aOffset | The register offset/address to write to. |
| byte[] | aBuffer | Buffer containing data to write. |
| uint | aBufferSize | Number of bytes to write. |
| bool | aFastMode | If true, use fast mode (400 kHz), otherwise standard mode (100 kHz). Default is true. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
IsSupported(IPvDeviceAdapterSwigInterface, PvDeviceSerial)
Checks if I2C bus communication is supported on the specified device port.
Declaration
public static bool IsSupported(IPvDeviceAdapterSwigInterface aDevice, PvDeviceSerial aPort = PvDeviceSerial.PvDeviceSerialBulk0)
Parameters
| Type | Name | Description |
|---|---|---|
| IPvDeviceAdapterSwigInterface | aDevice | The device adapter to check. |
| PvDeviceSerial | aPort | The serial port to check. Default is PvDeviceSerialBulk0. |
Returns
| Type | Description |
|---|---|
| bool | True if supported, false otherwise. |
MasterReceiverAfterFirstByte(byte, byte[], uint, out uint)
Receives data as I2C master after the first byte has been sent.
Declaration
public PvResult MasterReceiverAfterFirstByte(byte aSlaveAddress, byte[] aBuffer, uint aBufferSize, out uint aBytesRead)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte[] | aBuffer | Buffer to receive the data. |
| uint | aBufferSize | Maximum number of bytes to receive. |
| uint | aBytesRead | Number of bytes actually received. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
MasterReceiverAfterFirstByte(byte, byte[], uint, out uint, bool)
Receives data as I2C master after the first byte has been sent.
Declaration
public PvResult MasterReceiverAfterFirstByte(byte aSlaveAddress, byte[] aBuffer, uint aBufferSize, out uint aBytesRead, bool aFastMode)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte[] | aBuffer | Buffer to receive the data. |
| uint | aBufferSize | Maximum number of bytes to receive. |
| uint | aBytesRead | Number of bytes actually received. |
| bool | aFastMode | If true, use fast mode (400 kHz), otherwise standard mode (100 kHz). Default is true. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
MasterReceiverAfterFirstByte(byte, byte[], uint, out uint, bool, bool)
Receives data as I2C master after the first byte has been sent.
Declaration
public PvResult MasterReceiverAfterFirstByte(byte aSlaveAddress, byte[] aBuffer, uint aBufferSize, out uint aBytesRead, bool aFastMode, bool aGenerateStopCondition)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte[] | aBuffer | Buffer to receive the data. |
| uint | aBufferSize | Maximum number of bytes to receive. |
| uint | aBytesRead | Number of bytes actually received. |
| bool | aFastMode | If true, use fast mode (400 kHz), otherwise standard mode (100 kHz). Default is true. |
| bool | aGenerateStopCondition | If true, generate stop condition after reception. Default is true. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
MasterTransmitter(byte, byte[], uint)
Transmits data as I2C master.
Declaration
public PvResult MasterTransmitter(byte aSlaveAddress, byte[] aBuffer, uint aBufferSize)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte[] | aBuffer | Buffer containing data to transmit. |
| uint | aBufferSize | Number of bytes to transmit. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
MasterTransmitter(byte, byte[], uint, bool)
Transmits data as I2C master.
Declaration
public PvResult MasterTransmitter(byte aSlaveAddress, byte[] aBuffer, uint aBufferSize, bool aFastMode)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte[] | aBuffer | Buffer containing data to transmit. |
| uint | aBufferSize | Number of bytes to transmit. |
| bool | aFastMode | If true, use fast mode (400 kHz), otherwise standard mode (100 kHz). Default is true. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
MasterTransmitter(byte, byte[], uint, bool, bool)
Transmits data as I2C master.
Declaration
public PvResult MasterTransmitter(byte aSlaveAddress, byte[] aBuffer, uint aBufferSize, bool aFastMode, bool aGenerateStopCondition)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | aSlaveAddress | The 7-bit I2C slave address. |
| byte[] | aBuffer | Buffer containing data to transmit. |
| uint | aBufferSize | Number of bytes to transmit. |
| bool | aFastMode | If true, use fast mode (400 kHz), otherwise standard mode (100 kHz). Default is true. |
| bool | aGenerateStopCondition | If true, generate stop condition after transmission. Default is true. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |
Open(IPvDeviceAdapterSwigInterface, PvDeviceSerial)
Opens the I2C bus on the specified device serial port.
Declaration
public PvResult Open(IPvDeviceAdapterSwigInterface aDevice, PvDeviceSerial aPort = PvDeviceSerial.PvDeviceSerialBulk0)
Parameters
| Type | Name | Description |
|---|---|---|
| IPvDeviceAdapterSwigInterface | aDevice | The device adapter providing access to the device. |
| PvDeviceSerial | aPort | The serial port to use for I2C communication. Default is PvDeviceSerialBulk0. |
Returns
| Type | Description |
|---|---|
| PvResult | Result of the operation. |