Documentation ¶
Overview ¶
Package uapi provides the Linux GPIO UAPI definitions for gpiod.
Index ¶
- func BytesToString(a []byte) string
- func GetLineEvent(fd uintptr, request *EventRequest) error
- func GetLineHandle(fd uintptr, request *HandleRequest) error
- func GetLineValues(fd uintptr, values *HandleData) error
- func SetLineConfig(fd uintptr, config *HandleConfig) error
- func SetLineValues(fd uintptr, values HandleData) error
- type ChipInfo
- type EventData
- type EventFlag
- type EventRequest
- type HandleConfig
- type HandleData
- type HandleFlag
- func (f HandleFlag) IsActiveLow() bool
- func (f HandleFlag) IsBiasDisable() bool
- func (f HandleFlag) IsInput() bool
- func (f HandleFlag) IsOpenDrain() bool
- func (f HandleFlag) IsOpenSource() bool
- func (f HandleFlag) IsOutput() bool
- func (f HandleFlag) IsPullDown() bool
- func (f HandleFlag) IsPullUp() bool
- type HandleRequest
- type LineFlag
- type LineInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶
BytesToString is a helper function that converts strings stored in byte arrays, as returned by GetChipInfo and GetLineInfo, into strings.
func GetLineEvent ¶
func GetLineEvent(fd uintptr, request *EventRequest) error
GetLineEvent requests a line from the GPIO character device with event reporting enabled.
The fd is an open GPIO character device. The line must be an input and must not already be requested. If successful, the fd for the line is returned in the request.fd.
func GetLineHandle ¶
func GetLineHandle(fd uintptr, request *HandleRequest) error
GetLineHandle requests a line from the GPIO character device.
This request is without event reporting. The fd is an open GPIO character device. The lines must not already be requested. The flags in the request will be applied to all lines in the request. If successful, the fd for the line is returned in the request.fd.
func GetLineValues ¶
func GetLineValues(fd uintptr, values *HandleData) error
GetLineValues returns the values of a set of requested lines.
The fd is a requested line, as returned by GetLineHandle or GetLineEvent.
func SetLineConfig ¶ added in v0.3.0
func SetLineConfig(fd uintptr, config *HandleConfig) error
SetLineConfig sets the config of an existing handle request.
The config flags in the request will be applied to all lines in the handle request.
func SetLineValues ¶
func SetLineValues(fd uintptr, values HandleData) error
SetLineValues sets the values of a set of requested lines.
The fd is a requested line, as returned by GetLineHandle or GetLineEvent.
Types ¶
type ChipInfo ¶
type ChipInfo struct { // The system name of the device. Name [nameSize]byte // An identifying label added by the device driver. Label [nameSize]byte // The number of lines supported by this chip. Lines uint32 }
ChipInfo contains the details of a GPIO chip.
func GetChipInfo ¶
GetChipInfo returns the ChipInfo for the GPIO character device.
The fd is an open GPIO character device.
type EventData ¶
type EventData struct { // The time the event was detected. Timestamp uint64 // The type of event detected. ID uint32 // contains filtered or unexported fields }
EventData contains the details of a particular line event.
type EventFlag ¶
type EventFlag uint32
EventFlag indicates the types of events that will be reported.
const ( // EventRequestRisingEdge requests rising edge events. // This means a transition from a low logical state to a high logical state. // For active high lines (the default) this means a transition from a // physical low to a physical high. // Note that for active low lines this means a transition from a physical // high to a physical low. EventRequestRisingEdge EventFlag = 1 << iota // EventRequestFallingEdge requests falling edge events. // This means a transition from a high logical state to a low logical state. // For active high lines (the default) this means a transition from a // physical high to a physical low. // Note that for active low lines this means a transition from a physical // low to a physical high. EventRequestFallingEdge // EventRequestBothEdges requests both rising and falling edge events. // This is equivalent to requesting both EventRequestRisingEdge and // EventRequestRisingEdge. EventRequestBothEdges = EventRequestRisingEdge | EventRequestFallingEdge )
func (EventFlag) IsBothEdges ¶
IsBothEdges returns true if both rising and falling edge events have been requested.
func (EventFlag) IsFallingEdge ¶
IsFallingEdge returns true if falling edge events have been requested.
func (EventFlag) IsRisingEdge ¶
IsRisingEdge returns true if rising edge events have been requested.
type EventRequest ¶
type EventRequest struct { // The line to be requested. Offset uint32 // The line flags applied to this line. HandleFlags HandleFlag // The type of events to report. EventFlags EventFlag // The string identifying the requester to be applied to the line. Consumer [nameSize]byte // The file handle for the requested line. // Set if the request is successful. Fd int32 }
EventRequest is a request for control of a line with event reporting enabled.
type HandleConfig ¶ added in v0.3.0
type HandleConfig struct { // The flags to be applied to the lines. Flags HandleFlag // The default values to be applied to output lines (when // HandleRequestOutput is set in the Flags). DefaultValues [HandlesMax]uint8 // contains filtered or unexported fields }
HandleConfig is a request to change the config of an existing request.
Can be applied to both handle and event requests. Event requests cannot be reconfigured to outputs.
type HandleData ¶
type HandleData [HandlesMax]uint8
HandleData contains the logical value for each line. Zero is a logical low and any other value is a logical high.
type HandleFlag ¶
type HandleFlag uint32
HandleFlag contains the
const ( // HandleRequestInput requests the line as an input. // // This is ignored if Output is also set. HandleRequestInput HandleFlag = 1 << iota // HandleRequestOutput requests the line as an output. // // This takes precedence over Input, if both are set. HandleRequestOutput // HandleRequestActiveLow requests the line be made active low. HandleRequestActiveLow // HandleRequestOpenDrain requests the line be made open drain. // // This option requires the line to be requested as an Output. // This cannot be set at the same time as OpenSource. HandleRequestOpenDrain // HandleRequestOpenSource requests the line be made open source. // // This option requires the line to be requested as an Output. // This cannot be set at the same time as OpenDrain. HandleRequestOpenSource // HandleRequestPullUp requests the line have pull-up enabled. HandleRequestPullUp // HandleRequestPullDown requests the line have pull-down enabled. HandleRequestPullDown // HandleRequestBiasDisable requests the line have bias disabled. HandleRequestBiasDisable // HandlesMax is the maximum number of lines that can be requested in a // single request. HandlesMax = 64 )
func (HandleFlag) IsActiveLow ¶
func (f HandleFlag) IsActiveLow() bool
IsActiveLow returns true if the line is requested as a active low.
func (HandleFlag) IsBiasDisable ¶ added in v0.3.0
func (f HandleFlag) IsBiasDisable() bool
IsBiasDisable returns true if the line is requested with bias disabled.
func (HandleFlag) IsInput ¶
func (f HandleFlag) IsInput() bool
IsInput returns true if the line is requested as an input.
func (HandleFlag) IsOpenDrain ¶
func (f HandleFlag) IsOpenDrain() bool
IsOpenDrain returns true if the line is requested as an open drain.
func (HandleFlag) IsOpenSource ¶
func (f HandleFlag) IsOpenSource() bool
IsOpenSource returns true if the line is requested as an open source.
func (HandleFlag) IsOutput ¶
func (f HandleFlag) IsOutput() bool
IsOutput returns true if the line is requested as an output.
func (HandleFlag) IsPullDown ¶ added in v0.3.0
func (f HandleFlag) IsPullDown() bool
IsPullDown returns true if the line is requested with pull-down enabled.
func (HandleFlag) IsPullUp ¶ added in v0.3.0
func (f HandleFlag) IsPullUp() bool
IsPullUp returns true if the line is requested with pull-up enabled.
type HandleRequest ¶
type HandleRequest struct { // The lines to be requested. Offsets [HandlesMax]uint32 // The flags to be applied to the lines. Flags HandleFlag // The default values to be applied to output lines. DefaultValues [HandlesMax]uint8 // The string identifying the requester to be applied to the lines. Consumer [nameSize]byte // The number of lines being requested. Lines uint32 // The file handle for the requested lines. // Set if the request is successful. Fd int32 }
HandleRequest is a request for control of a set of lines. The lines must all be on the same GPIO chip.
type LineFlag ¶
type LineFlag uint32
LineFlag are the flags for a line.
const ( // LineFlagRequested indicates that the line has been requested. // It may have been requested by this process or another process. // The line cannot be requested again until this flag is clear. LineFlagRequested LineFlag = 1 << iota // LineFlagIsOut indicates that the line is an output. LineFlagIsOut // LineFlagActiveLow indicates that the line is active low. LineFlagActiveLow // LineFlagOpenDrain indicates that the line will pull low when set low but // float when set high. This flag only applies to output lines. // An output cannot be both open drain and open source. LineFlagOpenDrain // LineFlagOpenSource indicates that the line will pull high when set high // but float when set low. This flag only applies to output lines. // An output cannot be both open drain and open source. LineFlagOpenSource // LineFlagPullUp indicates that the internal line pull up is enabled. LineFlagPullUp // LineFlagPullDown indicates that the internal line pull down is enabled. LineFlagPullDown // LineFlagBiasDisable indicates that the internal line bias is disabled. LineFlagBiasDisable )
func (LineFlag) IsActiveLow ¶
IsActiveLow returns true if the line is active low.
func (LineFlag) IsBiasDisable ¶ added in v0.3.0
IsBiasDisable returns true if the line has bias disabled.
func (LineFlag) IsOpenDrain ¶
IsOpenDrain returns true if the line is open-drain.
func (LineFlag) IsOpenSource ¶
IsOpenSource returns true if the line is open-source.
func (LineFlag) IsPullDown ¶ added in v0.3.0
IsPullDown returns true if the line has pull-down enabled.
func (LineFlag) IsRequested ¶
IsRequested returns true if the line is requested.
type LineInfo ¶
type LineInfo struct { // The offset of the line within the chip. Offset uint32 // The line flags applied to this line. Flags LineFlag // The system name for this line. Name [nameSize]byte // If requested, a string added by the requester to identify the // owner of the request. Consumer [nameSize]byte }
LineInfo contains the details of a single line of a GPIO chip.