up2

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0, Apache-2.0 Imports: 8 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

Please refer to the main README.md

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/release/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 {
	*adaptors.DigitalPinsAdaptor
	*adaptors.PWMPinsAdaptor
	*adaptors.I2cBusAdaptor
	*adaptors.SpiBusAdaptor
	// contains filtered or unexported fields
}

Adaptor represents a Gobot Adaptor for the Upboard UP2

func NewAdaptor

func NewAdaptor(opts ...interface{}) *Adaptor

NewAdaptor creates a UP2 Adaptor

Optional parameters:

adaptors.WithGpiodAccess():	use character device gpiod driver instead of sysfs
adaptors.WithSpiGpioAccess(sclk, ncs, sdo, sdi):	use GPIO's instead of /dev/spidev#.#

Optional parameters for PWM, see [adaptors.NewPWMPinsAdaptor]

func (*Adaptor) Connect

func (a *Adaptor) Connect() error

Connect create new connection to board and pins.

func (*Adaptor) DigitalWrite

func (a *Adaptor) DigitalWrite(id string, val byte) error

DigitalWrite writes digital value to the specified pin.

func (*Adaptor) Finalize

func (a *Adaptor) Finalize() error

Finalize closes connection to board and pins

func (*Adaptor) Name

func (a *Adaptor) Name() string

Name returns the name of the Adaptor

func (*Adaptor) SetName

func (a *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