libgpiod
1.6.2
|
Represents a single GPIO line. More...
#include <gpiod.hpp>
Public Types | |
enum | : int { DIRECTION_INPUT = 1, DIRECTION_OUTPUT } |
Possible direction settings. More... | |
enum | : int { ACTIVE_LOW = 1, ACTIVE_HIGH } |
Possible active state settings. More... | |
enum | : int { BIAS_AS_IS = 1, BIAS_DISABLE, BIAS_PULL_UP, BIAS_PULL_DOWN } |
Possible bias settings. More... | |
Public Member Functions | |
GPIOD_API | line (void) |
Default constructor. More... | |
GPIOD_API | line (const line &other)=default |
Copy constructor. More... | |
GPIOD_API | line (line &&other)=default |
Move constructor. More... | |
GPIOD_API line & | operator= (const line &other)=default |
Assignment operator. More... | |
GPIOD_API line & | operator= (line &&other)=default |
Move assignment operator. More... | |
GPIOD_API | ~line (void)=default |
Destructor. | |
GPIOD_API unsigned int | offset (void) const |
Get the offset of this line. More... | |
GPIOD_API ::std::string | name (void) const |
Get the name of this line (if any). More... | |
GPIOD_API ::std::string | consumer (void) const |
Get the consumer of this line (if any). More... | |
GPIOD_API int | direction (void) const |
Get current direction of this line. More... | |
GPIOD_API int | active_state (void) const |
Get current active state of this line. More... | |
GPIOD_API int | bias (void) const |
Get current bias of this line. More... | |
GPIOD_API bool | is_used (void) const |
Check if this line is used by the kernel or other user space process. More... | |
GPIOD_API bool | is_open_drain (void) const |
Check if this line represents an open-drain GPIO. More... | |
GPIOD_API bool | is_open_source (void) const |
Check if this line represents an open-source GPIO. More... | |
GPIOD_API void | request (const line_request &config, int default_val=0) const |
Request this line. More... | |
GPIOD_API void | release (void) const |
Release the line if it was previously requested. | |
GPIOD_API bool | is_requested (void) const |
Check if this user has ownership of this line. More... | |
GPIOD_API int | get_value (void) const |
Read the line value. More... | |
GPIOD_API void | set_value (int val) const |
Set the value of this line. More... | |
GPIOD_API void | set_config (int direction, ::std::bitset< 32 > flags, int value=0) const |
Set configuration of this line. More... | |
GPIOD_API void | set_flags (::std::bitset< 32 > flags) const |
Set configuration flags of this line. More... | |
GPIOD_API void | set_direction_input () const |
Change the direction this line to input. | |
GPIOD_API void | set_direction_output (int value=0) const |
Change the direction this lines to output. More... | |
GPIOD_API bool | event_wait (const ::std::chrono::nanoseconds &timeout) const |
Wait for an event on this line. More... | |
GPIOD_API line_event | event_read (void) const |
Read a line event. More... | |
GPIOD_API ::std::vector< line_event > | event_read_multiple (void) const |
Read multiple line events. More... | |
GPIOD_API int | event_get_fd (void) const |
Get the event file descriptor associated with this line. More... | |
GPIOD_API const chip & | get_chip (void) const |
Get the reference to the parent chip. More... | |
GPIOD_API void | update (void) const |
Re-read the line info from the kernel. | |
GPIOD_API void | reset (void) |
Reset the state of this object. More... | |
GPIOD_API bool | operator== (const line &rhs) const noexcept |
Check if two line objects reference the same GPIO line. More... | |
GPIOD_API bool | operator!= (const line &rhs) const noexcept |
Check if two line objects reference different GPIO lines. More... | |
GPIOD_API | operator bool (void) const noexcept |
Check if this object holds a reference to any GPIO line. More... | |
GPIOD_API bool | operator! (void) const noexcept |
Check if this object doesn't reference any GPIO line. More... | |
Represents a single GPIO line.
Internally this class holds a raw pointer to a GPIO line descriptor and a reference to the parent chip. All line resources are freed when the last reference to the parent chip is dropped.
anonymous enum : int |
anonymous enum : int |
anonymous enum : int |
GPIOD_API gpiod::line::line | ( | void | ) |
Default constructor.
Creates an empty line object.
Copy constructor.
other | Other line object. |
Move constructor.
other | Other line object. |
GPIOD_API int gpiod::line::active_state | ( | void | ) | const |
Get current active state of this line.
GPIOD_API int gpiod::line::bias | ( | void | ) | const |
Get current bias of this line.
GPIOD_API ::std::string gpiod::line::consumer | ( | void | ) | const |
Get the consumer of this line (if any).
GPIOD_API int gpiod::line::direction | ( | void | ) | const |
Get current direction of this line.
GPIOD_API int gpiod::line::event_get_fd | ( | void | ) | const |
Get the event file descriptor associated with this line.
GPIOD_API line_event gpiod::line::event_read | ( | void | ) | const |
Read a line event.
GPIOD_API ::std::vector<line_event> gpiod::line::event_read_multiple | ( | void | ) | const |
Read multiple line events.
GPIOD_API bool gpiod::line::event_wait | ( | const ::std::chrono::nanoseconds & | timeout | ) | const |
Wait for an event on this line.
timeout | Time to wait before returning if no event occurred. |
Get the reference to the parent chip.
GPIOD_API int gpiod::line::get_value | ( | void | ) | const |
Read the line value.
GPIOD_API bool gpiod::line::is_open_drain | ( | void | ) | const |
Check if this line represents an open-drain GPIO.
GPIOD_API bool gpiod::line::is_open_source | ( | void | ) | const |
Check if this line represents an open-source GPIO.
GPIOD_API bool gpiod::line::is_requested | ( | void | ) | const |
Check if this user has ownership of this line.
GPIOD_API bool gpiod::line::is_used | ( | void | ) | const |
Check if this line is used by the kernel or other user space process.
GPIOD_API ::std::string gpiod::line::name | ( | void | ) | const |
Get the name of this line (if any).
GPIOD_API unsigned int gpiod::line::offset | ( | void | ) | const |
Get the offset of this line.
|
explicitnoexcept |
Check if this object holds a reference to any GPIO line.
|
noexcept |
Check if this object doesn't reference any GPIO line.
References DIRECTION_INPUT, and DIRECTION_OUTPUT.
|
noexcept |
Check if two line objects reference different GPIO lines.
rhs | Right-hand side of the equation. |
Assignment operator.
other | Other line object. |
Move assignment operator.
other | Other line object. |
Check if two line objects reference the same GPIO line.
rhs | Right-hand side of the equation. |
GPIOD_API void gpiod::line::request | ( | const line_request & | config, |
int | default_val = 0 |
||
) | const |
Request this line.
config | Request config (see gpiod::line_request). |
default_val | Default value - only matters for OUTPUT direction. |
GPIOD_API void gpiod::line::reset | ( | void | ) |
Reset the state of this object.
This is useful when the user needs to e.g. keep the line_event object but wants to drop the reference to the GPIO chip indirectly held by the line being the source of the event.
GPIOD_API void gpiod::line::set_config | ( | int | direction, |
::std::bitset< 32 > | flags, | ||
int | value = 0 |
||
) | const |
Set configuration of this line.
direction | New direction. |
flags | Replacement flags. |
value | New value (0 or 1) - only matters for OUTPUT direction. |
GPIOD_API void gpiod::line::set_direction_output | ( | int | value = 0 | ) | const |
Change the direction this lines to output.
value | New value (0 or 1). |
GPIOD_API void gpiod::line::set_flags | ( | ::std::bitset< 32 > | flags | ) | const |
Set configuration flags of this line.
flags | Replacement flags. |
GPIOD_API void gpiod::line::set_value | ( | int | val | ) | const |
Set the value of this line.
val | New value (0 or 1). |