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

make the process of registered available hosts less clunky

This commit is contained in:
Karan Misra 2014-02-27 05:59:38 +05:30
parent 2504678ba9
commit ef87ad7879
7 changed files with 66 additions and 69 deletions

View file

@ -7,23 +7,20 @@ import (
"github.com/kidoman/embd/i2c"
)
type descriptor struct {
rev int
func init() {
host.Describers[host.RPi] = describer
}
func (d *descriptor) GPIO() gpio.GPIO {
func describer(rev int) *host.Descriptor {
var pins = rev1Pins
if d.rev > 1 {
pins = rev2Pins
}
return lgpio.New(pins)
}
func (d *descriptor) I2C() i2c.I2C {
return li2c.New()
}
func Descriptor(rev int) *descriptor {
return &descriptor{rev}
return &host.Descriptor{
GPIO: func() gpio.GPIO {
return lgpio.New(pins)
},
I2C: li2c.New,
}
}