exp: golang.org/x/exp/io/i2c Index | Files | Directories

package i2c

import "golang.org/x/exp/io/i2c"

Package i2c allows users to read from an write to a slave I2C device.

Index

Package Files

devfs.go i2c.go

type Devfs

type Devfs struct{}

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

func (d *Devfs) Open(bus, addr int) (driver.Conn, error)

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

func Open(o driver.Opener, bus, addr int) (*Device, error)

Open opens an I2C device with the given I2C address on the specified bus.

func (*Device) Close

func (d *Device) Close() error

Close closes the device and releases the underlying sources. All devices must be closed once they are no longer in use.

func (*Device) Read

func (d *Device) Read(cmd byte, buf []byte) error

Read reads at most len(buf) number of bytes from the device for the given command.

func (*Device) Write

func (d *Device) Write(cmd byte, buf []byte) (err error)

Write writes the buffer for the given command to the device.

Directories

PathSynopsis
driverPackage driver contains interfaces to be implemented by various I2C implementations.

Package i2c imports 5 packages (graph). Updated about 17 hours ago. Refresh now. Tools for package owners.