I2C(3)
NAME
i2c − basic I2C interface
SYNOPSIS
bind -a #J[n] /dev
/dev/i2cnctl
/dev/i2cndata
DESCRIPTION
The I2C driver serves a one-level directory with two files that give access to the target with address n on the system’s I2C bus. N is usually determined by the I2C device manufacturer, and must be an even number from 0 to 254. I2C gives address 0 special meaning as the ‘general call’ address. See an I2C specification for details.
The control file i2cnctl accepts commands to set the valid address range and subaddressing mode for the corresponding data file. The following control messages can be written to it:
size nbytes
Set the logical size of the target device to nbytes (default: 256). IO requests will be kept within this limit. This value is also returned by Sys->stat as the length of the data file.
subaddress
Cause subsequent reads and writes on the data file to use I2C subaddressing. The target device must support it. By default, the device is not subaddressed.
The data file i2cndata exchanges data with the slave device with address n . Each write request transmits the given data to the device. Each read request sends a receive request to the device and returns the resulting data. If the I2C target is subaddressed, the current file offset gives the subaddress (ranging from 0 to 255); otherwise the file offset must be zero. Read and write requests are trimmed to the size of the device.
SOURCE
/os/mpc/devi2c.c
/os/mpc/i2c.c