i2c

package module
v0.0.0-...-d67f8c3 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2017 License: MIT Imports: 7 Imported by: 4

README

A golang i2c Interface for linux.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type I2CBus

type I2CBus interface {
	// ReadByte reads a byte from the given address.
	// S Addr Rd {A} {value} NA P
	ReadByte(addr byte) (value byte, err error)
	// WriteByte writes a byte to the given address.
	// S Addr Wr {A} value {A} P
	WriteByte(addr, value byte) error
	// WriteBytes writes a slice bytes to the given address.
	// S Addr Wr {A} value[0] {A} value[1] {A} ... {A} value[n] {A} NA P
	WriteBytes(addr byte, value []byte) error
	ReadBytes(addr byte, rxbuff []byte) error
	// ReadFromReg reads n (len(value)) bytes from the given address and register.
	ReadFromReg(addr, reg byte, value []byte) error
	// ReadByteFromReg reads a byte from the given address and register.
	ReadByteFromReg(addr, reg byte) (value byte, err error)
	// ReadU16FromReg reads a unsigned 16 bit integer from the given address and register.
	ReadWordFromReg(addr, reg byte) (value uint16, err error)
	ReadWordFromRegLSBF(addr, reg byte) (value uint16, err error)
	// WriteToReg writes len(value) bytes to the given address and register.
	WriteToReg(addr, reg byte, value []byte) error
	// WriteByteToReg writes a byte to the given address and register.
	WriteByteToReg(addr, reg, value byte) error
	// WriteU16ToReg
	WriteWordToReg(addr, reg byte, value uint16) error
	// Close releases the resources associated with the bus.
	Close() error
}

S (1 bit) : Start bit P (1 bit) : Stop bit Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. A, NA (1 bit) : Accept and reverse accept bit. Addr (7 bits): I2C 7 bit address. Note that this can be expanded as usual to

get a 10 bit I2C address.

Comm (8 bits): Command byte, a data byte which often selects a register on

the device.

Data (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh

for 16 bit data.

Count (8 bits): A data byte containing the length of a block operation. {..}: Data sent by I2C slave, as opposed to data sent by master.

func NewI2CBus

func NewI2CBus(l byte) I2CBus

Returns New i2c interfce on bus use i2cdetect to find out which bus you to use

Jump to

Keyboard shortcuts

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