Toolbox.NETMF.Hardware.MultiI2C

Toolbox.NETMF.Hardware.MultiI2C(Address, ClockRateKhz)
  • Address The I²C device address
  • ClockRateKhz The speed of the I²C device

Purpose of this class

This class is a wrapper for the built-in Microsoft.SPOT.Hardware.I2CDevice class with one difference: you can create only one Microsoft.SPOT.Hardware.I2CDevice instance and need to re-use that all the time with different configurations.
With this version, you can have multiple instances, making working with I²C a bit easier.
Also, the methods are a bit more simplified.

Methods

  • Read(ReadBuffer) Reads data from the device
  • Write(WriteBuffer) Writes data to the device
  • WriteRead(WriteBuffer, ReadBuffer) Writes and then reads data from the device

Properties

  • Timeout Reads/writes the I²C execution timeout
  • DeviceAddress Returns the address of the I²C device
  • ClockRateKhz Returns the speed of the I²C device

Sample code in C#

MultiI2C device = new MultiI2C(0x09, 100);

device.Write(new byte[] { 0x6f, 0x6e, 0xff, 0x00, 0x00 });

Sample code in VB

Dim device As MultiI2C = New MultiI2C(&H9, 100)

Dim WriteBuffer() As Byte = {&H6F, &H6E, &HFF, &H0, &H0}
device.Write(WriteBuffer)

Last edited Jan 2, 2013 at 7:42 PM by Garrcomm, version 4