gpio

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package gpio allows to configure and controll General Purpose I/O ports and their pins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config uint32

Config is configuration word of GPIO pin.

const (
	ModeIn     Config = 0 // Input buffer connected, output disabled.
	ModeInOut  Config = 1 // Input buffer connected, output enabled.
	ModeDiscon Config = 2 // Input buffer disconnected, output disabled.
	ModeOut    Config = 3 // Input buffer disconnected, output enabled.

	PullNone Config = 0 << 2 // Disable pull-up/down resistance.
	PullDown Config = 1 << 2 // Enable pull-down resistance.
	PullUp   Config = 3 << 2 // Enable pull-up resistance.

	DriveS0S1 Config = 0 << 8 // Standard 0, standard 1.
	DriveH0S1 Config = 1 << 8 // High drive 0, standard 1.
	DriveS0H1 Config = 2 << 8 // Standard 0, high drive 1.
	DriveH0H1 Config = 3 << 8 // High drive 0, high drive 1.
	DriveD0S1 Config = 4 << 8 // Disconnect 0, standard 1.
	DriveD0H1 Config = 5 << 8 // Disconnect 0, high drive 1.
	DriveS0D1 Config = 6 << 8 // Standard 0, disconnect 1.
	DriveH0D1 Config = 7 << 8 // High drive 0, disconnect 1.

	SenseNone Config = 0 << 16 // Sense disabled.
	SenseHigh Config = 2 << 16 // Sense for high level.
	SenseLow  Config = 3 << 16 // Sense for low level.
)

type Pin

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

Pin represents one phisical pin (specific pin in specific port).

func SelPin

func SelPin(psel int8) Pin

SelPin returns the pin corresponding to the compact representation psel.

func (Pin) Clear

func (p Pin) Clear()

Clear sets output value of the pin to 0 in one atomic operation.

func (Pin) Config

func (p Pin) Config() Config

Config returns current configuration of pin.

func (Pin) Index

func (p Pin) Index() int

Index returns pin index in the port.

func (Pin) IsValid

func (p Pin) IsValid() bool

IsValid reports whether p represents a valid pin.

func (Pin) Load

func (p Pin) Load() int

Load returns input value of the pin.

func (Pin) LoadOut

func (p Pin) LoadOut() int

LoadOut returns output value of the pin.

func (Pin) Mask

func (p Pin) Mask() Pins

Mask returns bitmask that represents the pin.

func (Pin) Port

func (p Pin) Port() *Port

Port returns the port where the pin is located.

func (Pin) Sel

func (p Pin) Sel() int8

Sel returns compact representation of Pin.

func (Pin) Set

func (p Pin) Set()

Set sets output value of the pin to 1 in one atomic operation.

func (Pin) Setup

func (p Pin) Setup(cfg Config)

Setup configures pin.

func (Pin) Store

func (p Pin) Store(val int)

Store sets output value of the pin to the least significant bit of val.

type Pins

type Pins uint32

Pins is a bitmask which represents the pins of GPIO port.

const (
	Pin0 Pins = 1 << iota
	Pin1
	Pin2
	Pin3
	Pin4
	Pin5
	Pin6
	Pin7
	Pin8
	Pin9
	Pin10
	Pin11
	Pin12
	Pin13
	Pin14
	Pin15
	Pin16
	Pin17
	Pin18
	Pin19
	Pin20
	Pin21
	Pin22
	Pin23
	Pin24
	Pin25
	Pin26
	Pin27
	Pin28
	Pin29
	Pin30
	Pin31
)

type Port

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

Port represents one GPIO port.

func P

func P(n int) *Port

P returns n-th GPIO port

func (*Port) ClearPins

func (p *Port) ClearPins(pins Pins)

ClearPins sets output value of pins to 0 in one atomic operation.

func (*Port) Index

func (p *Port) Index() int

Index returns the port number.

func (*Port) Load

func (p *Port) Load() Pins

Load returns input value of all pins.

func (*Port) LoadOut

func (p *Port) LoadOut() Pins

LoadOut returns output value of all pins.

func (*Port) Pin

func (p *Port) Pin(n int) Pin

Pin returns n-th pin in port p.

func (*Port) PinConfig

func (p *Port) PinConfig(n int) Config

PinConfig returns current configuration of n-th pin in port p.

func (*Port) Pins

func (p *Port) Pins(pins Pins) Pins

Pins returns input value of pins.

func (*Port) PinsOut

func (p *Port) PinsOut(pins Pins) Pins

PinsOut returns output value of pins.

func (*Port) SetDirIn

func (p *Port) SetDirIn(pins Pins)

SetDirIn allows a fast change multiple pins to input mode.

func (*Port) SetDirOut

func (p *Port) SetDirOut(pins Pins)

SetDirIn allows a fast change multiple pins to output mode.

func (*Port) SetPins

func (p *Port) SetPins(pins Pins)

SetPins sets output value of pins to 1 in one atomic operation.

func (*Port) Setup

func (p *Port) Setup(pins Pins, cfg Config)

Setup configures pins.

func (*Port) SetupPin

func (p *Port) SetupPin(n int, cfg Config)

Setup configures n-th pin in port p.

func (*Port) Store

func (p *Port) Store(val Pins)

Store sets output value of all pins to value specified by val.

Jump to

Keyboard shortcuts

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