====== Bash Shell Interface for I2C ====== On the kernel level, I2C communication is handled by the ''i2c-dev'' kernel driver. On the lowest level, the bus is seen as a file and using a file descriptor one can read from it or write to it. The shell interface is a set of compiled programs that wrap this functionality for specific uses at a higher level. The intended use is interactive debugging to see if something works or not. For programmatic use it's better to take a look at the [[.:i2c-tools_API|C API]] for C/C++ and the [[.:smbus2|smbus2]] library for Python. These programs are part of the ''i2c-tools'' package that usually comes preinstalled in most Linux distributions. ===== i2cdetect ===== Detects I2C chips. Use: ''i2cdetect [options] i2cbus [first_addr last_addr]''. Special flags that don't require a given i2cbus are ''-V'' that prints the current version and ''-l''. * ''i2cdetect -l'' to list busses. To access each buss you have to used it's number (''i2c-{NUM}'') or the full string name. * ''-q'' and ''-r'' options are to use quick write and receive byte commands for probing. They can corrupt certain IC chips. * ''-F'' displays the list of functionalities available on the bus. ===== i2cdump ===== Examines registers on the I2C bus. Use: ''i2cdump [options] i2cbus address [mode [bank [bankreg]]]'' * ''i2cbus'': One of the buses represented by the number or string name from ''i2cdetect -l''. * ''-r first-last'': Limit the range of registers being accessed. Incompatible with ''s''. * ''address'': The address of the IC chip on the bus. * ''mode'': Chooses the mode to access the register as a single byte, a double byte word or a block. If not provided, defaults to single byte without PEC. Options are listed below: * ''b'': Single byte (default). * ''w'': Word. * ''i'': I2C block. * ''c'': Consecutive block. Useful for ICs with automatic increment, like EEPROMs. * ''W'': Word, but the command will only be issued on even addresses. Also useful for EEPROMs. * ''s'': SMBus block. Avoid it, it's deprecated. * ''p'': Can be appended on the mode parameter (not on ''i'' and ''W'') to enable Packet Error Checking (PEC). * ''bank''/''bankreg'': Used on Winbond and Asus chips. ''bank'' is an integer from 0 to 7, and ''bankreg'' an integer from 0x00 to 0xff with a default of 0x4e. Use of ''i2cdump'' is not advised unless you have intimate knowledge of the IC you're accessing. It's very easy to corrupt stuff. ===== i2cget ===== 3 ===== i2cset ===== 4 ===== i2ctransfer ===== 5