The twowire command
Synopsis
twowire subcommand ?arg ...?
Description
The twowire command provides access to the i2c busses of the Raspberry Pi. The legal values of subcommand are listed below. Note that you can abbreviate the subcommands.
- twowire twowire bus address
- Create a handle for the i2c device with the specified address on the specified i2c bus. This handle can be used with the other subcommands to exchange data with the device. The regular Tcl close or chan close commands can be used to release the handle.
- twowire functionality handle
- Check which functionality is supported by the driver. The return value is a list of all supported functions. See the Functionality section below for the possible values.
- twowire readbyte handle
- Read a single byte from the device addressed by the handle.
- twowire readregbyte handle register
- Read a byte from the specified register of the device addressed by the handle.
- twowire readregword handle register
- Read a 2-byte word (LSB, MSB) from the specified register of the device addressed by the handle.
- twowire readregblock handle register
- Read multiple bytes from the specified register of the device addressed by the handle. The first received data byte is interpreted as the number of data bytes to follow. The data is returned as a binary string.
- twowire readregdata handle register length
- Read a block of length bytes from the specified register of the device addressed by the handle. The data is returned as a binary string.
- twowire writebyte handle data
- Write a single byte to the device addressed by the handle.
- twowire writeregbyte handle register data
- Write a byte to the specified register of the device addressed by the handle.
- twowire writeregword handle register data
- Write a 2-byte word (LSB, MSB) to the specified register of the device addressed by the handle.
- twowire writeregblock handle register bytes
- Write a block of data bytes, preceded by the size of the block, to the specified register of the device addressed by the handle. The bytes argument must be a binary string. A maximum of 32 bytes will be written.
- twowire writeregdata handle register bytes
- Write a block of data bytes to the specified register of the device addressed by the handle. The bytes argument must be a binary string. A maximum of 32 bytes will be written.
Functionality
These are the possible functionality flags that can be reported by the twowire functionality command, along with their meaning. Not all functionalities may be accessible using the twowire command.- readbyte
- Handles the readbyte command
- writebyte
- Handles the writebyte command
- readregbyte
- Handles the readregbyte command
- writeregbyte
- Handles the writeregbyte command
- readregword
- Handles the readregword command
- writeregword
- Handles the writeregword command
- readblock
- Handles the readblock command
- writeblock
- Handles the writeblock command
- readdata
- Handles the readdata command
- writedata
- Handles the writedata command
- quick
- Handles the SMBus write_quick command
- notify
- Can send the SMBus Host Notify command
- proc
- Handles the SMBus Process Call command (send 16 bits of data then receive 16 bits of data)
- blockproc
- Handles the SMBus Block Write - Block Read Process Call (send a block of data, then receive a block of data).
- i2c
- Plain i2c-level commands (Pure SMBus adapters typically can not do these)
- 10bitaddr
- Handles the 10-bit address extensions
- mangling
- Knows about the I2C_M_IGNORE_NAK, I2C_M_REV_DIR_ADDR and I2C_M_NO_RD_ACK flags (which modify the I2C protocol!)
- pec
- Supports Packet Error Checking
- nostart
- Can skip repeated start sequence
- slave
- The device operates solely as a slave interface.