1
0
mirror of https://github.com/kidoman/embd synced 2025-01-05 03:21:35 +01:00
embd/descriptor.go

27 lines
421 B
Go
Raw Normal View History

2014-03-03 00:51:23 +05:30
package embd
2014-03-02 19:39:30 +05:30
import "fmt"
type Descriptor struct {
2014-03-03 00:51:23 +05:30
GPIO func() GPIO
I2C func() I2C
}
type Describer func(rev int) *Descriptor
var Describers = map[Host]Describer{}
2014-03-03 00:51:23 +05:30
func DescribeHost() (*Descriptor, error) {
host, rev, err := DetectHost()
if err != nil {
return nil, err
}
describer, ok := Describers[host]
if !ok {
2014-03-02 19:39:30 +05:30
return nil, fmt.Errorf("host: invalid host %q", host)
}
return describer(rev), nil
}