1
0
Fork 0
mirror of https://github.com/kidoman/embd synced 2025-07-03 20:07:40 +02:00

make the framework easier to begin with

This commit is contained in:
Karan Misra 2014-03-01 20:19:44 +05:30
parent ef87ad7879
commit 3d08995000
26 changed files with 237 additions and 170 deletions

View file

@ -1,6 +1,8 @@
// Package i2c enables gophers i2c speaking ability.
package i2c
import "github.com/kidoman/embd/host"
type Bus interface {
// ReadByte reads a byte from the given address.
ReadByte(addr byte) (value byte, err error)
@ -29,3 +31,24 @@ type I2C interface {
Close() error
}
var instance I2C
func Open() error {
desc, err := host.Describe()
if err != nil {
return err
}
instance = desc.I2C().(I2C)
return nil
}
func Close() error {
return instance.Close()
}
func NewBus(l byte) Bus {
return instance.Bus(l)
}