IO-Warrior IIC usage howto.

This file contains some useful tips for using IIC function of IO-Warrior.

According to specs, there are 2 types of IIC transactions:
1) Writing data to IIC.
2) Reading data from IIC.

To initiate write transaction, you should write 8-bytes packet to IIC
interface, where:
1st byte is Report ID. It's equal to 2.
2nd byte is flags, it contains the following bits:
7 - Generate Start
6 - Generate Stop
5,4,3 - Unused, set to zero
2 - Data count LSB
1 - Data count
0 - Data count LSB

You can write upto 6 bytes of data in one write transaction.

Here is sample IIC write packet setup:

Dim iicPacket(7)
    ' "IIC write packet" report ID - 2
    iicPacket(0) = 2
    ' Generate start, write 3 bytes and generate stop CMD
    ' If you want to write more than 6 bytes, you shouldn't generate STOP
    ' You should generate stop condition after all bytes are transfered
    iicPacket(1) = &HC3
    ' IIC device address and R/W bit = 0, so we write
    ' We write to A/D converter
    iicPacket(2) = &H58
    ' Command to IIC device, A/D register zero
    iicPacket(3) = &H0
    ' A/D value
    ' See IO-Warrior and IIC specs for more specific information
    iicPacket(4) = &H0
    ' Other bytes are zero
    iicPacket(5) = 0
    iicPacket(6) = 0
    iicPacket(7) = 0
    ' Write to IIC interface
    Res = IowKitWrite(iowHandle, 1, iicPacket(0), 8)
    ...

After writing "IIC write packet" to IO-Warrior, you should read ACK packet
from it.
Here is the sample code:
    ' Read ACK packet from IO-Warrior
    Res = IowKitRead(iowHandle, 1, iicPacket(0), 8)
    ' Check for correct report ID
    If (iicPacket(0) = 2) Then
       ' Check for error
       If (iicPacket(1) And &H80) <> 0 Then
          ' Error occured, transaction has been aborted
       Else
          ' Everything is fine, get data counter
          nWritten = iicPacket(1) And 7
          ...
       End If
    End If
    ...
