From de0ad53f3fda269de5ed7c74a8eff3069f21ae6a Mon Sep 17 00:00:00 2001 From: Karan Misra Date: Thu, 15 Jan 2015 06:55:55 +0530 Subject: [PATCH] rpi: add support for rpi a+/b+ --- README.md | 4 ++-- host/rpi/rpi.go | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ed8ade3..5213924 100644 --- a/README.md +++ b/README.md @@ -66,9 +66,9 @@ Join the [mailing list](https://groups.google.com/forum/#!forum/go-embd) ## Platforms Supported -* [RaspberryPi](http://www.raspberrypi.org/) +* [RaspberryPi](http://www.raspberrypi.org/) (including [A+](http://www.raspberrypi.org/products/model-a-plus/) and [B+](http://www.raspberrypi.org/products/model-b-plus/)) * [BeagleBone Black](http://beagleboard.org/Products/BeagleBone%20Black) -* [Intel Galileo](http://www.intel.com/content/www/us/en/do-it-yourself/galileo-maker-quark-board.html) **coming soon** +* [Intel Edison](http://www.intel.com/content/www/us/en/do-it-yourself/galileo-maker-quark-board.html) **coming soon** * [Radxa](http://radxa.com/) **coming soon** * [Cubietruck](http://www.cubietruck.com/) **coming soon** * Bring Your Own **coming soon** diff --git a/host/rpi/rpi.go b/host/rpi/rpi.go index 372835b..940a4c2 100644 --- a/host/rpi/rpi.go +++ b/host/rpi/rpi.go @@ -1,5 +1,5 @@ /* - Package rpi provides Raspberry Pi support. + Package rpi provides Raspberry Pi (including A+/B+) support. The following features are supported on Linux kernel 3.8+ GPIO (digital (rw)) @@ -55,13 +55,29 @@ var rev2Pins = embd.PinMap{ &embd.PinDesc{ID: "P1_26", Aliases: []string{"7", "GPIO_7", "CE1", "SPI0_CE1_N"}, Caps: embd.CapDigital | embd.CapSPI, DigitalLogical: 7}, } +// This is the same as the Rev 2 for the first 26 pins. +var rev3Pins = append(append(embd.PinMap(nil), rev2Pins...), embd.PinMap{ + &embd.PinDesc{ID: "P1_29", Aliases: []string{"5", "GPIO_5"}, Caps: embd.CapDigital, DigitalLogical: 5}, + &embd.PinDesc{ID: "P1_31", Aliases: []string{"6", "GPIO_6"}, Caps: embd.CapDigital, DigitalLogical: 6}, + &embd.PinDesc{ID: "P1_32", Aliases: []string{"12", "GPIO_12"}, Caps: embd.CapDigital, DigitalLogical: 12}, + &embd.PinDesc{ID: "P1_33", Aliases: []string{"13", "GPIO_13"}, Caps: embd.CapDigital, DigitalLogical: 13}, + &embd.PinDesc{ID: "P1_35", Aliases: []string{"19", "GPIO_19"}, Caps: embd.CapDigital, DigitalLogical: 19}, + &embd.PinDesc{ID: "P1_36", Aliases: []string{"16", "GPIO_16"}, Caps: embd.CapDigital, DigitalLogical: 16}, + &embd.PinDesc{ID: "P1_37", Aliases: []string{"26", "GPIO_26"}, Caps: embd.CapDigital, DigitalLogical: 26}, + &embd.PinDesc{ID: "P1_38", Aliases: []string{"20", "GPIO_20"}, Caps: embd.CapDigital, DigitalLogical: 20}, + &embd.PinDesc{ID: "P1_40", Aliases: []string{"21", "GPIO_21"}, Caps: embd.CapDigital, DigitalLogical: 21}, +}...) + var ledMap = embd.LEDMap{ "led0": []string{"0", "led0", "LED0"}, } func init() { embd.Register(embd.HostRPi, func(rev int) *embd.Descriptor { - var pins = rev2Pins + pins := rev3Pins + if rev < 16 { + pins = rev2Pins + } if rev < 4 { pins = rev1Pins }