1
0
mirror of https://github.com/kidoman/embd synced 2024-10-31 23:38:44 +01:00
embd/descriptor.go
2014-03-03 00:51:23 +05:30

27 lines
421 B
Go

package embd
import "fmt"
type Descriptor struct {
GPIO func() GPIO
I2C func() I2C
}
type Describer func(rev int) *Descriptor
var Describers = map[Host]Describer{}
func DescribeHost() (*Descriptor, error) {
host, rev, err := DetectHost()
if err != nil {
return nil, err
}
describer, ok := Describers[host]
if !ok {
return nil, fmt.Errorf("host: invalid host %q", host)
}
return describer(rev), nil
}