mirror of
https://github.com/kidoman/embd
synced 2025-07-03 03:47:33 +02:00
simplify package structure
This commit is contained in:
parent
3cae4064dc
commit
36f2c0486d
41 changed files with 736 additions and 885 deletions
26
descriptor.go
Normal file
26
descriptor.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue