Documentation ¶
Overview ¶
Package chardevgpio is a library to the Linux GPIO Character device API.
Index ¶
- Constants
- Variables
- type Chip
- type ChipInfo
- type Event
- type EventHandlerFunc
- type EventLine
- type EventRequestFlags
- type HandleConfig
- type HandleRequest
- type HandleRequestFlag
- type LineInfo
- func (li LineInfo) Consumer() string
- func (li LineInfo) IsActiveHigh() bool
- func (li LineInfo) IsActiveLow() bool
- func (li LineInfo) IsBiasPullDown() bool
- func (li LineInfo) IsBiasPullUp() bool
- func (li LineInfo) IsInput() bool
- func (li LineInfo) IsKernel() bool
- func (li LineInfo) IsOpenDrain() bool
- func (li LineInfo) IsOpenSource() bool
- func (li LineInfo) IsOutput() bool
- func (li LineInfo) Name() string
- func (li LineInfo) Offset() int
- type LineWatcher
Constants ¶
const ( HandleRequestInput HandleRequestFlag = 1 << 0 HandleRequestOutput = 1 << 1 HandleRequestActiveLow = 1 << 2 HandleRequestOpenDrain = 1 << 3 HandleRequestOpenSource = 1 << 4 HandleRequestBiasPullUp = 1 << 5 HandleRequestBiasPullDown = 1 << 6 HandleRequestBiasDisable = 1 << 7 )
HandleRequest request flags.
const ( RisingEdge EventRequestFlags = 1 << 0 FallingEdge = 1 << 1 BothEdges = (1 << 0) | (1 << 1) )
EventLine request flags.
Variables ¶
var ErrOperationNotPermitted = errors.New("operation not permitted")
ErrOperationNotPermitted is returned when trying to read on an output line or to write on a input line.
Functions ¶
This section is empty.
Types ¶
type Chip ¶
type Chip struct { ChipInfo // contains filtered or unexported fields }
Chip is a GPIO chip controlling a set of lines.
func (Chip) RequestLines ¶ added in v1.0.0
func (c Chip) RequestLines(request *HandleRequest) error
RequestLines takes a prepared HandleRequest and returns it ready to work.
type ChipInfo ¶ added in v1.0.0
type ChipInfo struct {
// contains filtered or unexported fields
}
ChipInfo contains informations about a GPIO chip.
type Event ¶ added in v1.0.0
Event represents a occurred event.
type EventHandlerFunc ¶ added in v1.0.0
type EventHandlerFunc func(evd Event)
EventHandlerFunc is the type of the function called for each event retrieved by WaitForEver.
type EventLine ¶ added in v1.0.0
type EventLine struct {
// contains filtered or unexported fields
}
EventLine represents a single line setup to receive GPIO events.
type EventRequestFlags ¶ added in v1.0.0
type EventRequestFlags uint32
EventRequestFlags defines the kind of event to wait on a line.
type HandleConfig ¶ added in v1.0.0
type HandleConfig struct {
// contains filtered or unexported fields
}
HandleConfig is the structure to reconfigure an existing HandleRequest (not used currently, require Kernel 5.5 or later).
type HandleRequest ¶ added in v1.0.0
type HandleRequest struct {
// contains filtered or unexported fields
}
HandleRequest represents at first a query to be sent to a chip to get control on a set of lines. After be returned by the chip, it must be used to send or received data to lines.
func NewHandleRequest ¶ added in v1.0.0
func NewHandleRequest(offsets []int, flags HandleRequestFlag) *HandleRequest
NewHandleRequest prepare a HandleRequest
func (HandleRequest) Close ¶ added in v1.0.0
func (hr HandleRequest) Close() error
Close releases resources helded by the HandleRequest.
func (*HandleRequest) Read ¶ added in v1.0.0
func (hr *HandleRequest) Read() (int, []int, error)
Reads return values read from the lines handled by the HandleRequest. The second return parameter contains all values returned as an array. The first one is the first element of this array, useful when dealing with 1 line HandleRequest.
func (*HandleRequest) WithConsumer ¶ added in v1.0.0
func (hr *HandleRequest) WithConsumer(consumer string) *HandleRequest
WithConsumer set the consumer for a prepared HandleRequest.
func (*HandleRequest) WithDefaults ¶ added in v1.0.0
func (hr *HandleRequest) WithDefaults(defaults []int) *HandleRequest
WithDefaults set the default values for a prepared HandleRequest. Note that setting default values on a InputLine is a nonsense but no error are returned.
type HandleRequestFlag ¶ added in v1.0.0
type HandleRequestFlag uint32
HandleRequestFlag is the type of request flags.
type LineInfo ¶
type LineInfo struct {
// contains filtered or unexported fields
}
LineInfo contains informations about a GPIO line.
func (LineInfo) IsActiveHigh ¶
IsActiveHigh returns true if the line is configured as active high.
func (LineInfo) IsActiveLow ¶
IsActiveLow returns true if the line is configured as active low.
func (LineInfo) IsBiasPullDown ¶ added in v1.0.0
IsBiasPullDown returns true if the line is configured as bias pull down.
func (LineInfo) IsBiasPullUp ¶ added in v1.0.0
IsBiasPullUp returns true if the line is configured as bias pull up.
func (LineInfo) IsOpenDrain ¶
IsOpenDrain returns true if the line is configured as open drain.
func (LineInfo) IsOpenSource ¶
IsOpenSource returns true if the line is configured as open source.
type LineWatcher ¶ added in v1.0.0
type LineWatcher struct {
// contains filtered or unexported fields
}
LineWatcher is a receiver of events for a set of event lines.
func NewLineWatcher ¶ added in v1.0.0
func NewLineWatcher() (LineWatcher, error)
NewLineWatcher initializes a new LineWatcher.
func (*LineWatcher) Add ¶ added in v1.0.0
func (lw *LineWatcher) Add(chip Chip, line int, flags EventRequestFlags, consumer string) error
Add adds a new line to watch to the LineWatcher.
func (*LineWatcher) Close ¶ added in v1.0.0
func (lw *LineWatcher) Close() error
Close releases resources helded by the LineWatcher.
func (*LineWatcher) Wait ¶ added in v1.0.0
func (lw *LineWatcher) Wait() (Event, error)
Wait waits for first occurrence of an event on one of the event lines.
func (*LineWatcher) WaitForEver ¶ added in v1.0.0
func (lw *LineWatcher) WaitForEver(handler EventHandlerFunc) error
WaitForEver waits indefinitely for events on the event lines. Note that for one event, more than one EventData can be retrieved on the event line.