pocketbeagle: add support for PocketBeagle

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2017-12-19 13:42:49 +01:00
parent 165a6f8798
commit b5e6f8e422
8 changed files with 168 additions and 6 deletions

View File

@ -187,7 +187,8 @@ Gobot has a extensible system for connecting to hardware devices. The following
- [Arduino](http://www.arduino.cc/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/firmata) - [Arduino](http://www.arduino.cc/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/firmata)
- Audio <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/audio) - Audio <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/audio)
- [Beaglebone Black](http://beagleboard.org/Products/BeagleBone+Black/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/beaglebone) - [Beaglebone Black](http://beagleboard.org/boards) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/beaglebone)
- [Beaglebone PocketBeagle](http://beagleboard.org/pocket/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/beaglebone)
- [Bluetooth LE](https://www.bluetooth.com/what-is-bluetooth-technology/bluetooth-technology-basics/low-energy) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/ble) - [Bluetooth LE](https://www.bluetooth.com/what-is-bluetooth-technology/bluetooth-technology-basics/low-energy) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/ble)
- [C.H.I.P](http://www.nextthing.co/pages/chip) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/chip) - [C.H.I.P](http://www.nextthing.co/pages/chip) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/chip)
- [C.H.I.P Pro](https://docs.getchip.com/chip_pro.html) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/chip) - [C.H.I.P Pro](https://docs.getchip.com/chip_pro.html) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/chip)

View File

@ -2,10 +2,14 @@
The BeagleBone is an ARM based single board computer, with lots of GPIO, I2C, and analog interfaces built in. The BeagleBone is an ARM based single board computer, with lots of GPIO, I2C, and analog interfaces built in.
The Gobot adaptor for the BeagleBone should support all of the various BeagleBone boards such as the BeagleBone Black, SeeedStudio BeagleBone Green, SeeedStudio BeagleBone Green Wireless, and others that use the latest Debian and standard "Cape Manager" interfaces. The Gobot adaptor for the BeagleBone supports all of the various BeagleBone boards such as the BeagleBone Black, SeeedStudio BeagleBone Green, SeeedStudio BeagleBone Green Wireless, and others that use the latest Debian and standard "Cape Manager" interfaces.
For more info about the BeagleBone platform go to [http://beagleboard.org/getting-started](http://beagleboard.org/getting-started). For more info about the BeagleBone platform go to [http://beagleboard.org/getting-started](http://beagleboard.org/getting-started).
In addition, there is an separate Adaptor for the PocketBeagle, a USB-key-fob sized computer. The PocketBeagle has a different pin layout and somewhat different capabilities.
For more info about the PocketBeagle platform go to [http://beagleboard.org/pocket](http://beagleboard.org/pocket).
## How to Install ## How to Install
@ -54,6 +58,39 @@ func main() {
} }
``` ```
To use the PocketBeagle, use `beaglebone.NewPocketBeagleAdaptor()` like this:
```go
package main
import (
"time"
"gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/gpio"
"gobot.io/x/gobot/platforms/beaglebone"
)
func main() {
beagleboneAdaptor := beaglebone.NewPocketBeagleAdaptor()
led := gpio.NewLedDriver(beagleboneAdaptor, "P1_2")
work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}
robot := gobot.NewRobot("pocketBeagleBot",
[]gobot.Connection{beagleboneAdaptor},
[]gobot.Device{led},
work,
)
robot.Start()
}
```
## How to Connect ## How to Connect
### Compiling ### Compiling

View File

@ -23,7 +23,7 @@ type pwmPinData struct {
const pwmDefaultPeriod = 500000 const pwmDefaultPeriod = 500000
// Adaptor is the gobot.Adaptor representation for the Beaglebone // Adaptor is the gobot.Adaptor representation for the Beaglebone Black/Green
type Adaptor struct { type Adaptor struct {
name string name string
digitalPins []*sysfs.DigitalPin digitalPins []*sysfs.DigitalPin
@ -39,10 +39,10 @@ type Adaptor struct {
findPin func(pinPath string) (string, error) findPin func(pinPath string) (string, error)
} }
// NewAdaptor returns a new Beaglebone Adaptor // NewAdaptor returns a new Beaglebone Black/Green Adaptor
func NewAdaptor() *Adaptor { func NewAdaptor() *Adaptor {
b := &Adaptor{ b := &Adaptor{
name: gobot.DefaultName("Beaglebone"), name: gobot.DefaultName("BeagleboneBlack"),
digitalPins: make([]*sysfs.DigitalPin, 120), digitalPins: make([]*sysfs.DigitalPin, 120),
pwmPins: make(map[string]*sysfs.PWMPin), pwmPins: make(map[string]*sysfs.PWMPin),
i2cBuses: make(map[int]i2c.I2cDevice), i2cBuses: make(map[int]i2c.I2cDevice),

View File

@ -257,3 +257,8 @@ func TestBeagleboneDigitalPinFinalizeFileError(t *testing.T) {
err = a.Finalize() err = a.Finalize()
gobottest.Assert(t, strings.Contains(err.Error(), "/sys/class/gpio/unexport: No such file."), true) gobottest.Assert(t, strings.Contains(err.Error(), "/sys/class/gpio/unexport: No such file."), true)
} }
func TestPocketBeagleAdaptorName(t *testing.T) {
a := NewPocketBeagleAdaptor()
gobottest.Assert(t, strings.HasPrefix(a.Name(), "PocketBeagle"), true)
}

View File

@ -1,5 +1,6 @@
/* /*
Package beaglebone provides the Gobot adaptor for the Beaglebone Black. Package beaglebone provides the Gobot adaptor for the Beaglebone Black/Green, as well as a
separate Adaptor for the PocketBeagle.
Installing: Installing:

View File

@ -0,0 +1,24 @@
package beaglebone
import "gobot.io/x/gobot"
// PocketBeagleAdaptor is the Gobot Adaptor for the PocketBeagle
// For more information check out:
// http://beagleboard.org/pocket
//
type PocketBeagleAdaptor struct {
*Adaptor
}
// NewPocketBeagleAdaptor creates a new Adaptor for the PocketBeagle
func NewPocketBeagleAdaptor() *PocketBeagleAdaptor {
a := NewAdaptor()
a.SetName(gobot.DefaultName("PocketBeagle"))
a.pinMap = pocketBeaglePinMap
a.pwmPinMap = pocketBeaglePwmPinMap
a.analogPinMap = pocketBeagleAnalogPinMap
return &PocketBeagleAdaptor{
Adaptor: a,
}
}

View File

@ -0,0 +1,94 @@
package beaglebone
var pocketBeaglePinMap = map[string]int{
// P1_1 - VIN
"P1_2": 87,
// P1_3 - USB1-V_EN
"P1_4": 89,
// P1_5 - USB1-VBUS
"P1_6": 5,
// P1_7 - USB1-VIN
"P1_8": 2,
// P1_9 - USB1-DN
"P1_10": 3,
// P1_11 - USB1-DP
"P1_12": 4,
// P1_13 - USB1-ID
// P1_14 - 3.3V
// P1_15 - USB1-GND
// P1_16 - GND
// P1_16 - AIN-VREF-
// P1_18 - AIN-VREF+
// P1_19 - AIO0
"P1_20": 20,
// P1_21 - AIO1
// P1_22 - GND
// P1_23 - AIO2
// P1_24 - VOUT-5V
// P1_25 - AIO3
"P1_26": 12,
// P1_27 - AIO4
"P1_28": 13,
"P1_29": 117,
"P1_30": 43,
"P1_31": 114,
"P1_32": 42,
"P1_33": 111,
"P1_34": 26,
"P1_35": 88,
"P1_36": 110,
"P2_1": 50,
"P2_2": 59,
"P2_3": 23,
"P2_4": 58,
"P2_5": 30,
"P2_6": 57,
"P2_7": 31,
"P2_8": 60,
"P2_9": 15,
"P2_10": 52,
"P2_11": 14,
// P2_12 - PWR-BTN
// P2_13 - VOUT
// P2_14 - BAT-VIN
// P2_15 - GND
// P2_16 - BAT-TEMP
"P2_17": 65,
"P2_18": 47,
"P2_19": 27,
"P2_20": 64,
// P2_21 - GND
"P2_22": 46,
// P2_23 - 3.3V
"P2_24": 44,
"P2_25": 41,
// P2_26 - NRST
"P2_27": 40,
"P2_28": 116,
"P2_29": 7,
"P2_30": 113,
"P2_31": 19,
"P2_32": 112,
"P2_33": 45,
"P2_34": 115,
"P2_35": 86,
// P2_36 - AIO7
}
var pocketBeaglePwmPinMap = map[string]pwmPinData{
"P1_33": {path: "/sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip*", channel: 1},
"P1_36": {path: "/sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip*", channel: 0},
"P2_1": {path: "/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip*", channel: 0},
"P2_3": {path: "/sys/devices/platform/ocp/48304000.epwmss/48304200.pwm/pwm/pwmchip*", channel: 1},
}
var pocketBeagleAnalogPinMap = map[string]string{
"P1_19": "in_voltage0_raw",
"P1_21": "in_voltage1_raw",
"P1_23": "in_voltage2_raw",
"P1_25": "in_voltage3_raw",
"P1_27": "in_voltage4_raw",
"P2_36": "in_voltage7_raw",
}