Documentation ¶
Overview ¶
Package gpiosysfs implements linux GPIO Sysfs Interface.
Ref: https://www.kernel.org/doc/Documentation/gpio/sysfs.txt
GPIO Sysfs Interface is deprecated. New applications are supposed to use the character device implementation: github.com/mkch/gpio
Index ¶
- Constants
- type Chip
- type Direction
- type Edge
- type Event
- type Pin
- func (pin *Pin) ActiveLow(value bool, err error)
- func (pin *Pin) Close() (err error)
- func (pin *Pin) Direction() (dir Direction, err error)
- func (pin *Pin) Edge() (edge Edge, err error)
- func (pin *Pin) SetActiveLow(value bool) (err error)
- func (pin *Pin) SetDirection(direction Direction) (err error)
- func (pin *Pin) SetEdge(edge Edge) (err error)
- func (pin *Pin) SetValue(value byte) (err error)
- func (pin *Pin) Value() (value byte, err error)
- type PinWithEvent
Constants ¶
const ( In Direction = "in" // RW. The pin is configured as input. Out = "out" // RW. The pin is configured as output, usually initialized to low. OutLow = "low" // W. Configure the pin as output and initialize it to low. OutHigh = "high" // W. Configure the pin as output and initialize it to high. )
Available directions.
const ( // None means no edge is selected to generate interrupts. None Edge = "none" // Rising edges is is selected to generate interrupts. Rising: level is getting to high from low. Rising = "rising" // Falling edges is is selected to generate interrupts. Falling: level is getting to low from hight. Falling = "falling" // Both rising and falling edges are selected to generate interrupts. Both = "both" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chip ¶
type Chip struct { Base int // The first GPIO managed by this chip. Label string // The Label fo this chip. Provided for diagnostics (not always unique) Ngpio int // How many GPIOs this chip manges. The GPIOs managed by this chip are in the range of Base to Base + ngpio - 1. }
Chip is the information of a GPIO controller chip.
func Controllers ¶
Controllers returns all GPIO controllers available.
type Edge ¶
type Edge string
Edge is the signal edge that will make Interrupt send value to the channel.
type Pin ¶
type Pin struct {
// contains filtered or unexported fields
}
Pin is a GPIO pin.
func (*Pin) Direction ¶
Direction returns the IO direction of the pin. The return values is In or Out.
func (*Pin) SetActiveLow ¶
SetActiveLow sets whether pin is configured as active low.
func (*Pin) SetDirection ¶
SetDirection sets the IO direction of the pin. pin.SetDirection(Out) may fail if Edge is not None.
func (*Pin) SetEdge ¶
SetEdge sets which edges are selected to generate interrupts. Not all GPIO pins are configured to support edge selection, so, Edge should be called to confirm the desired edge are set actually.
type PinWithEvent ¶
type PinWithEvent struct { *Pin // contains filtered or unexported fields }
PinWithEvent is an opened GPIO pin whose events can be read.
func OpenPinWithEvents ¶
func OpenPinWithEvents(n int) (pin *PinWithEvent, err error)
OpenPinWithEvents opens a GPIO pin for input and GPIO events.
func (*PinWithEvent) Close ¶
func (pin *PinWithEvent) Close() (err error)
func (*PinWithEvent) Events ¶
func (pin *PinWithEvent) Events() <-chan *Event
Events returns a channel from which the occurrence time of GPIO events can be read. The GPIO events of this pin will be sent to the returned channel, and the channel is closed when l is closed.
Package gpiosysfs will not block sending to the channel: it only keeps the lastest value in the channel.