Firmware-811 Command-122

From I-CubeX Wiki
Jump to: navigation, search

I2C READ SINGLE (122, 7Ah)

The I2C READ SINGLE command can be used to transfer data from a I2C device. It is similar to the I2C READ command but is used for I2C devices that do not use a register access byte. Unless the I2C device has no pull-up resistors it is not necessary to use the I2C PORT command before sending the I2C READ SINGLE command. The command can be used in both host and stand-alone modes of operation.

The I2C READ SINGLE command [BODY] is:

00000xxx: xxx = [0..7]; I2C port number
0aaaaaaa: aaaaaa = [0..127]; I2C address of device
0bbbbbbb: bbbbbbb = [1..127]; number of bytes to read

Example:

240, 125, 0 {DEV}, 122 {I2C READ SINGLE}, 2 {port number}, 73 {address of device}, 3 {number of bytes to read 3}, 247 (F0h, 7Dh, 00h, 7Ah, 02h, 49h, 03h, F7h)

If the device responded to the provided I2C address “aaaaaaa” (I2C devices always acknowledge when it’s address is called) then the WiDig will respond with a I2C READ SINGLE message having the same address followed by the number of bytes that was requested and the data bytes (according to the example above, the reply message could be: F0h, 7Dh, 00h, 7Ah, 02h, 49h, 03h, 00h, 07h, 0Eh, 0Fh, 08h, 00h, F7h thus the received bytes would be 07h, EFh and 80h). Each requested byte is split as two consecutive bytes having their upper 4 bits to zero and encoded as upper byte sent first then lower byte (ex. 47h would be sent as 04h 07h). If there was no acknowledgement from the device within 100 ms (eg. wrong address or device not present) then the WiDig will respond with an I2C NO RESPONSE message (ie. in the above case the response would be F0h, 00h, 7Bh, 02h, 49h, F7h). If the I2C port on the WiDig was not opened the WiDig will respond with an I2C PORT message indicating the port was not opened (F0h 7Dh 00h 7Dh xx F7h, where xx is the requested port).