Documentation ¶
Overview ¶
Package i2c provides an interface to Linux I2C devices.
Index ¶
- Constants
- func Do(index, slave int, f func(bus *Bus) error) (err error)
- type Bus
- func (b *Bus) Close() (err error)
- func (b *Bus) Do(rw RW, command uint8, size SMBusSize, data *SMBusData) (err error)
- func (b *Bus) ForceSlaveAddress(n int) error
- func (b *Bus) GetFeatures() (mask FeatureFlag, err error)
- func (b *Bus) Open(index int) (err error)
- func (b *Bus) Read(cmd uint8, size SMBusSize, data *SMBusData) (err error)
- func (bus *Bus) ReadBlock(offset, n int, delay time.Duration) ([]byte, error)
- func (b *Bus) ReadWrite(rw RW, command uint8, size SMBusSize, data *SMBusData) (err error)
- func (b *Bus) Send(messages []Message) (err error)
- func (b *Bus) Set10BitAddressing() error
- func (b *Bus) Set7BitAddressing() error
- func (b *Bus) SetRetries(n int) error
- func (b *Bus) SetSlaveAddress(n int) error
- func (b *Bus) SetTimeout(n int) error
- func (b *Bus) Write(cmd uint8, size SMBusSize, data *SMBusData) (err error)
- type FeatureFlag
- type IoctlOp
- type Message
- type MessageFlags
- type RW
- type SMBusData
- type SMBusSize
Constants ¶
View Source
const BlockMax = SMBusMax + 2
View Source
const License = `` /* 15871-byte string literal not displayed */
View Source
const SMBusMax = 32
View Source
const SendMaxMsgs = 42
View Source
const Version = "v1.1.0"
Version format :: v<MAJOR>.<MINOR>.<PATCH>[-rc<CANDIDATE>]
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
func (*Bus) ForceSlaveAddress ¶
func (*Bus) GetFeatures ¶
func (b *Bus) GetFeatures() (mask FeatureFlag, err error)
func (*Bus) Set10BitAddressing ¶
func (*Bus) Set7BitAddressing ¶
func (*Bus) SetRetries ¶
func (*Bus) SetSlaveAddress ¶
func (*Bus) SetTimeout ¶
type FeatureFlag ¶
type FeatureFlag uint32
Functionality (features)
const ( I2C FeatureFlag = 0x00000001 TenBit_Address FeatureFlag = 0x00000002 Protocol_Mangling FeatureFlag = 0x00000004 /* I2C_M_IGNORE_NAK etc. */ SMBUS_PEC FeatureFlag = 0x00000008 No_Start FeatureFlag = 0x00000010 /* I2C_M_NOSTART */ Slave FeatureFlag = 0x00000020 SMBUS_Block_Proc_Call FeatureFlag = 0x00008000 /* SMBus 2.0 */ SMBUS_Quick FeatureFlag = 0x00010000 SMBUS_Read_Byte FeatureFlag = 0x00020000 SMBUS_Write_Byte FeatureFlag = 0x00040000 SMBUS_Read_Byte_Data FeatureFlag = 0x00080000 SMBUS_Write_Byte_Data FeatureFlag = 0x00100000 SMBUS_Read_Word_Data FeatureFlag = 0x00200000 SMBUS_Write_Word_Data FeatureFlag = 0x00400000 SMBUS_Proc_Call FeatureFlag = 0x00800000 SMBUS_Read_Block_Data FeatureFlag = 0x01000000 SMBUS_Write_Block_Data FeatureFlag = 0x02000000 SMBUS_Read_I2C_Block FeatureFlag = 0x04000000 /* I2C-like block xfer with 1-byte register address. */ SMBUS_Write_I2C_Block FeatureFlag = 0x08000000 )
func (FeatureFlag) String ¶
func (x FeatureFlag) String() string
type IoctlOp ¶
type IoctlOp uintptr
/dev/i2c-X ioctl commands. The ioctl's parameter is always an unsigned long, except for:
- I2C_FUNCS, takes pointer to an unsigned long
- I2C_RDWR, takes pointer to struct i2c_rdwr_ioctl_data
- I2C_SMBUS, takes pointer to struct i2c_smbus_ioctl_data
const ( I2C_RETRIES IoctlOp = 0x0701 /* number of times a device address should be polled when not acknowledging */ I2C_TIMEOUT IoctlOp = 0x0702 /* Set timeout in units of 10 ms */ I2C_SLAVE IoctlOp = 0x0703 /* Use this slave address */ I2C_SLAVE_FORCE IoctlOp = 0x0706 /* Use this slave address, even if it is already in use by a driver. */ I2C_TENBIT IoctlOp = 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ I2C_FUNCS IoctlOp = 0x0705 /* Get the adapter functionality mask */ I2C_RDWR IoctlOp = 0x0707 /* Combined R/W transfer (one STOP only) */ I2C_PEC IoctlOp = 0x0708 /* != 0 to use PEC with SMBus */ I2C_SMBUS IoctlOp = 0x0720 /* SMBus transfer */ )
type Message ¶
type Message struct { Address uint16 Flags MessageFlags Data []byte }
type MessageFlags ¶
type MessageFlags uint16
const ( ReadData MessageFlags = 0x0001 /* read data, from slave to master; else write */ TenBit MessageFlags = 0x0010 /* this is a ten bit chip address */ Stop MessageFlags = 0x8000 /* if feature Protocol_Mangling */ NoStart MessageFlags = 0x4000 /* if feature No_Start */ Rev_Dir_Addr MessageFlags = 0x2000 /* if feature Protocol_Mangling */ Ignore_NAK MessageFlags = 0x1000 /* if feature Protocol_Mangling */ No_Read_ACK MessageFlags = 0x0800 /* if feature Protocol_Mangling */ Recv_Len MessageFlags = 0x0400 /* length will be first received byte */ )
type SMBusSize ¶
type SMBusSize uint32
SMBus transaction types (size parameter in the above functions)
Note: these no longer correspond to the (arbitrary) PIIX4 internal codes!
const ( // This sends a single bit to the device, at the place of the Rd/Wr bit. Quick SMBusSize = 0 // This reads a single byte from a device, without specifying a device register. Byte SMBusSize = 1 // This reads a single byte from a device, from a designated register. // The register is specified through the Comm byte. ByteData SMBusSize = 2 // As above but 2 bytes of data. WordData SMBusSize = 3 // This command selects a device register (through the Comm byte), sends // 16 bits of data to it, and reads 16 bits of data in return. ProcCall SMBusSize = 4 // This command reads/writes a block of up to 32 bytes from a device, from a // designated register that is specified through the Comm byte. The amount // of data is specified by first byte of data. BlockData SMBusSize = 5 I2CBlockBroken SMBusSize = 6 // This command selects a device register (through the Comm byte), sends // 1 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return. // SMBus 2.0 BlockProcCall SMBusSize = 7 I2CBlockData SMBusSize = 8 )
Click to show internal directories.
Click to hide internal directories.