1# i2c_write_bytes
2
3## Description
4
5Writes bytes to a device register. Communicates with the device directly using
6the [I2C interface](i2c_interface.md).
7
8All of the bytes will be written in a single I2C operation.
9
10The bytes must be specified in the order required by the device. For example, a
11PMBus device requires byte values to be written in little-endian order (least
12significant byte first).
13
14## Properties
15
16| Name     | Required | Type             | Description                                                                                                                                                                                                                                                                                                                          |
17| :------- | :------: | :--------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
18| register |   yes    | string           | Device register address expressed in hexadecimal. Must be prefixed with 0x and surrounded by double quotes. This is the location of the first byte.                                                                                                                                                                                  |
19| values   |   yes    | array of strings | One or more byte values to write expressed in hexadecimal. Each value must be prefixed with 0x and surrounded by double quotes.                                                                                                                                                                                                      |
20| masks    |    no    | array of strings | One or more bit masks expressed in hexadecimal. Each mask must be prefixed with 0x and surrounded by double quotes. The number of bit masks must match the number of byte values to write. Each mask specifies which bits to write within the corresponding byte value. Only the bits with a value of 1 in the mask will be written. |
21
22## Return Value
23
24true
25
26## Examples
27
28```json
29{
30  "comments": [
31    "Write 0xFF01 to register 0xA0.  Device requires bytes to be",
32    "written in big-endian order."
33  ],
34  "i2c_write_bytes": {
35    "register": "0xA0",
36    "values": ["0xFF", "0x01"]
37  }
38}
39```
40
41```json
42{
43  "comments": [
44    "Write 0x7302 to register 0x82.  Device requires bytes to be",
45    "written in little-endian order.  Do not write the most",
46    "significant bit in each byte because the bit is reserved."
47  ],
48  "i2c_write_bytes": {
49    "register": "0x82",
50    "values": ["0x02", "0x73"],
51    "masks": ["0x7F", "0x7F"]
52  }
53}
54```
55