diff --git a/bbb.go b/bbb.go index 85cf083..2a6ce55 100644 --- a/bbb.go +++ b/bbb.go @@ -19,20 +19,6 @@ import ( "time" ) -func init() { - Register(HostBBB, func(rev int) *Descriptor { - return &Descriptor{ - GPIODriver: func() GPIODriver { - return newGPIODriver(bbbPins, newDigitalPin, newBBBAnalogPin, newBBBPWMPin) - }, - I2CDriver: newI2CDriver, - LEDDriver: func() LEDDriver { - return newLEDDriver(bbbLEDMap) - }, - } - }) -} - var bbbPins = PinMap{ &PinDesc{ID: "P8_07", Aliases: []string{"66", "GPIO_66", "Caps: TIMER4"}, Caps: CapDigital | CapGPMC, DigitalLogical: 66}, &PinDesc{ID: "P8_08", Aliases: []string{"67", "GPIO_67", "TIMER7"}, Caps: CapDigital | CapGPMC, DigitalLogical: 67}, @@ -438,3 +424,17 @@ func (p *bbbPWMPin) Close() error { return nil } + +func init() { + Register(HostBBB, func(rev int) *Descriptor { + return &Descriptor{ + GPIODriver: func() GPIODriver { + return newGPIODriver(bbbPins, newDigitalPin, newBBBAnalogPin, newBBBPWMPin) + }, + I2CDriver: newI2CDriver, + LEDDriver: func() LEDDriver { + return newLEDDriver(bbbLEDMap) + }, + } + }) +} diff --git a/rpi.go b/rpi.go index 39a114d..218a8ae 100644 --- a/rpi.go +++ b/rpi.go @@ -6,22 +6,6 @@ package embd -func init() { - Register(HostRPi, func(rev int) *Descriptor { - var pins = rpiRev1Pins - if rev > 1 { - pins = rpiRev2Pins - } - - return &Descriptor{ - GPIODriver: func() GPIODriver { - return newGPIODriver(pins, newDigitalPin, nil, nil) - }, - I2CDriver: newI2CDriver, - } - }) -} - var rpiRev1Pins = PinMap{ &PinDesc{ID: "P1_3", Aliases: []string{"0", "GPIO_0", "SDA", "I2C0_SDA"}, Caps: CapDigital | CapI2C, DigitalLogical: 0}, &PinDesc{ID: "P1_5", Aliases: []string{"1", "GPIO_1", "SCL", "I2C0_SCL"}, Caps: CapDigital | CapI2C, DigitalLogical: 1}, @@ -61,3 +45,19 @@ var rpiRev2Pins = PinMap{ &PinDesc{ID: "P1_24", Aliases: []string{"8", "GPIO_8", "CE0", "SPI0_CE0_N"}, Caps: CapDigital | CapSPI, DigitalLogical: 8}, &PinDesc{ID: "P1_26", Aliases: []string{"7", "GPIO_7", "CE1", "SPI0_CE1_N"}, Caps: CapDigital | CapSPI, DigitalLogical: 7}, } + +func init() { + Register(HostRPi, func(rev int) *Descriptor { + var pins = rpiRev1Pins + if rev > 1 { + pins = rpiRev2Pins + } + + return &Descriptor{ + GPIODriver: func() GPIODriver { + return newGPIODriver(pins, newDigitalPin, nil, nil) + }, + I2CDriver: newI2CDriver, + } + }) +}