The I2C protocol can access a device by three different manners:
Write
(Start, AddW, Byte1, Byte2, …, Stop)
Read
(Start, AddR, Byte1, Byte2, …, Stop)
Read After Write
(Start, AddW, ByteW1, ByteW2, …, ReStart,
AddR, ByteR1, ByteR2, …Stop)
I2C Read/Write with ack command:
To be able to do all of these 3 sequences, use this command:
Byte#
Number of bits
Example
0x00 I2CRWwithAck (0x0007)
16 bits
0x0007
0x02 TransactionID
16 bits
0x1B34
0x04 LengthOfParameters (X + 3) 16 bits
0x0005
0x06 7 bits Address (bit 7 = 0)
8 bits
0x28
0x07 X (number of bytes to write) 8 bits
0x02
0x08 xBytes
X bytes
0xAF1D
….
Y (number of bytes to read) 8 bits
0x05
The four previous entries can be replicated to access the same or other I2C slaves within this
command sequence.
Checksum
16 bits
0x…
The FMod-TCP DB translates automatically those commands to I2C
sequences:
If X = 0, the Read method is used.
If Y = 0, the Write method is used.
If X & Y
≠
0, the Read after Write method is used.
Warning: Please check that
240
3
2
≤
+
Y
X
. In other case, the command will
be ignored by the board.
Note: the max length of parameters is 172 bytes on this board.
Pay close
attention to building sequences that do not exceed this and not to ask too
much byte in answer! It is also mandatory that the command has to be
transmitted within one TCP packet.
Otherwise, the FMod-TCP DB will
ignore it.
St
AddW
Bytes to W
A
nA Sp
AddR
Bytes to R
A
A
R
St
AddR
Bytes to R
A
nA Sp
St
AddW
Bytes to W
A
A Sp