oI2C Object
An Object that provides access to an I2C device.
Description:
 An Object that provides access to an I2C device.
Operation:
 The oI2C Object reads/writes a byte from/to an I2C device connected to the Local I2C Bus. The Local I2C Bus consists of the Local I2C Clock Line, the Local I2C Data Line, and Ground.

The Node property specifies the 7-Bit address of the I2C device with which to communicate. The 7-Bit address is the I2C address that is assigned by the device's manufacturer and is 'hard-wired' into the I2C device.

Three different I2C addressing modes are supported as well as either an 8-Bit or 16-Bit data transfer. If the I2C device does not use an internal memory/register location, then the Mode property can be set to 2 (cv7bit) which specifies to send only the 7-Bit I2C address. If the I2C device does use an internal memory/register location, then the Mode property can be set to 0 (cv23bit) or 1 (cv10bit) which specifies to send the 7-Bit I2C address followed by a memory/register location of either 16-Bits or 8-Bits respectively.

The Location property specifies the I2C device's memory/register location and is only used when the Mode property is set to 0 or 1.

The NoInc property specifies if the Location property is increased each time the I2C device is read from or written to. If the NoInc property is set to 0 then the Location property will be increased by the number of bytes specified by the Width property. If the NoInc property is set to 1 then the Location property is left unchanged.

The Width property specifies how many bytes get transferred. If the Width property is set to 0, then 1 byte is transferred. If the Width property is set to 1, then 2 bytes are transferred when the I2C device is read/written.

The oI2C Object has no Operate property. Instead when an oI2C Object's Value property is read from or written to the oI2C Object performs all the necessary operations to transfer data to/from the specified I2C device. Once the data has been transferred, the oI2C Object returns to a dormant state.

For more information on the specifications of individual I2C devices consult the manufacturer's technical information sheets.

Remarks:
 The default property of the oI2C Object cannot be assigned to a pointer.
Storage size & Availability:
 

The following table lists the size and availability of the oDio1 Object:

ObjectSizeVersion
oI2C5 BytesA.1.0 and greater
Properties:
 The following table lists the Properties of the oI2C Object:
PropertyDescription
AddressReturns a pointer to the address of the oI2C Object instance.

Data-Type: Number-Pointer, Read-Only

Data-Range: 0 - 127

LocationA value indicating the current Location-Address to use when accessing the I2C device.

Data-Type: Word

Data-Range: 0 - 65535

ModeThe I2C mode

Data-Type: Nibble

Data-Range: 0 - 3

The following table list the values of the Mode Property:

ModeConstantDescription
0cv23BitThe oI2C Object will use the 23-Bit I2C address mode.
1cv10BitThe oI2C Object will use the 10-Bit I2C address mode.
2cv7BitThe oI2C Object will use the 7-Bit I2C address mode.
3 Unused
NodeThe I2C address to be used.

Data-Type: Byte

Data-Range: 0 - 127

NoIncA value that specifies if the Location property will be incremented each time the I2C Object's Value property is read or written.

Data-Type: Bit, Flag

Data-Range: 0 - 1

The following table lists the values of the NoInc Property:

NoIncConstantDescription
0cvFalseThe oI2C Object increments the Location property each time the Value property is read or written
1cvTrueThe oI2C Object does not increment the Location property each time the Value property is read or written
StringThe Value property represented as a string.

Note: The String property is available in OOPic Basic Version 2

Data-Type: String

ValueA value indicating the contents of the I2C device. When read the value within the I2C device will be returned. When written the value is stored into the I2C device.

Data-Type: Byte, Default

Data-Range:
When Width = 0 Data-Range is 0 - 255
When Width = 1 Data-Range is 0 - 65535

WidthThe number of Bytes to read/write.

Data-Type: Bit

Data-Range: 0 - 1

The following table lists the values of the Width Property:

WidthConstantDescription
0cv8BitThe oI2C Object will read and write 8 bits at a time
1cv16BitThe oI2C Object will read and write 16 bits at a time
Example:
 In the following example, the oI2C Object is used.
'This program uses the I2C Object 
'to store a value in the I2C EEPROM
'in socket E1.  Each time the OOPic
'is turned on or reset the value is
'increased and then outputted to
'I/O Lines 8-15.

Dim A As New oI2C
Dim B As New oDio8

Sub Main()
  A.Node = cvE1
  A.NoInc = cvTrue
  A.Value = A.Value + 1
  B.IOGroup = 5
  B.Direction = cvOutput
  B.Value = A.Value
End Sub
See Also:
 oEEProm Object