Documentation ¶
Overview ¶
Before usage you should load the i2c-dev kernel module
sudo modprobe i2c-dev
Index ¶
- Constants
- type I2C
- func (i2c *I2C) Close() error
- func (i2c *I2C) GetAddr() uint8
- func (i2c *I2C) GetDev() string
- func (i2c *I2C) Init(addr uint8, dev string, i2cAddress uintptr) (*I2C, error)
- func (i2c *I2C) ReadBytes(buf []byte) (int, error)
- func (i2c *I2C) ReadRegBytes(reg byte, n int) ([]byte, int, error)
- func (i2c *I2C) ReadRegS16BE(reg byte) (int16, error)
- func (i2c *I2C) ReadRegS16LE(reg byte) (int16, error)
- func (i2c *I2C) ReadRegU16BE(reg byte) (uint16, error)
- func (i2c *I2C) ReadRegU16LE(reg byte) (uint16, error)
- func (i2c *I2C) ReadRegU8(reg byte) (byte, error)
- func (i2c *I2C) WriteBytes(buf []byte) (int, error)
- func (i2c *I2C) WriteRegS16BE(reg byte, value int16) error
- func (i2c *I2C) WriteRegS16LE(reg byte, value int16) error
- func (i2c *I2C) WriteRegU16BE(reg byte, value uint16) error
- func (i2c *I2C) WriteRegU16LE(reg byte, value uint16) error
- func (i2c *I2C) WriteRegU24BE(reg byte, value uint32) error
- func (i2c *I2C) WriteRegU32BE(reg byte, value uint32) error
- func (i2c *I2C) WriteRegU8(reg byte, value byte) error
Constants ¶
const DEFAULT_I2C_ADDRESS = 0x0703
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type I2C ¶
type I2C struct {
// contains filtered or unexported fields
}
I2C represents a connection to I2C-device.
func (*I2C) Init ¶
Init opens a connection for I2C-device. SMBus (System Management Bus) protocol over I2C supported as well: you should preliminary specify register address to read from, either write register together with the data in case of write operations.
func (*I2C) ReadBytes ¶
ReadBytes read bytes from I2C-device. Number of bytes read correspond to buf parameter length.
func (*I2C) ReadRegBytes ¶
ReadRegBytes read count of n byte's sequence from I2C-device starting from reg address.
func (*I2C) ReadRegS16BE ¶
ReadRegS16BE reads signed big endian word (16 bits) from I2C-device starting from address specified in reg.
func (*I2C) ReadRegS16LE ¶
ReadRegS16LE reads signed little endian word (16 bits) from I2C-device starting from address specified in reg.
func (*I2C) ReadRegU16BE ¶
ReadRegU16BE reads unsigned big endian word (16 bits) from I2C-device starting from address specified in reg.
func (*I2C) ReadRegU16LE ¶
ReadRegU16LE reads unsigned little endian word (16 bits) from I2C-device starting from address specified in reg.
func (*I2C) WriteBytes ¶
WriteBytes send bytes to the remote I2C-device. The interpretation of the message is implementation-dependent.
func (*I2C) WriteRegS16BE ¶
WriteRegS16BE writes signed big endian word (16 bits) value to I2C-device starting from address specified in reg.
func (*I2C) WriteRegS16LE ¶
WriteRegS16LE writes signed little endian word (16 bits) value to I2C-device starting from address specified in reg.
func (*I2C) WriteRegU16BE ¶
WriteRegU16BE writes unsigned big endian word (16 bits) value to I2C-device starting from address specified in reg.
func (*I2C) WriteRegU16LE ¶
WriteRegU16LE writes unsigned little endian word (16 bits) value to I2C-device starting from address specified in reg.
func (*I2C) WriteRegU24BE ¶
WriteRegU24BE writes unsigned big endian word (24 bits) value to I2C-device starting from address specified in reg.
func (*I2C) WriteRegU32BE ¶
WriteRegU32BE writes unsigned big endian word (32 bits) value to I2C-device starting from address specified in reg.