i2c

package
v0.0.0-...-f592e1d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Before usage you should load the i2c-dev kernel module

sudo modprobe i2c-dev

Index

Constants

View Source
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) Close

func (i2c *I2C) Close() error

Close I2C-connection.

func (*I2C) GetAddr

func (i2c *I2C) GetAddr() uint8

GetAddr return device occupied address in the bus.

func (*I2C) GetDev

func (i2c *I2C) GetDev() string

GetDev return full device name.

func (*I2C) Init

func (i2c *I2C) Init(addr uint8, dev string, i2cAddress uintptr) (*I2C, error)

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

func (i2c *I2C) ReadBytes(buf []byte) (int, error)

ReadBytes read bytes from I2C-device. Number of bytes read correspond to buf parameter length.

func (*I2C) ReadRegBytes

func (i2c *I2C) ReadRegBytes(reg byte, n int) ([]byte, int, error)

ReadRegBytes read count of n byte's sequence from I2C-device starting from reg address.

func (*I2C) ReadRegS16BE

func (i2c *I2C) ReadRegS16BE(reg byte) (int16, error)

ReadRegS16BE reads signed big endian word (16 bits) from I2C-device starting from address specified in reg.

func (*I2C) ReadRegS16LE

func (i2c *I2C) ReadRegS16LE(reg byte) (int16, error)

ReadRegS16LE reads signed little endian word (16 bits) from I2C-device starting from address specified in reg.

func (*I2C) ReadRegU16BE

func (i2c *I2C) ReadRegU16BE(reg byte) (uint16, error)

ReadRegU16BE reads unsigned big endian word (16 bits) from I2C-device starting from address specified in reg.

func (*I2C) ReadRegU16LE

func (i2c *I2C) ReadRegU16LE(reg byte) (uint16, error)

ReadRegU16LE reads unsigned little endian word (16 bits) from I2C-device starting from address specified in reg.

func (*I2C) ReadRegU8

func (i2c *I2C) ReadRegU8(reg byte) (byte, error)

ReadRegU8 reads byte from I2C-device register specified in reg.

func (*I2C) WriteBytes

func (i2c *I2C) WriteBytes(buf []byte) (int, error)

WriteBytes send bytes to the remote I2C-device. The interpretation of the message is implementation-dependent.

func (*I2C) WriteRegS16BE

func (i2c *I2C) WriteRegS16BE(reg byte, value int16) error

WriteRegS16BE writes signed big endian word (16 bits) value to I2C-device starting from address specified in reg.

func (*I2C) WriteRegS16LE

func (i2c *I2C) WriteRegS16LE(reg byte, value int16) error

WriteRegS16LE writes signed little endian word (16 bits) value to I2C-device starting from address specified in reg.

func (*I2C) WriteRegU16BE

func (i2c *I2C) WriteRegU16BE(reg byte, value uint16) error

WriteRegU16BE writes unsigned big endian word (16 bits) value to I2C-device starting from address specified in reg.

func (*I2C) WriteRegU16LE

func (i2c *I2C) WriteRegU16LE(reg byte, value uint16) error

WriteRegU16LE writes unsigned little endian word (16 bits) value to I2C-device starting from address specified in reg.

func (*I2C) WriteRegU24BE

func (i2c *I2C) WriteRegU24BE(reg byte, value uint32) error

WriteRegU24BE writes unsigned big endian word (24 bits) value to I2C-device starting from address specified in reg.

func (*I2C) WriteRegU32BE

func (i2c *I2C) WriteRegU32BE(reg byte, value uint32) error

WriteRegU32BE writes unsigned big endian word (32 bits) value to I2C-device starting from address specified in reg.

func (*I2C) WriteRegU8

func (i2c *I2C) WriteRegU8(reg byte, value byte) error

WriteRegU8 writes byte to I2C-device register specified in reg.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL