up2

package
v0.0.0-...-6da3503 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: Apache-2.0, Apache-2.0 Imports: 10 Imported by: 0

README

UP2

The UP2 Board aka "Up Squared" is a single board SoC computer based on the Intel Apollo Lake processor. It has built-in GPIO, PWM, SPI, and I2C interfaces.

For more info about the UP2 Board, go to http://www.up-board.org/upsquared/.

How to Install

Update operating system and BIOS on UP2 board

We recommend updating to the latest Ubuntu 16.04 and BIOS v3.3 when using the UP2 board. To update your UP2 OS go to:

https://downloads.up-community.org/download/up-squared-iot-grove-development-kit-ubuntu-16-04-server-image/

To update your UP2 BIOS, go to:

https://downloads.up-community.org/download/up-squared-uefi-bios-v3-3/

Once your UP2 has been updated, you will need to provide permission to the upsquared user to access the GPIO or I2C subsystems on the board.

Configuring GPIO on UP2 board

To access the GPIO subsystem, you will need to create a new group, add your user to the group, and then add a UDEV rule.

First, run the following commands on the board itself:

sudo groupadd gpio
sudo adduser upsquared gpio

Now, add a new UDEV rule to the UP2 board. Add the following text as a new UDEV rule named /etc/udev/rules.d/99-gpio.rules:

SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\
        chown -R root:gpiouser /sys/class/gpio && chmod -R 770 /sys/class/gpio;\
        chown -R root:gpiouser /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio;\
        chown -R root:gpiouser /sys$devpath && chmod -R 770 /sys$devpath\
'"
Configuring built-in LEDs on UP2 board

To use the built-in LEDs you will need to create a new group, add your user to the group, and then add a UDEV rule.

First, run the following commands on the board itself:

sudo groupadd leds
sudo adduser upsquared leds

Now add the following text as a new UDEV rule named /etc/udev/rules.d/99-leds.rules:

SUBSYSTEM=="leds*", PROGRAM="/bin/sh -c '\
        chown -R root:leds /sys/class/leds && chmod -R 770 /sys/class/leds;\
        chown -R root:leds /sys/devices/platform/up-pinctrl/leds && chmod -R 770 /sys/devices/platform/up-pinctrl/leds;\
        chown -R root:leds /sys/devices/platform/AANT0F01:00/upboard-led.* && chmod -R 770 /sys/devices/platform/AANT0F01:00/upboard-led.*;\
'"
Configuring I2C on UP2 board

To access the I2C subsystem, run the following command:

sudo usermod -aG i2c upsquared

You should reboot your UP2 board after making these changes for them to take effect.

IMPORTANT NOTE REGARDING I2C: The current UP2 firmware is not able to scan for I2C devices using the i2cdetect command line tool. If you run this tool, it will cause the I2C subsystem to malfunction until you reboot your system. That means at this time, do not use i2cdetect on the UP2 board.

Local setup

You would normally install Go and Gobot on your local workstation. Once installed, cross compile your program on your workstation, transfer the final executable to your UP2, and run the program on the UP2 as documented below.

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

How to Use

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

r := up2.NewAdaptor()
led := gpio.NewLedDriver(r, "13")

You can also use the values up2.LEDRed, up2.LEDBlue, up2.LEDGreen, and up2.LEDYellow as pin reference to access the 4 built-in LEDs. For example:

r := up2.NewAdaptor()
led := gpio.NewLedDriver(r, up2.LEDRed)

How to Connect

Compiling

Compile your Gobot program on your workstation like this:

$ GOARCH=amd64 GOOS=linux go build examples/up2_blink.go

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

$ scp up2_blink upsquared@192.168.1.xxx:/home/upsquared/
$ ssh -t upsquared@192.168.1.xxx "./up2_blink"

Documentation

Overview

Package up2 contains the Gobot adaptor for the Upboard UP2.

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

Index

Constants

View Source
const (
	// LEDRed is the built-in red LED.
	LEDRed = "red"

	// LEDBlue is the built-in blue LED.
	LEDBlue = "blue"

	// LEDGreen is the built-in green LED.
	LEDGreen = "green"

	// LEDYellow is the built-in yellow LED.
	LEDYellow = "yellow"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adaptor

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

Adaptor represents a Gobot Adaptor for the Upboard UP2

func NewAdaptor

func NewAdaptor() *Adaptor

NewAdaptor creates a UP2 Adaptor

func (*Adaptor) Connect

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

Connect initializes the board

func (*Adaptor) DigitalPin

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

DigitalPin returns matched digitalPin for specified values

func (*Adaptor) DigitalRead

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

DigitalRead reads digital value from the specified pin.

func (*Adaptor) DigitalWrite

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

DigitalWrite writes digital value to the specified pin.

func (*Adaptor) Finalize

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

Finalize closes connection to board and pins

func (*Adaptor) GetConnection

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 [5..6] which corresponds to /dev/i2c-5 through /dev/i2c-6.

func (*Adaptor) GetDefaultBus

func (c *Adaptor) GetDefaultBus() int

GetDefaultBus returns the default i2c bus for this platform

func (*Adaptor) GetSpiConnection

func (c *Adaptor) GetSpiConnection(busNum, chipNum, mode, bits int, maxSpeed int64) (connection spi.Connection, err error)

GetSpiConnection returns an spi connection to a device on a specified bus. Valid bus number is [0..1] which corresponds to /dev/spidev0.0 through /dev/spidev0.1.

func (*Adaptor) GetSpiDefaultBits

func (c *Adaptor) GetSpiDefaultBits() int

GetSpiDefaultBits returns the default spi number of bits for this platform.

func (*Adaptor) GetSpiDefaultBus

func (c *Adaptor) GetSpiDefaultBus() int

GetSpiDefaultBus returns the default spi bus for this platform.

func (*Adaptor) GetSpiDefaultChip

func (c *Adaptor) GetSpiDefaultChip() int

GetSpiDefaultChip returns the default spi chip for this platform.

func (*Adaptor) GetSpiDefaultMaxSpeed

func (c *Adaptor) GetSpiDefaultMaxSpeed() int64

GetSpiDefaultMaxSpeed returns the default spi max speed for this platform.

func (*Adaptor) GetSpiDefaultMode

func (c *Adaptor) GetSpiDefaultMode() int

GetSpiDefaultMode returns the default spi mode for this platform.

func (*Adaptor) Name

func (c *Adaptor) Name() string

Name returns the name of the Adaptor

func (*Adaptor) PWMPin

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

PWMPin returns matched pwmPin for specified pin number

func (*Adaptor) PwmWrite

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

PwmWrite writes a PWM signal to the specified pin

func (*Adaptor) ServoWrite

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

ServoWrite writes a servo signal to the specified pin

func (*Adaptor) SetName

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