I2CSET(8) | System Manager's Manual | I2CSET(8) |
i2cset - set I2C registers
i2cset [-f] [-y] [-m mask] [-r]
[-a] i2cbus chip-address data-address
[value] ... [mode]
i2cset -V
i2cset is a small helper program to set registers visible through the I2C bus.
There are three required options to i2cset. i2cbus indicates the number or name of the I2C bus to be scanned. This number should correspond to one of the busses listed by i2cdetect -l. chip-address specifies the address of the chip on that bus, and is an integer between 0x03 and 0x77. data-address specifies the address on that chip to write to, and is an integer between 0x00 and 0xFF.
The value parameter, if specified, is the value to write to that location on the chip. If this parameter is omitted, then a short write is issued. For most chips, it simply sets an internal pointer to the target location, but doesn't actually write to that location. For a few chips though, in particular simple ones with a single register, this short write is an actual write. If the mode parameter is s or i, multiple values can be specified.
The mode parameter, if specified, is one of the letters b, w, s, or i, corresponding to a write size of a single byte, a 16-bit word, a SMBus block write, or an I2C block write, respectively. For SMBus and I2C block writes, the write size is determined by the number of value parameters. Except for I2C block writes, a p can also be appended to the mode parameter to enable PEC. If the mode parameter is omitted, i2cset defaults to byte mode without PEC. The value provided must be within range for the specified data type (0x00-0xFF for byte and block writes, 0x0000-0xFFFF for words). Another possible mode is c, which doesn't write any value (so-called short write). You usually don't have to specify this mode, as it is the default when no value is provided, unless you also want to enable PEC.
i2cset can be extremely dangerous if used improperly. It can confuse your I2C bus, cause data loss, or have more serious side effects. Writing to a serial EEPROM on a memory DIMM (chip addresses between 0x50 and 0x57) may DESTROY your memory, leaving your system unbootable! Be extremely careful using this program.
Write value 0x42 to 8-bit register 0x11 of the I2C device at 7-bit address 0x2d on bus 1 (i2c-1), after user confirmation:
# i2cset 1 0x2d 0x11 0x42
Immediately clear the 3 least significant bits of 8-bit register 0x11 of the I2C device at 7-bit address 0x2d on bus 1 (i2c-1) (no user confirmation):
# i2cset -y -m 0x07 1 0x2d 0x11 0x00
Write value 0x5000 to 16-bit register 0x02 of the I2C device at 7-bit address 0x48 on bus 1 (i2c-1), after user confirmation:
# i2cset 1 0x48 0x02 0x5000 w
Also see i2cget(8) for examples of combined usage of i2cset and i2cget.
i2cdetect(8), i2cdump(8), i2cget(8), i2ctransfer(8), isaset(8)
Frodo Looijaard, Mark D. Studebaker and Jean Delvare
This manual page was originally written by David Z Maze <dmaze@debian.org> for the Debian GNU/Linux system.
October 2017 |