package i2c
import "golang.org/x/exp/io/i2c"
Package i2c allows users to read from and write to a slave I2C device.
Deprecated
This package is not maintained anymore. An actively supported cross-platform alternative is https://periph.io/.
Index ¶
Examples ¶
Functions ¶
func TenBit ¶
TenBit marks an I2C address as a 10-bit address.
Types ¶
type Devfs ¶
type Devfs struct { // Dev is the I2C bus device, e.g. /dev/i2c-1. Required. Dev string }
Devfs is an I2C driver that works against the devfs. You need to load the "i2c-dev" kernel module to use this driver.
func (*Devfs) Open ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device represents an I2C device. Devices must be closed once they are no longer in use.
func Open ¶
Open opens a connection to an I2C device. All devices must be closed once they are no longer in use. For devices that use 10-bit I2C addresses, addr can be marked as a 10-bit address with TenBit.
func (*Device) Close ¶
Close closes the device and releases the underlying sources.
func (*Device) Read ¶
Read reads len(buf) bytes from the device.
func (*Device) ReadReg ¶
ReadReg is similar to Read but it reads from a register.
func (*Device) Write ¶
Write writes the buffer to the device. If it is required to write to a specific register, the register should be passed as the first byte in the given buffer.
func (*Device) WriteReg ¶
WriteReg is similar to Write but writes to a register.
Source Files ¶
devfs.go i2c.go
Directories ¶
Path | Synopsis |
---|---|
io/i2c/driver | Package driver contains interfaces to be implemented by various I2C implementations. |
io/i2c/example | |
io/i2c/example/displayip | Package main contains a program that displays the IPv4 address of the machine on an a Grove-LCD RGB backlight. |
- Version
- v0.0.0-20250218142911-aa4b98e5adaa (latest)
- Published
- Feb 18, 2025
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 2 days ago –
Tools for package owners.