Firmware-72 Command-124

From I-CubeX Wiki
Jump to: navigation, search

I2C WRITE SINGLE (124, 7Ch)

The I2C WRITE SINGLE command is similar to the I2C WRITE 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 WRITE SINGLE command. The command can be used in both host and stand-alone modes of operation.

The I2C WRITE SINGLE command [BODY] is:

00000xxx: xxx = [0..6]; I2C port number
0aaaaaaa: aaaaaa = [0..127]; I2C address of device
0000bbbb:
0000cccc: bbbbcccc = [0..255]; data to write

Upto 4 databytes (bbbbcccc) may be written using one message by adding extra pairs of 0000bbbb and 0000cccc.

Example:

240, 125, 0 {DEV}, 124 {I2C WRITE SINGLE}, 4 {port number}, 73 {address of device}, 0, 3 {data byte 3 = 0*16+3}, 247 (F0h, 7Dh, 00h, 7Ch, 04h, 49h, 00h, 03h, F7h)

If the device responded to the provided I2C address “aaaaaaa” (I2C devices always acknowledge when it’s address is called) then the USB-microDig will respond with a I2C WRITE SINGLE message identical to the I2C WRITE SINGLE command sent. If there was no acknowledgement from the device within 100 ms (eg. wrong address or device not present) then the USB-microDig will respond with an I2C NO RESPONSE message (ie. in the above case the response would be F0h, 00h, 7Bh, 04h, 49h, F7h). If the I2C port on the USB-microDig was not opened the USB-microDig will respond with an I2C PORT message indicating the port was not opened (F0h 7Dh 00h 7Dh 04h F7h, where the port number is 4).