func init() { embd.Register(embd.HostRPi, func(rev int) *embd.Descriptor { // Refer to http://elinux.org/RPi_HardwareHistory#Board_Revision_History // for details. pins := rev3Pins if rev < 16 { pins = rev2Pins } if rev < 4 { pins = rev1Pins } return &embd.Descriptor{ GPIODriver: func() embd.GPIODriver { return embd.NewGPIODriver(pins, generic.NewDigitalPin, nil, nil) }, I2CDriver: func() embd.I2CDriver { return embd.NewI2CDriver(generic.NewI2CBus) }, LEDDriver: func() embd.LEDDriver { return embd.NewLEDDriver(ledMap, generic.NewLED) }, SPIDriver: func() embd.SPIDriver { return embd.NewSPIDriver(spiDeviceMinor, generic.NewSPIBus, nil) }, } }) }
func init() { embd.Register(BotanistGwHost, func(rev int) *embd.Descriptor { return &embd.Descriptor{ GPIODriver: func() embd.GPIODriver { return embd.NewGPIODriver(pins, NewDigitalPin, nil, nil) }, I2CDriver: func() embd.I2CDriver { return embd.NewI2CDriver(generic.NewI2CBus) }, SPIDriver: func() embd.SPIDriver { return embd.NewSPIDriver(spiDeviceMinor, generic.NewSPIBus, nil) }, } }) }
func init() { embd.Register(embd.HostBBB, func(rev int) *embd.Descriptor { return &embd.Descriptor{ GPIODriver: func() embd.GPIODriver { return embd.NewGPIODriver(pins, generic.NewDigitalPin, newAnalogPin, newPWMPin) }, I2CDriver: func() embd.I2CDriver { return embd.NewI2CDriver(generic.NewI2CBus) }, LEDDriver: func() embd.LEDDriver { return embd.NewLEDDriver(ledMap, generic.NewLED) }, SPIDriver: func() embd.SPIDriver { return embd.NewSPIDriver(spiDeviceMinor, generic.NewSPIBus) }, } }) }
func TestPWMPinClose(t *testing.T) { pinMap := embd.PinMap{ &embd.PinDesc{ID: "P1_1", Aliases: []string{"1"}, Caps: embd.CapPWM}, } driver := embd.NewGPIODriver(pinMap, nil, nil, newPWMPin) pin, err := driver.PWMPin(1) if err != nil { t.Fatalf("Looking up pwm pin 1: got %v", err) } pin.Close() pin2, err := driver.PWMPin(1) if err != nil { t.Fatalf("Looking up pwm pin 1: got %v", err) } if pin == pin2 { t.Fatal("Looking up closed pwm pin 1: but got the old instance") } }
func init() { embd.Register(embd.HostCHIP, func(rev int) *embd.Descriptor { return &embd.Descriptor{ GPIODriver: func() embd.GPIODriver { return embd.NewGPIODriver(chipPins, generic.NewDigitalPin, nil, nil) }, I2CDriver: func() embd.I2CDriver { return embd.NewI2CDriver(generic.NewI2CBus) }, //LEDDriver: func() embd.LEDDriver { // return embd.NewLEDDriver(ledMap, generic.NewLED) //}, SPIDriver: func() embd.SPIDriver { return embd.NewSPIDriver(spiDeviceMinor, generic.NewSPIBus, nil) }, } }) }
func init() { embd.Register(embd.HostRPi, func(rev int) *embd.Descriptor { var pins = rev1Pins if rev > 1 { pins = rev2Pins } return &embd.Descriptor{ GPIODriver: func() embd.GPIODriver { return embd.NewGPIODriver(pins, generic.NewDigitalPin, nil, nil) }, I2CDriver: func() embd.I2CDriver { return embd.NewI2CDriver(generic.NewI2CBus) }, LEDDriver: func() embd.LEDDriver { return embd.NewLEDDriver(ledMap, generic.NewLED) }, SPIDriver: func() embd.SPIDriver { return embd.NewSPIDriver(spiDeviceMinor, generic.NewSPIBus) }, } }) }