Documentation ¶
Index ¶
- func SwapBytes(word uint16) uint16
- type Err
- type I2C
- func (i2c *I2C) Address() int
- func (i2c *I2C) Close() error
- func (i2c *I2C) ProcessCall(register uint8, value uint16) (uint16, error)
- func (i2c *I2C) ProcessCallBlock(register uint8, block []byte) ([]byte, error)
- func (i2c *I2C) ProcessCallSwapped(register uint8, value uint16) (uint16, error)
- func (i2c *I2C) Read(p []byte) (n int, err error)
- func (i2c *I2C) ReadBlock(register uint8) ([]byte, error)
- func (i2c *I2C) ReadInt16Reg(register uint8) (int16, error)
- func (i2c *I2C) ReadInt16RegSwapped(register uint8) (int16, error)
- func (i2c *I2C) ReadInt8() (int8, error)
- func (i2c *I2C) ReadInt8Reg(register uint8) (int8, error)
- func (i2c *I2C) ReadUint16Reg(register uint8) (result uint16, err error)
- func (i2c *I2C) ReadUint16RegSwapped(register uint8) (result uint16, err error)
- func (i2c *I2C) ReadUint8() (result uint8, err error)
- func (i2c *I2C) ReadUint8Reg(register uint8) (result uint8, err error)
- func (i2c *I2C) SetAddress(address int) error
- func (i2c *I2C) Write(p []byte) (n int, err error)
- func (i2c *I2C) WriteBlock(register uint8, block []byte) error
- func (i2c *I2C) WriteInt16Reg(register uint8, value int16) error
- func (i2c *I2C) WriteInt16RegSwapped(register uint8, value int16) error
- func (i2c *I2C) WriteInt8(value int8) error
- func (i2c *I2C) WriteInt8Reg(register uint8, value int8) error
- func (i2c *I2C) WriteQuick(value uint8) error
- func (i2c *I2C) WriteUint16Reg(register uint8, value uint16) error
- func (i2c *I2C) WriteUint16RegSwapped(register uint8, value uint16) error
- func (i2c *I2C) WriteUint8(value uint8) error
- func (i2c *I2C) WriteUint8Reg(register uint8, value uint8) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type I2C ¶
type I2C struct {
// contains filtered or unexported fields
}
I2C is a port of https://github.com/bivab/smbus-cffi/
func (*I2C) ProcessCall ¶
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 ¶
ProcessCallBlock reads a block of up to 32 bytes from a device, from a designated register.
func (*I2C) ProcessCallSwapped ¶
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) ReadInt16Reg ¶
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 ¶
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 ¶
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 ¶
ReadInt8Reg reads a single byte from a device, from a designated register.
func (*I2C) ReadUint16Reg ¶
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 ¶
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 ¶
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 ¶
ReadUint8Reg reads a single byte from a device, from a designated register.
func (*I2C) SetAddress ¶
func (*I2C) WriteBlock ¶
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 ¶
WriteInt16Reg is the opposite of the ReadInt16Reg operation. 16 bits of data is written to a device, to the designated register.
func (*I2C) WriteInt16RegSwapped ¶
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) WriteInt8Reg ¶
WriteInt8Reg writes a single byte to a device, to a designated register.
func (*I2C) WriteQuick ¶
WriteQuick sends a single bit to the device, at the place of the Rd/Wr bit.
func (*I2C) WriteUint16Reg ¶
WriteUint16Reg is the opposite of the ReadUint16Reg operation. 16 bits of data is written to a device, to the designated register.
func (*I2C) WriteUint16RegSwapped ¶
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 ¶
WriteUint8 sends a single byte to a device.