Documentation
¶
Overview ¶
Package i2c provides low level control over the linux i2c bus.
Before usage you should load the i2c-dev kernel module
sudo modprobe i2c-dev
Each i2c bus can address 127 independent i2c devices, and most linux systems contain several buses.
Index ¶
- Constants
- type I2C
- func (v *I2C) Close() error
- func (v *I2C) ReadBytes(buf []byte) (int, error)
- func (v *I2C) ReadRegBytes(reg byte, n int) ([]byte, int, error)
- func (v *I2C) ReadRegS16BE(reg byte) (int16, error)
- func (v *I2C) ReadRegS16LE(reg byte) (int16, error)
- func (v *I2C) ReadRegU16BE(reg byte) (uint16, error)
- func (v *I2C) ReadRegU16LE(reg byte) (uint16, error)
- func (v *I2C) ReadRegU8(reg byte) (byte, error)
- func (v *I2C) WriteBytes(buf []byte) (int, error)
- func (v *I2C) WriteRegS16BE(reg byte, value int16) error
- func (v *I2C) WriteRegS16LE(reg byte, value int16) error
- func (v *I2C) WriteRegU16BE(reg byte, value uint16) error
- func (v *I2C) WriteRegU16LE(reg byte, value uint16) error
- func (v *I2C) WriteRegU8(reg byte, value byte) error
Constants ¶
const (
I2C_SLAVE = 0x0703
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type I2C ¶
type I2C struct { // Enable verbose output Debug bool // contains filtered or unexported fields }
I2C represents a connection to an i2c device.
func (*I2C) ReadRegBytes ¶
SMBus (System Management Bus) protocol over I2C. Read count of n byte's sequence from i2c device starting from reg address.
func (*I2C) ReadRegS16BE ¶
SMBus (System Management Bus) protocol over I2C. Read signed big endian word (16 bits) from i2c device starting from address specified in reg.
func (*I2C) ReadRegS16LE ¶
SMBus (System Management Bus) protocol over I2C. Read unsigned little endian word (16 bits) from i2c device starting from address specified in reg.
func (*I2C) ReadRegU16BE ¶
SMBus (System Management Bus) protocol over I2C. Read unsigned big endian word (16 bits) from i2c device starting from address specified in reg.
func (*I2C) ReadRegU16LE ¶
SMBus (System Management Bus) protocol over I2C. Read unsigned little endian word (16 bits) from i2c device starting from address specified in reg.
func (*I2C) ReadRegU8 ¶
SMBus (System Management Bus) protocol over I2C. Read byte from i2c device register specified in reg.
func (*I2C) WriteBytes ¶
Write sends buf to the remote i2c device. The interpretation of the message is implementation dependant.
func (*I2C) WriteRegS16BE ¶
SMBus (System Management Bus) protocol over I2C. Write signed big endian word (16 bits) value to i2c device starting from address specified in reg.
func (*I2C) WriteRegS16LE ¶
SMBus (System Management Bus) protocol over I2C. Write signed big endian word (16 bits) value to i2c device starting from address specified in reg.
func (*I2C) WriteRegU16BE ¶
SMBus (System Management Bus) protocol over I2C. Write unsigned big endian word (16 bits) value to i2c device starting from address specified in reg.
func (*I2C) WriteRegU16LE ¶
SMBus (System Management Bus) protocol over I2C. Write unsigned big endian word (16 bits) value to i2c device starting from address specified in reg.