Documentation
Overview ¶
Package i2c defines interface to an I²C bus and an I²C device.
It includes the adapter Dev to directly address an I²C device on a I²C bus without having to continuously specify the address when doing I/O. This enables the support of conn.Conn.
Index ¶
Examples ¶
Constants ¶
Variables ¶
Functions ¶
Types ¶
type Bus ¶
type Bus interface { Tx(addr uint16, w, r []byte) error // SetSpeed changes the bus speed, if supported. // // On linux due to the way the I²C sysfs driver is exposed in userland, // calling this function will likely affect *all* I²C buses on the host. SetSpeed(hz int64) error }
Bus defines the interface a concrete I²C driver must implement.
This interface is consummed by a device driver for a device sitting on a bus.
This interface doesn't implement conn.Conn since a device address must be specified. Use i2cdev.Dev as an adapter to get a conn.Conn compatible object.
type BusCloser ¶
BusCloser is an I²C bus that can be closed.
This interface is meant to be handled by the application and not the device driver. A device driver doesn't "own" a bus, hence it must operate on a Bus, not a BusCloser.
type Dev ¶
Dev is a device on a I²C bus.
It implements conn.Conn.
It saves from repeatedly specifying the device address.
Example ¶
Output:
type Pins ¶
type Pins interface { // SCL returns the CLK (clock) pin. SCL() gpio.PinIO // SDA returns the DATA pin. SDA() gpio.PinIO }
Pins defines the pins that an I²C bus interconnect is using on the host.
It is expected that a implementer of Bus also implement Pins but this is not a requirement.
Example ¶
Output:
Directories
Path | Synopsis |
---|---|
Package i2creg defines I²C bus registry to list buses present on the host.
|
Package i2creg defines I²C bus registry to list buses present on the host. |
Package i2csmoketest is leveraged by periph-smoketest to verify that an I²C EEPROM device and a DS2483 device can be accessed on an I²C bus.
|
Package i2csmoketest is leveraged by periph-smoketest to verify that an I²C EEPROM device and a DS2483 device can be accessed on an I²C bus. |
Package i2ctest is meant to be used to test drivers over a fake I²C bus.
|
Package i2ctest is meant to be used to test drivers over a fake I²C bus. |