Documentation
¶
Index ¶
- Constants
- type I2C
- func (v *I2C) Close() error
- func (v *I2C) GetAddr() uint8
- func (v *I2C) GetBus() int
- func (v *I2C) ReadBytes(buf []byte) (int, error)
- func (v *I2C) ReadRegBytes(reg byte, n int) ([]byte, int, error)
- func (v *I2C) ReadRegBytesWithDelay(reg byte, n int, delay time.Duration) ([]byte, int, error)
- func (v *I2C) ReadRegS16BE(reg byte) (int16, error)
- func (v *I2C) ReadRegS16BEWithDelay(reg byte, delay time.Duration) (int16, error)
- func (v *I2C) ReadRegS16LE(reg byte) (int16, error)
- func (v *I2C) ReadRegS16LEWithDelay(reg byte, delay time.Duration) (int16, error)
- func (v *I2C) ReadRegU16BE(reg byte) (uint16, error)
- func (v *I2C) ReadRegU16BEWithDelay(reg byte, delay time.Duration) (uint16, error)
- func (v *I2C) ReadRegU16LE(reg byte) (uint16, error)
- func (v *I2C) ReadRegU16LEWithDelay(reg byte, delay time.Duration) (uint16, error)
- func (v *I2C) ReadRegU8(reg byte) (byte, error)
- func (v *I2C) ReadRegU8WithDelay(reg byte, delay time.Duration) (byte, error)
- func (v *I2C) WriteBytes(buf []byte) (int, error)
- func (v *I2C) WriteRegS16BE(reg byte, value int16) error
- func (v *I2C) WriteRegS16LE(reg byte, value int16) error
- func (v *I2C) WriteRegU16BE(reg byte, value uint16) error
- func (v *I2C) WriteRegU16LE(reg byte, value uint16) error
- func (v *I2C) WriteRegU8(reg byte, value byte) error
Constants ¶
const ( // DefaultReadDelay 默认的写入指令与读取数据之间的延迟 // DefaultReadDelay Default delay between write cmd and read from bus DefaultReadDelay = 0 )
const (
I2C_SLAVE = C.I2C_SLAVE
)
Get I2C_SLAVE constant value from Linux OS I2C declaration file.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type I2C ¶
type I2C struct {
// contains filtered or unexported fields
}
I2C 此结构体用于存储访问的i2c设备的信息
I2C represents a connection to I2C-device.
func NewI2C ¶
NewI2C 此方法用于打开一个i2c句柄 bus为系统的i2c接口的id addr为要访问的设备在bus上的地址
NewI2C 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 从器件读取数据,返回读取的数据长度 ReadBytes read bytes from I2C-device. Number of bytes read correspond to buf parameter length.
func (*I2C) ReadRegBytes ¶
ReadRegBytes 从器件读取n字节数据 ReadRegBytes read count of n byte's sequence from I2C-device starting from reg address. SMBus (System Management Bus) protocol over I2C.
func (*I2C) ReadRegBytesWithDelay ¶
ReadRegBytesWithDelay 从器件读取n字节数据,在发送读取指令和读取之间附带延迟 ReadRegBytesWithDelay read count of n byte's sequence from I2C-device starting from reg address with delay between send and read. SMBus (System Management Bus) protocol over I2C.
func (*I2C) ReadRegS16BE ¶
ReadRegS16BE 从器件读取2字节有符号数据(大端优先) ReadRegS16BE reads signed big endian word (16 bits) from I2C-device starting from address specified in reg. SMBus (System Management Bus) protocol over I2C.
func (*I2C) ReadRegS16BEWithDelay ¶
ReadRegS16BEWithDelay 从器件读取2字节有符号数据(大端优先),在发送读取指令和读取之间附带延迟 ReadRegS16BEWithDelay reads signed big endian word (16 bits) from I2C-device starting from address specified in reg with delay between send and read. SMBus (System Management Bus) protocol over I2C.
func (*I2C) ReadRegS16LE ¶
ReadRegS16LE 从器件读取2字节有符号数据(小端优先) ReadRegS16LE reads signed little endian word (16 bits) from I2C-device starting from address specified in reg. SMBus (System Management Bus) protocol over I2C.
func (*I2C) ReadRegS16LEWithDelay ¶
ReadRegS16LEWithDelay 从器件读取2字节有符号数据(小端优先),在发送读取指令和读取之间附带延迟 ReadRegS16LEWithDelay reads signed little endian word (16 bits) from I2C-device starting from address specified in reg with delay between send and read. SMBus (System Management Bus) protocol over I2C.
func (*I2C) ReadRegU16BE ¶
ReadRegU16BE 从器件读取2字节无符号数据(大端优先) ReadRegU16BE reads unsigned big endian word (16 bits) from I2C-device starting from address specified in reg. SMBus (System Management Bus) protocol over I2C.
func (*I2C) ReadRegU16BEWithDelay ¶
ReadRegU16BEWithDelay 从器件读取2字节无符号数据(大端优先),在发送读取指令和读取之间附带延迟 ReadRegU16BEWithDelay reads unsigned big endian word (16 bits) from I2C-device starting from address specified in reg with delay between send and read. SMBus (System Management Bus) protocol over I2C.
func (*I2C) ReadRegU16LE ¶
ReadRegU16LE 从器件读取2字节无符号数据(小端优先) ReadRegU16LE reads unsigned little endian word (16 bits) from I2C-device starting from address specified in reg. SMBus (System Management Bus) protocol over I2C.
func (*I2C) ReadRegU16LEWithDelay ¶
ReadRegU16LEWithDelay 从器件读取2字节无符号数据(小端优先),在发送读取指令和读取之间附带延迟 ReadRegU16LEWithDelay reads unsigned little endian word (16 bits) from I2C-device starting from address specified in reg with delay between send and read. SMBus (System Management Bus) protocol over I2C.
func (*I2C) ReadRegU8 ¶
ReadRegU8 从器件读取1字节数据 ReadRegU8 reads byte from I2C-device register specified in reg. SMBus (System Management Bus) protocol over I2C.
func (*I2C) ReadRegU8WithDelay ¶
ReadRegU8WithDelay 从器件读取1字节数据,在发送读取指令和读取之间附带延迟 ReadRegU8WithDelay reads byte from I2C-device register specified in reg with delay between send and read. SMBus (System Management Bus) protocol over I2C.
func (*I2C) WriteBytes ¶
WriteBytes 向器件发送数据 WriteBytes send bytes to the remote I2C-device. The interpretation of the message is implementation-dependent.
func (*I2C) WriteRegS16BE ¶
WriteRegS16BE 向器件写入2字节有符号数据(大端优先) WriteRegS16BE writes signed big endian word (16 bits) value to I2C-device starting from address specified in reg. SMBus (System Management Bus) protocol over I2C.
func (*I2C) WriteRegS16LE ¶
WriteRegS16LE 向器件写入2字节有符号数据(小端优先) WriteRegS16LE writes signed little endian word (16 bits) value to I2C-device starting from address specified in reg. SMBus (System Management Bus) protocol over I2C.
func (*I2C) WriteRegU16BE ¶
WriteRegU16BE 向器件写入2字节无符号数据(大端优先) WriteRegU16BE writes unsigned big endian word (16 bits) value to I2C-device starting from address specified in reg. SMBus (System Management Bus) protocol over I2C.
func (*I2C) WriteRegU16LE ¶
WriteRegU16LE 向器件写入2字节无符号数据(小端优先) WriteRegU16LE writes unsigned little endian word (16 bits) value to I2C-device starting from address specified in reg. SMBus (System Management Bus) protocol over I2C.