1
0
mirror of https://github.com/kidoman/embd synced 2024-12-22 12:50:19 +01:00

more streamlining

This commit is contained in:
Karan Misra 2014-02-27 04:44:50 +05:30
parent b5e2d0acc7
commit 6ea4e31399
4 changed files with 11 additions and 13 deletions

View File

@ -1,4 +1,4 @@
package host
package embd
import (
"errors"
@ -8,13 +8,13 @@ import (
"github.com/kidoman/embd/i2c"
)
type Descriptor interface {
type descriptor interface {
GPIO() gpio.GPIO
I2C() i2c.I2C
}
func Describe() (Descriptor, error) {
host, rev, err := Detect()
func describeHost() (descriptor, error) {
host, rev, err := DetectHost()
if err != nil {
return nil, err
}

View File

@ -1,4 +1,4 @@
package host
package embd
import (
"fmt"
@ -49,7 +49,7 @@ func kernelVersion() (major, minor, patch int, err error) {
return
}
func Detect() (host Host, rev int, err error) {
func DetectHost() (host Host, rev int, err error) {
major, minor, patch, err := kernelVersion()
if err != nil {
return

5
hal.go
View File

@ -2,7 +2,6 @@ package embd
import (
"github.com/kidoman/embd/gpio"
"github.com/kidoman/embd/host"
"github.com/kidoman/embd/i2c"
)
@ -17,7 +16,7 @@ const (
)
func NewGPIO() (gpio.GPIO, error) {
desc, err := host.Describe()
desc, err := describeHost()
if err != nil {
return nil, err
}
@ -26,7 +25,7 @@ func NewGPIO() (gpio.GPIO, error) {
}
func NewI2C() (i2c.I2C, error) {
desc, err := host.Describe()
desc, err := describeHost()
if err != nil {
return nil, err
}

View File

@ -4,11 +4,10 @@ import (
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/host"
)
func main() {
h, _, err := host.Detect()
h, _, err := embd.DetectHost()
if err != nil {
return
}
@ -16,9 +15,9 @@ func main() {
var pinNo interface{}
switch h {
case host.BBB:
case embd.BBB:
pinNo = "P9_31"
case host.RPi:
case embd.RPi:
pinNo = 10
default:
panic("host not supported (yet :P)")