gpio

package module
v0.0.0-...-a6de66e Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2016 License: BSD-2-Clause Imports: 6 Imported by: 63

README

gpio

THIS PROJECT IS NO LONGER ACCEPTING ISSUES OR PULL REQUESTS

GPIO for Go

testing

Please run the 'blink' example found under examples/blink. Proper tests will be added soon.

alternatives

https://github.com/mrmorphic/hwio is another project aiming to expose the hardware capabilities of embedded systems via Go.

Documentation

Overview

Package gpio provides a user space interface to GPIO pins.

Index

Constants

View Source
const (
	GPIO0     = 0
	GPIO1     = 1
	GPIO2     = 2
	GPIO3     = 3
	GPIO4     = 4
	GPIO7     = 7
	GPIO8     = 8
	GPIO9     = 9
	GPIO10    = 10
	GPIO11    = 11
	GPIO17    = 17
	GPIO18    = 18
	GPIO22    = 22
	GPIO23    = 23
	GPIO24    = 24
	GPIO25    = 25
	GPIOCount = 16 // the number of GPIO pins available
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge string

Edge represents the edge on which a pin interrupt is triggered

const (
	EdgeNone    Edge = "none"
	EdgeRising  Edge = "rising"
	EdgeFalling Edge = "falling"
	EdgeBoth    Edge = "both"
)

type IRQEvent

type IRQEvent func()

IRQEvent defines the callback function used to inform the caller of an interrupt.

type Mode

type Mode string

Mode represents a state of a GPIO pin

const (
	ModeInput  Mode = "in"
	ModeOutput Mode = "out"
	ModePWM         = "pwm"
)

type Pin

type Pin interface {
	Mode() Mode                      // gets the current pin mode
	SetMode(Mode)                    // set the current pin mode
	Set()                            // sets the pin state high
	Clear()                          // sets the pin state low
	Close() error                    // if applicable, closes the pin
	Get() bool                       // returns the current pin state
	BeginWatch(Edge, IRQEvent) error // calls the function argument when an edge trigger event occurs
	EndWatch() error                 // stops watching the pin
	Wait(bool)                       // wait for pin state to match boolean argument

	Err() error // returns the last error state
}

Pin represents a GPIO pin.

func OpenPin

func OpenPin(n int, mode Mode) (Pin, error)

OpenPin exports the pin, creating the virtual files necessary for interacting with the pin. It also sets the mode for the pin, making it ready for use.

Directories

Path Synopsis
examples
package rpi provides a GPIO implementation customised for the RPi.
package rpi provides a GPIO implementation customised for the RPi.

Jump to

Keyboard shortcuts

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