1
0
mirror of https://github.com/kidoman/embd synced 2025-01-03 10:31:36 +01:00
embd/host/descriptor.go
2014-03-01 20:19:44 +05:30

27 lines
422 B
Go

package host
import "errors"
type Descriptor struct {
GPIO func() interface{}
I2C func() interface{}
}
type Describer func(rev int) *Descriptor
var Describers = map[Host]Describer{}
func Describe() (*Descriptor, error) {
host, rev, err := Detect()
if err != nil {
return nil, err
}
describer, ok := Describers[host]
if !ok {
return nil, errors.New("host: invalid host")
}
return describer(rev), nil
}