i2c

package
v0.0.0-...-2d0cc53 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2015 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SwapBytes

func SwapBytes(word uint16) uint16

Types

type Err

type Err struct {
	// contains filtered or unexported fields
}

func (Err) Error

func (err Err) Error() string

type I2C

type I2C struct {
	// contains filtered or unexported fields
}

I2C is a port of https://github.com/bivab/smbus-cffi/

func NewI2C

func NewI2C(bus, address int) (*I2C, error)

Connects the object to the specified SMBus.

func (*I2C) Address

func (i2c *I2C) Address() int

func (*I2C) Close

func (i2c *I2C) Close() error

func (*I2C) ProcessCall

func (i2c *I2C) ProcessCall(register uint8, value uint16) (uint16, error)

ProcessCall selects a device register (through the register byte), sends 16 bits of data to it, and reads 16 bits of data in return.

func (*I2C) ProcessCallBlock

func (i2c *I2C) ProcessCallBlock(register uint8, block []byte) ([]byte, error)

ProcessCallBlock reads a block of up to 32 bytes from a device, from a designated register.

func (*I2C) ProcessCallSwapped

func (i2c *I2C) ProcessCallSwapped(register uint8, value uint16) (uint16, error)

ProcessCallSwapped selects a device register (through the register byte), sends 16 bits of data to it, and reads 16 bits of data in return. The bytes of the 16 bit value will be swapped.

func (*I2C) Read

func (i2c *I2C) Read(p []byte) (n int, err error)

func (*I2C) ReadBlock

func (i2c *I2C) ReadBlock(register uint8) ([]byte, error)

ReadBlock writes up to 32 bytes to a device, to a designated register.

func (*I2C) ReadInt16Reg

func (i2c *I2C) ReadInt16Reg(register uint8) (int16, error)

ReadInt16Reg is very like ReadInt8Reg; again, data is read from a device, from a designated register. But this time, the data is a complete word (16 bits).

func (*I2C) ReadInt16RegSwapped

func (i2c *I2C) ReadInt16RegSwapped(register uint8) (int16, error)

ReadInt16RegSwapped is very like ReadInt8RegSwapped; again, data is read from a device, from a designated register. But this time, the data is a complete word (16 bits). The bytes of the 16 bit value will be swapped.

func (*I2C) ReadInt8

func (i2c *I2C) ReadInt8() (int8, error)

ReadInt8 reads a single byte from a device, without specifying a device register. Some devices are so simple that this interface is enough; for others, it is a shorthand if you want to read the same register as in the previous SMBus command.

func (*I2C) ReadInt8Reg

func (i2c *I2C) ReadInt8Reg(register uint8) (int8, error)

ReadInt8Reg reads a single byte from a device, from a designated register.

func (*I2C) ReadUint16Reg

func (i2c *I2C) ReadUint16Reg(register uint8) (result uint16, err error)

ReadUint16Reg is very like ReadUint8Reg; again, data is read from a device, from a designated register. But this time, the data is a complete word (16 bits).

func (*I2C) ReadUint16RegSwapped

func (i2c *I2C) ReadUint16RegSwapped(register uint8) (result uint16, err error)

ReadUint16RegSwapped is very like ReadUint8Reg; again, data is read from a device, from a designated register. But this time, the data is a complete word (16 bits). The bytes of the 16 bit value will be swapped.

func (*I2C) ReadUint8

func (i2c *I2C) ReadUint8() (result uint8, err error)

ReadUint8 reads a single byte from a device, without specifying a device register. Some devices are so simple that this interface is enough; for others, it is a shorthand if you want to read the same register as in the previous SMBus command.

func (*I2C) ReadUint8Reg

func (i2c *I2C) ReadUint8Reg(register uint8) (result uint8, err error)

ReadUint8Reg reads a single byte from a device, from a designated register.

func (*I2C) SetAddress

func (i2c *I2C) SetAddress(address int) error

func (*I2C) Write

func (i2c *I2C) Write(p []byte) (n int, err error)

func (*I2C) WriteBlock

func (i2c *I2C) WriteBlock(register uint8, block []byte) error

WriteBlock selects a device register, sends 1 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return.

func (*I2C) WriteInt16Reg

func (i2c *I2C) WriteInt16Reg(register uint8, value int16) error

WriteInt16Reg is the opposite of the ReadInt16Reg operation. 16 bits of data is written to a device, to the designated register.

func (*I2C) WriteInt16RegSwapped

func (i2c *I2C) WriteInt16RegSwapped(register uint8, value int16) error

WriteInt16RegSwapped is the opposite of the ReadInt16RegSwapped operation. 16 bits of data is written to a device, to the designated register. The bytes of the 16 bit value will be swapped.

func (*I2C) WriteInt8

func (i2c *I2C) WriteInt8(value int8) error

WriteInt8 sends a single byte to a device.

func (*I2C) WriteInt8Reg

func (i2c *I2C) WriteInt8Reg(register uint8, value int8) error

WriteInt8Reg writes a single byte to a device, to a designated register.

func (*I2C) WriteQuick

func (i2c *I2C) WriteQuick(value uint8) error

WriteQuick sends a single bit to the device, at the place of the Rd/Wr bit.

func (*I2C) WriteUint16Reg

func (i2c *I2C) WriteUint16Reg(register uint8, value uint16) error

WriteUint16Reg is the opposite of the ReadUint16Reg operation. 16 bits of data is written to a device, to the designated register.

func (*I2C) WriteUint16RegSwapped

func (i2c *I2C) WriteUint16RegSwapped(register uint8, value uint16) error

WriteUint16RegSwapped is the opposite of the ReadUint16RegSwapped operation. 16 bits of data is written to a device, to the designated register. The bytes of the 16 bit value will be swapped.

func (*I2C) WriteUint8

func (i2c *I2C) WriteUint8(value uint8) error

WriteUint8 sends a single byte to a device.

func (*I2C) WriteUint8Reg

func (i2c *I2C) WriteUint8Reg(register uint8, value uint8) error

WriteUint8Reg writes a single byte to a device, to a designated register.

Jump to

Keyboard shortcuts

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