USERI2CWRITE
Write data to device on I2C bus
Platform: |
OEM7600, OEM7700, OEM7720 |
Use this command to write data to devices on the I2C bus.
This command only applies to OEM7 receivers that have I2C signals available on the interface connector. The compatible receivers are listed in the Platform section above.
The USERI2CRESPONSE log can be used to check the completion or status of the write operation. An optional user defined Transaction ID can be provided to help synchronize requests with responses in the USERI2CRESPONSE log. This command is primarily intended to be used by Lua applications that need to interact with external devices.
Writing to an I2C device requires a device address, to distinguish which physical device is to be accessed, a register within the device and the data. Depending on the type of I2C device, register addresses can be 1 to 4 bytes in length, and so the actual number of bytes for the register address must be specified.
For some I2C devices there are no registers within the device. In this case, the Register Address Length is 0, and no bytes are supplied for the Register Address.
For some other I2C devices, write operations are done in two stages:
-
The first stage sends a write command with a register address, but no data. This is a dummy write to set the register within the device for write operations that follow.
-
The second stage sends a write command with no register address, but does send a stream of data.
The USERI2CWRITE command is flexible to handle all of these situations.
Message ID: 2233
Abbreviated ASCII Syntax:
USERI2CWRITE DeviceAddress RegisterAddressLen RegisterAddress WriteDataLength WriteData [TransactionID]
Examples:
USERI2CWRITE 70 1 AB 12 3132333435363738393A3B3C 1234
USERI2CWRITE 74 3 ABCDED 5 1234567890 1234
USERI2CWRITE 40 0 5 1234567890 1234
USERI2CWRITE 40 2 AABB 0 1234 (a dummy write)
Field |
Field Type |
Description |
Format |
Binary Bytes |
Binary Offset |
---|---|---|---|---|---|
1 |
Command header |
USERI2CWRITE header This field contains the command name for abbreviated ASCII or the message header for ASCII or Binary. |
- |
H |
0 |
2 |
DeviceAddress |
The 7 bit address of the I2C device. Valid values 0 through 127. For ASCII and Abbreviated commands, this field is a hexadecimal string of two digits. There is no 0x prefix and spaces are not allowed in the string. |
Uchar |
11 |
H |
3 |
RegisterAddressLen |
The length of the register address that follows. Valid values are 0 through 4. |
Ulong |
4 |
H+4 |
4 |
RegisterAddress |
The actual address of the register to be written. The number of bytes here must match the RegisterAddressLen. In particular, when RegisterAddressLen is 0, this field is empty (even for a binary command) For ASCII and Abbreviated commands, this field is a hexadecimal string of two digits for each byte in the register address. There is no 0x prefix and spaces are not allowed in the string. |
Uchar Array |
X1 |
H+8 |
5 |
WriteDataLength |
The length of data to be written in bytes. Valid values are 0 through 256. |
Ulong |
4 |
H+122 |
6 |
WriteData |
The data to be written. The number of bytes in this data block must match the WriteDataLength. In particular, when WriteDataLength is 0, this field is empty. For ASCII and Abbreviated commands, this field is a hexadecimal string of two digits for each byte in the data block. There is no 0x prefix and spaces are not allowed in the string. Data is streamed to the device as a series of bytes in the order provided. |
Uchar Array |
Y3 |
H+164 |
7 |
TransactionID |
An optional user provided ID for this transaction. Default = 0. This transaction ID will be copied to the USERI2CRESPONSE log created for this write operation. |
Ulong |
4 |
H+16+4*INT((Y+3)/4)5 |