Package microchip implements drivers for a few I2C controlled IC's produced by Maxim Integrated. This package relies on x/exp/io/spi.
Drivers for the following IC's are implemented:
Sample usage:
package main
import (
"fmt"
"github.com/advancedclimatesystems/io/i2c/max"
"golang.org/x/exp/io/i2c"
)
func main() {
d, err := i2c.Open(&i2c.Devfs{
Dev: "/dev/i2c-0",
}, 0x1c)
if err != nil {
panic(fmt.Sprintf("failed to open device: %v", err))
}
defer d.Close()
// 2.5V is the input reference of the DAC.
dac, err := max.NewMAX5813(d, 2.5)
if err != nil {
panic(fmt.Sprintf("failed to create MAX5813: %v", err))
}
// Set output of channel 1 to 1.3V.
if err := dac.SetVoltage(1.3, 1); err != nil {
panic(fmt.Sprintf("failed to set voltage: %v", err))
}
// It's also possible to set output of a channel with digital output code.
if err := dac.SetInputCode(128, 1); err != nil {
panic(fmt.Sprintf("failed to set voltage using output code: %v", err))
}
}