chip

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2017 License: Apache-2.0, Apache-2.0 Imports: 11 Imported by: 0

README

C.H.I.P.

The C.H.I.P. is a small, inexpensive ARM based single board computer, with many different IO interfaces available on the pin headers.

For documentation about the C.H.I.P. platform click here.

The C.H.I.P. Pro is a version of C.H.I.P. intended for use in embedded product development. Here is info about the C.H.I.P. Pro pin headers.

How to Install

We recommend updating to the latest Debian OS when using the C.H.I.P., however Gobot should also support older versions of the OS, should your application require this.

You would normally install Go and Gobot on your workstation. Once installed, cross compile your program on your workstation, transfer the final executable to your C.H.I.P and run the program on the C.H.I.P. itself as documented here.

go get -d -u gobot.io/x/gobot/...
PWM support

Note that PWM might not be available in your kernel. In that case, you can install the required device tree overlay from the command line using Gort CLI commands on the C.H.I.P device. Here are the steps:

Install the required patched device tree compiler as described in the C.H.I.P docs:

gort chip install dtc

Now, install the pwm overlay to activate pwm on the PWM0 pin:

gort chip install pwm

Reboot the device to make sure the init script loads the overlay on boot.

How to Use

The pin numbering used by your Gobot program should match the way your board is labeled right on the board itself.

package main

import (
    "fmt"

    "gobot.io/x/gobot"
    "gobot.io/x/gobot/drivers/gpio"
    "gobot.io/x/gobot/platforms/chip"
)

func main() {
    chipAdaptor := chip.NewAdaptor()
    button := gpio.NewButtonDriver(chipAdaptor, "XIO-P0")

    work := func() {
        gobot.On(button.Event("push"), func(data interface{}) {
            fmt.Println("button pressed")
        })

        gobot.On(button.Event("release"), func(data interface{}) {
            fmt.Println("button released")
        })
    }

    robot := gobot.NewRobot("buttonBot",
        []gobot.Connection{chipAdaptor},
        []gobot.Device{button},
        work,
    )

    robot.Start()
}

If you want to use the C.H.I.P. Pro, use the NewProAdaptor() function like this:

chipProAdaptor := chip.NewProAdaptor()

How to Connect

Compiling

Compile your Gobot program on your workstation like this:

$ GOARM=7 GOARCH=arm GOOS=linux go build examples/chip_button.go

Once you have compiled your code, you can you can upload your program and execute it on the C.H.I.P. from your workstation using the scp and ssh commands like this:

$ scp chip_button root@192.168.1.xx:
$ ssh -t root@192.168.1.xx "./chip_button"

Documentation

Overview

Package chip contains the Gobot adaptor for the CHIP and CHIP Pro

For further information refer to the chip README: https://github.com/hybridgroup/gobot/blob/master/platforms/chip/README.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adaptor added in v1.0.0

type Adaptor struct {
	// contains filtered or unexported fields
}

Adaptor represents a Gobot Adaptor for a C.H.I.P.

func NewAdaptor added in v1.0.0

func NewAdaptor() *Adaptor

NewAdaptor creates a C.H.I.P. Adaptor

func NewProAdaptor added in v1.5.0

func NewProAdaptor() *Adaptor

NewAdaptor creates a C.H.I.P. Pro Adaptor

func (*Adaptor) Connect added in v1.0.0

func (c *Adaptor) Connect() (err error)

Connect initializes the board

func (*Adaptor) DigitalPin added in v1.5.0

func (c *Adaptor) DigitalPin(pin string, dir string) (sysfsPin sysfs.DigitalPinner, err error)

digitalPin returns matched digitalPin for specified values

func (*Adaptor) DigitalRead added in v1.0.0

func (c *Adaptor) DigitalRead(pin string) (val int, err error)

DigitalRead reads digital value from the specified pin. Valids pins are the XIO-P0 through XIO-P7 pins from the extender (pins 13-20 on header 14), as well as the SoC pins aka all the other pins.

func (*Adaptor) DigitalWrite added in v1.0.0

func (c *Adaptor) DigitalWrite(pin string, val byte) (err error)

DigitalWrite writes digital value to the specified pin. Valids pins are the XIO-P0 through XIO-P7 pins from the extender (pins 13-20 on header 14), as well as the SoC pins aka all the other pins.

func (*Adaptor) Finalize added in v1.0.0

func (c *Adaptor) Finalize() (err error)

Finalize closes connection to board and pins

func (*Adaptor) GetConnection added in v1.2.0

func (c *Adaptor) GetConnection(address int, bus int) (connection i2c.Connection, err error)

GetConnection returns a connection to a device on a specified bus. Valid bus number is [0..2] which corresponds to /dev/i2c-0 through /dev/i2c-2.

func (*Adaptor) GetDefaultBus added in v1.2.0

func (c *Adaptor) GetDefaultBus() int

GetDefaultBus returns the default i2c bus for this platform

func (*Adaptor) Name added in v1.0.0

func (c *Adaptor) Name() string

Name returns the name of the Adaptor

func (*Adaptor) PWMPin added in v1.5.0

func (c *Adaptor) PWMPin(pin string) (sysfsPin sysfs.PWMPinner, err error)

pwmPin returns matched pwmPin for specified pin number

func (*Adaptor) PwmWrite added in v1.4.0

func (c *Adaptor) PwmWrite(pin string, val byte) (err error)

PwmWrite writes a PWM signal to the specified pin

func (*Adaptor) ServoWrite added in v1.4.0

func (c *Adaptor) ServoWrite(pin string, angle byte) (err error)

ServoWrite writes a servo signal to the specified pin

func (*Adaptor) SetBoard added in v1.5.0

func (c *Adaptor) SetBoard(n string) (err error)

SetBoard sets the name of the type of board

func (*Adaptor) SetName added in v1.0.0

func (c *Adaptor) SetName(n string)

SetName sets the name of the Adaptor

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL