libgpiod  1.5.2
gpiod.hpp
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * This file is part of libgpiod.
4  *
5  * Copyright (C) 2017-2018 Bartosz Golaszewski <bartekgola@gmail.com>
6  */
7 
8 #ifndef __LIBGPIOD_GPIOD_CXX_HPP__
9 #define __LIBGPIOD_GPIOD_CXX_HPP__
10 
11 #include <bitset>
12 #include <chrono>
13 #include <gpiod.h>
14 #include <memory>
15 #include <string>
16 #include <vector>
17 
18 namespace gpiod {
19 
20 class line;
21 class line_bulk;
22 class line_event;
23 class line_iter;
24 class chip_iter;
25 
38 class chip
39 {
40 public:
41 
45  GPIOD_API chip(void) = default;
46 
52  GPIOD_API chip(const ::std::string& device, int how = OPEN_LOOKUP);
53 
58  GPIOD_API chip(const chip& other) = default;
59 
64  GPIOD_API chip(chip&& other) = default;
65 
71  GPIOD_API chip& operator=(const chip& other) = default;
72 
78  GPIOD_API chip& operator=(chip&& other) = default;
79 
83  GPIOD_API ~chip(void) = default;
84 
93  GPIOD_API void open(const ::std::string &device, int how = OPEN_LOOKUP);
94 
98  GPIOD_API void reset(void) noexcept;
99 
104  GPIOD_API ::std::string name(void) const;
105 
110  GPIOD_API ::std::string label(void) const;
111 
116  GPIOD_API unsigned int num_lines(void) const;
117 
123  GPIOD_API line get_line(unsigned int offset) const;
124 
130  GPIOD_API line find_line(const ::std::string& name) const;
131 
137  GPIOD_API line_bulk get_lines(const ::std::vector<unsigned int>& offsets) const;
138 
144 
150  GPIOD_API line_bulk find_lines(const ::std::vector<::std::string>& names) const;
151 
157  GPIOD_API bool operator==(const chip& rhs) const noexcept;
158 
164  GPIOD_API bool operator!=(const chip& rhs) const noexcept;
165 
170  GPIOD_API explicit operator bool(void) const noexcept;
171 
176  GPIOD_API bool operator!(void) const noexcept;
177 
182  enum : int {
183  OPEN_LOOKUP = 1,
185  OPEN_BY_PATH,
187  OPEN_BY_NAME,
193  };
194 
195 private:
196 
197  chip(::gpiod_chip* chip);
198 
199  void throw_if_noref(void) const;
200 
201  ::std::shared_ptr<::gpiod_chip> _m_chip;
202 
203  friend chip_iter;
204  friend line_iter;
205 };
206 
211 {
215  enum : int {
216  DIRECTION_AS_IS = 1,
228  };
229 
230  GPIOD_API static const ::std::bitset<32> FLAG_ACTIVE_LOW;
232  GPIOD_API static const ::std::bitset<32> FLAG_OPEN_SOURCE;
234  GPIOD_API static const ::std::bitset<32> FLAG_OPEN_DRAIN;
236  GPIOD_API static const ::std::bitset<32> FLAG_BIAS_DISABLE;
238  GPIOD_API static const ::std::bitset<32> FLAG_BIAS_PULL_DOWN;
240  GPIOD_API static const ::std::bitset<32> FLAG_BIAS_PULL_UP;
243  ::std::string consumer;
247  ::std::bitset<32> flags;
249 };
250 
258 class line
259 {
260 public:
261 
266 
271  GPIOD_API line(const line& other) = default;
272 
277  GPIOD_API line(line&& other) = default;
278 
284  GPIOD_API line& operator=(const line& other) = default;
285 
291  GPIOD_API line& operator=(line&& other) = default;
292 
296  GPIOD_API ~line(void) = default;
297 
302  GPIOD_API unsigned int offset(void) const;
303 
308  GPIOD_API ::std::string name(void) const;
309 
315  GPIOD_API ::std::string consumer(void) const;
316 
321  GPIOD_API int direction(void) const;
322 
327  GPIOD_API int active_state(void) const;
328 
333  GPIOD_API int bias(void) const;
334 
340  GPIOD_API bool is_used(void) const;
341 
346  GPIOD_API bool is_open_drain(void) const;
347 
352  GPIOD_API bool is_open_source(void) const;
353 
359  GPIOD_API void request(const line_request& config, int default_val = 0) const;
360 
364  GPIOD_API void release(void) const;
365 
370  GPIOD_API bool is_requested(void) const;
371 
376  GPIOD_API int get_value(void) const;
377 
382  GPIOD_API void set_value(int val) const;
383 
390  GPIOD_API void set_config(int direction, ::std::bitset<32> flags,
391  int value = 0) const;
392 
397  GPIOD_API void set_flags(::std::bitset<32> flags) const;
398 
403 
408  GPIOD_API void set_direction_output(int value = 0) const;
409 
416  GPIOD_API bool event_wait(const ::std::chrono::nanoseconds& timeout) const;
417 
423 
428  GPIOD_API ::std::vector<line_event> event_read_multiple(void) const;
429 
434  GPIOD_API int event_get_fd(void) const;
435 
440  GPIOD_API const chip& get_chip(void) const;
441 
445  GPIOD_API void update(void) const;
446 
454  GPIOD_API void reset(void);
455 
461  GPIOD_API bool operator==(const line& rhs) const noexcept;
462 
468  GPIOD_API bool operator!=(const line& rhs) const noexcept;
469 
474  GPIOD_API explicit operator bool(void) const noexcept;
475 
481  GPIOD_API bool operator!(void) const noexcept;
482 
486  enum : int {
487  DIRECTION_INPUT = 1,
491  };
492 
496  enum : int {
497  ACTIVE_LOW = 1,
499  ACTIVE_HIGH,
501  };
502 
506  enum : int {
507  BIAS_AS_IS = 1,
509  BIAS_DISABLE,
511  BIAS_PULL_UP,
515  };
516 
517 private:
518 
519  line(::gpiod_line* line, const chip& owner);
520 
521  void throw_if_null(void) const;
522  line_event make_line_event(const ::gpiod_line_event& event) const noexcept;
523 
524  ::gpiod_line* _m_line;
525  chip _m_chip;
526 
527  friend chip;
528  friend line_bulk;
529  friend line_iter;
530 };
531 
537 GPIOD_API line find_line(const ::std::string& name);
538 
543 {
544 
548  enum : int {
549  RISING_EDGE = 1,
551  FALLING_EDGE,
553  };
554 
555  ::std::chrono::nanoseconds timestamp;
561 };
562 
570 {
571 public:
572 
576  GPIOD_API line_bulk(void) = default;
577 
583  GPIOD_API line_bulk(const ::std::vector<line>& lines);
584 
589  GPIOD_API line_bulk(const line_bulk& other) = default;
590 
595  GPIOD_API line_bulk(line_bulk&& other) = default;
596 
602  GPIOD_API line_bulk& operator=(const line_bulk& other) = default;
603 
609  GPIOD_API line_bulk& operator=(line_bulk&& other) = default;
610 
614  GPIOD_API ~line_bulk(void) = default;
615 
622  GPIOD_API void append(const line& new_line);
623 
629  GPIOD_API line& get(unsigned int offset);
630 
637  GPIOD_API line& operator[](unsigned int offset);
638 
643  GPIOD_API unsigned int size(void) const noexcept;
644 
649  GPIOD_API bool empty(void) const noexcept;
650 
654  GPIOD_API void clear(void);
655 
662  GPIOD_API void request(const line_request& config,
663  const std::vector<int> default_vals = std::vector<int>()) const;
664 
668  GPIOD_API void release(void) const;
669 
675  GPIOD_API ::std::vector<int> get_values(void) const;
676 
682  GPIOD_API void set_values(const ::std::vector<int>& values) const;
683 
692  GPIOD_API void set_config(int direction, ::std::bitset<32> flags,
693  const ::std::vector<int> values = std::vector<int>()) const;
694 
699  GPIOD_API void set_flags(::std::bitset<32> flags) const;
700 
705 
711  GPIOD_API void set_direction_output(const ::std::vector<int>& values) const;
712 
720  GPIOD_API line_bulk event_wait(const ::std::chrono::nanoseconds& timeout) const;
721 
726  GPIOD_API explicit operator bool(void) const noexcept;
727 
732  GPIOD_API bool operator!(void) const noexcept;
733 
737  GPIOD_API static const unsigned int MAX_LINES;
738 
742  class iterator
743  {
744  public:
745 
749  GPIOD_API iterator(void) = default;
750 
755  GPIOD_API iterator(const iterator& other) = default;
756 
761  GPIOD_API iterator(iterator&& other) = default;
762 
768  GPIOD_API iterator& operator=(const iterator& other) = default;
769 
775  GPIOD_API iterator& operator=(iterator&& other) = default;
776 
780  GPIOD_API ~iterator(void) = default;
781 
787 
792  GPIOD_API const line& operator*(void) const;
793 
798  GPIOD_API const line* operator->(void) const;
799 
806  GPIOD_API bool operator==(const iterator& rhs) const noexcept;
807 
814  GPIOD_API bool operator!=(const iterator& rhs) const noexcept;
815 
816  private:
817 
818  iterator(const ::std::vector<line>::iterator& it);
819 
820  ::std::vector<line>::iterator _m_iter;
821 
822  friend line_bulk;
823  };
824 
829  GPIOD_API iterator begin(void) noexcept;
830 
835  GPIOD_API iterator end(void) noexcept;
836 
837 private:
838 
839  void throw_if_empty(void) const;
840  void to_line_bulk(::gpiod_line_bulk* bulk) const;
841 
842  ::std::vector<line> _m_bulk;
843 };
844 
852 
859 
865 GPIOD_API chip_iter end(const chip_iter& iter) noexcept;
866 
871 {
872 public:
873 
877  GPIOD_API chip_iter(void) = default;
878 
883  GPIOD_API chip_iter(const chip_iter& other) = default;
884 
889  GPIOD_API chip_iter(chip_iter&& other) = default;
890 
896  GPIOD_API chip_iter& operator=(const chip_iter& other) = default;
897 
903  GPIOD_API chip_iter& operator=(chip_iter&& other) = default;
904 
908  GPIOD_API ~chip_iter(void) = default;
909 
915 
920  GPIOD_API const chip& operator*(void) const;
921 
926  GPIOD_API const chip* operator->(void) const;
927 
934  GPIOD_API bool operator==(const chip_iter& rhs) const noexcept;
935 
942  GPIOD_API bool operator!=(const chip_iter& rhs) const noexcept;
943 
944 private:
945 
946  chip_iter(::gpiod_chip_iter* iter);
947 
948  ::std::shared_ptr<::gpiod_chip_iter> _m_iter;
949  chip _m_current;
950 
951  friend chip_iter make_chip_iter(void);
952 };
953 
960 
966 GPIOD_API line_iter end(const line_iter& iter) noexcept;
967 
972 {
973 public:
974 
978  GPIOD_API line_iter(void) = default;
979 
984  GPIOD_API line_iter(const chip& owner);
985 
990  GPIOD_API line_iter(const line_iter& other) = default;
991 
996  GPIOD_API line_iter(line_iter&& other) = default;
997 
1003  GPIOD_API line_iter& operator=(const line_iter& other) = default;
1004 
1011 
1015  GPIOD_API ~line_iter(void) = default;
1016 
1022 
1027  GPIOD_API const line& operator*(void) const;
1028 
1033  GPIOD_API const line* operator->(void) const;
1034 
1041  GPIOD_API bool operator==(const line_iter& rhs) const noexcept;
1042 
1049  GPIOD_API bool operator!=(const line_iter& rhs) const noexcept;
1050 
1051 private:
1052 
1053  ::std::shared_ptr<::gpiod_line_iter> _m_iter;
1054  line _m_current;
1055 };
1056 
1061 } /* namespace gpiod */
1062 
1063 #endif /* __LIBGPIOD_GPIOD_CXX_HPP__ */
gpiod::line_request::FLAG_BIAS_DISABLE
static GPIOD_API const ::std::bitset< 32 > FLAG_BIAS_DISABLE
The line has neither pull-up nor pull-down resistor enabled.
Definition: gpiod.hpp:236
gpiod::line_request::FLAG_BIAS_PULL_UP
static GPIOD_API const ::std::bitset< 32 > FLAG_BIAS_PULL_UP
The line has a configurable pull-up resistor enabled.
Definition: gpiod.hpp:240
gpiod::line_bulk::iterator::operator=
GPIOD_API iterator & operator=(iterator &&other)=default
Move assignment operator.
gpiod::line_bulk::empty
GPIOD_API bool empty(void) const noexcept
Check if this line_bulk doesn't hold any lines.
gpiod::line_event::event_type
int event_type
Type of the event that occurred.
Definition: gpiod.hpp:557
gpiod::line_bulk::event_wait
GPIOD_API line_bulk event_wait(const ::std::chrono::nanoseconds &timeout) const
Poll the set of lines for line events.
gpiod::line_bulk::set_values
GPIOD_API void set_values(const ::std::vector< int > &values) const
Set values of all lines held by this object.
gpiod::chip::OPEN_BY_PATH
@ OPEN_BY_PATH
Assume the string is a path to the GPIO chardev.
Definition: gpiod.hpp:185
gpiod::chip::chip
GPIOD_API chip(void)=default
Default constructor.
gpiod::line_iter::operator++
GPIOD_API line_iter & operator++(void)
Advance the iterator by one element.
gpiod_line_bulk
Helper structure for storing a set of GPIO line objects.
Definition: gpiod.h:700
gpiod::chip_iter::~chip_iter
GPIOD_API ~chip_iter(void)=default
Destructor.
gpiod::line::name
GPIOD_API ::std::string name(void) const
Get the name of this line (if any).
gpiod::line_bulk::iterator::operator++
GPIOD_API iterator & operator++(void)
Advance the iterator by one element.
gpiod::line::is_open_drain
GPIOD_API bool is_open_drain(void) const
Check if this line represents an open-drain GPIO.
gpiod::line::set_direction_output
GPIOD_API void set_direction_output(int value=0) const
Change the direction this lines to output.
gpiod::chip_iter::make_chip_iter
friend chip_iter make_chip_iter(void)
Create a new chip_iter.
gpiod::line::get_chip
GPIOD_API const chip & get_chip(void) const
Get the reference to the parent chip.
gpiod::chip_iter::chip_iter
GPIOD_API chip_iter(chip_iter &&other)=default
Move constructor.
gpiod::line_request::flags
::std::bitset< 32 > flags
Additional request flags.
Definition: gpiod.hpp:247
gpiod::chip::name
GPIOD_API ::std::string name(void) const
Return the name of the chip held by this object.
gpiod::line::offset
GPIOD_API unsigned int offset(void) const
Get the offset of this line.
gpiod::line_iter::operator=
GPIOD_API line_iter & operator=(line_iter &&other)=default
Move assignment operator.
gpiod::chip::OPEN_BY_NAME
@ OPEN_BY_NAME
Assume the string is the name of the chip.
Definition: gpiod.hpp:187
gpiod::line_bulk::begin
GPIOD_API iterator begin(void) noexcept
Returns an iterator to the first line.
gpiod::line::line
GPIOD_API line(void)
Default constructor.
gpiod::line_bulk::operator!
GPIOD_API bool operator!(void) const noexcept
Check if this object doesn't hold any lines.
gpiod::line_request::FLAG_OPEN_DRAIN
static GPIOD_API const ::std::bitset< 32 > FLAG_OPEN_DRAIN
The line is an open-drain port.
Definition: gpiod.hpp:234
gpiod::chip::label
GPIOD_API ::std::string label(void) const
Return the label of the chip held by this object.
gpiod::line_bulk::get_values
GPIOD_API ::std::vector< int > get_values(void) const
Read values from all lines held by this object.
gpiod::chip::~chip
GPIOD_API ~chip(void)=default
Destructor.
gpiod::line::BIAS_PULL_DOWN
@ BIAS_PULL_DOWN
Line's internal pull-down bias is enabled.
Definition: gpiod.hpp:513
gpiod::line::ACTIVE_HIGH
@ ACTIVE_HIGH
Line's active state is high.
Definition: gpiod.hpp:499
gpiod::line_iter::operator==
GPIOD_API bool operator==(const line_iter &rhs) const noexcept
Check if this operator points to the same element.
gpiod::line_bulk::end
GPIOD_API iterator end(void) noexcept
Returns an iterator to the element following the last line.
gpiod::chip::operator=
GPIOD_API chip & operator=(chip &&other)=default
Move assignment operator.
gpiod::line_bulk::iterator::iterator
GPIOD_API iterator(const iterator &other)=default
Copy constructor.
gpiod::line::active_state
GPIOD_API int active_state(void) const
Get current active state of this line.
gpiod::line_request::request_type
int request_type
Type of the request.
Definition: gpiod.hpp:245
gpiod::chip
Represents a GPIO chip.
Definition: gpiod.hpp:39
gpiod::line_bulk::get
GPIOD_API line & get(unsigned int offset)
Get the line at given offset.
gpiod::chip::get_line
GPIOD_API line get_line(unsigned int offset) const
Get the line exposed by this chip at given offset.
gpiod::line_bulk::set_direction_input
GPIOD_API void set_direction_input() const
Change the direction all lines held by this object to input.
gpiod::line_request
Stores the configuration for line requests.
Definition: gpiod.hpp:211
gpiod::line_iter::line_iter
GPIOD_API line_iter(line_iter &&other)=default
Move constructor.
gpiod::chip_iter::operator=
GPIOD_API chip_iter & operator=(const chip_iter &other)=default
Assignment operator.
gpiod::line_bulk::iterator
Iterator for iterating over lines held by line_bulk.
Definition: gpiod.hpp:743
gpiod::line_bulk::~line_bulk
GPIOD_API ~line_bulk(void)=default
Destructor.
gpiod::line_bulk::release
GPIOD_API void release(void) const
Release all lines held by this object.
gpiod::chip::chip
GPIOD_API chip(chip &&other)=default
Move constructor.
gpiod::chip::num_lines
GPIOD_API unsigned int num_lines(void) const
Return the number of lines exposed by this chip.
gpiod::line_iter::operator->
GPIOD_API const line * operator->(void) const
Member access operator.
GPIOD_API
#define GPIOD_API
Makes symbol visible.
Definition: gpiod.h:58
gpiod::line
Represents a single GPIO line.
Definition: gpiod.hpp:259
gpiod::line::operator=
GPIOD_API line & operator=(const line &other)=default
Assignment operator.
gpiod::line_bulk::clear
GPIOD_API void clear(void)
Remove all lines from this object.
gpiod::chip::OPEN_BY_NUMBER
@ OPEN_BY_NUMBER
Assume the string is the number of the GPIO chip.
Definition: gpiod.hpp:191
gpiod::line_bulk
Represents a set of GPIO lines.
Definition: gpiod.hpp:570
gpiod::line_bulk::set_flags
GPIOD_API void set_flags(::std::bitset< 32 > flags) const
Set configuration flags of all lines held by this object.
gpiod::line_request::DIRECTION_OUTPUT
@ DIRECTION_OUTPUT
Request for driving the GPIO lines.
Definition: gpiod.hpp:220
gpiod::line_iter::line_iter
GPIOD_API line_iter(const line_iter &other)=default
Copy constructor.
gpiod::line_request::EVENT_RISING_EDGE
@ EVENT_RISING_EDGE
Listen for rising edge events.
Definition: gpiod.hpp:224
gpiod::line_bulk::iterator::operator==
GPIOD_API bool operator==(const iterator &rhs) const noexcept
Check if this operator points to the same element.
gpiod::chip::chip
GPIOD_API chip(const chip &other)=default
Copy constructor.
gpiod::line_request::DIRECTION_INPUT
@ DIRECTION_INPUT
Request for reading line values.
Definition: gpiod.hpp:218
gpiod::line_event::timestamp
::std::chrono::nanoseconds timestamp
Best estimate of time of event occurrence in nanoseconds.
Definition: gpiod.hpp:555
gpiod::line_iter::line_iter
GPIOD_API line_iter(void)=default
Default constructor.
gpiod::line_bulk::set_config
GPIOD_API void set_config(int direction, ::std::bitset< 32 > flags, const ::std::vector< int > values=std::vector< int >()) const
Set configuration of all lines held by this object.
gpiod::chip::operator=
GPIOD_API chip & operator=(const chip &other)=default
Assignment operator.
gpiod::line_bulk::operator=
GPIOD_API line_bulk & operator=(line_bulk &&other)=default
Move assignment operator.
gpiod::line_iter::line_iter
GPIOD_API line_iter(const chip &owner)
Constructor.
gpiod::chip::chip
GPIOD_API chip(const ::std::string &device, int how=OPEN_LOOKUP)
Constructor.
gpiod::line_request::DIRECTION_AS_IS
@ DIRECTION_AS_IS
Request for values, don't change the direction.
Definition: gpiod.hpp:216
gpiod::chip_iter::operator->
GPIOD_API const chip * operator->(void) const
Member access operator.
gpiod::chip_iter::operator++
GPIOD_API chip_iter & operator++(void)
Advance the iterator by one element.
gpiod::line::~line
GPIOD_API ~line(void)=default
Destructor.
gpiod::line::request
GPIOD_API void request(const line_request &config, int default_val=0) const
Request this line.
gpiod::line_bulk::append
GPIOD_API void append(const line &new_line)
Add a line to this line_bulk object.
gpiod::line_bulk::iterator::~iterator
GPIOD_API ~iterator(void)=default
Destructor.
gpiod::chip_iter::operator==
GPIOD_API bool operator==(const chip_iter &rhs) const noexcept
Check if this operator points to the same element.
gpiod::line::BIAS_DISABLE
@ BIAS_DISABLE
Line's internal bias is disabled.
Definition: gpiod.hpp:509
gpiod::line_bulk::line_bulk
GPIOD_API line_bulk(line_bulk &&other)=default
Move constructor.
gpiod::line_event::source
line source
Line object referencing the GPIO line on which the event occurred.
Definition: gpiod.hpp:559
gpiod::line_request::EVENT_FALLING_EDGE
@ EVENT_FALLING_EDGE
Listen for falling edge events.
Definition: gpiod.hpp:222
gpiod::line_bulk::iterator::iterator
GPIOD_API iterator(iterator &&other)=default
Move constructor.
gpiod::line::direction
GPIOD_API int direction(void) const
Get current direction of this line.
gpiod::chip_iter
Allows to iterate over all GPIO chips present on the system.
Definition: gpiod.hpp:871
gpiod::line::update
GPIOD_API void update(void) const
Re-read the line info from the kernel.
gpiod::make_chip_iter
GPIOD_API chip_iter make_chip_iter(void)
Create a new chip_iter.
gpiod::chip_iter::chip_iter
GPIOD_API chip_iter(void)=default
Default constructor.
gpiod::line_bulk::iterator::operator=
GPIOD_API iterator & operator=(const iterator &other)=default
Assignment operator.
gpiod::find_line
GPIOD_API line find_line(const ::std::string &name)
Find a GPIO line by name.
gpiod::line_request::FLAG_BIAS_PULL_DOWN
static GPIOD_API const ::std::bitset< 32 > FLAG_BIAS_PULL_DOWN
The line has a configurable pull-down resistor enabled.
Definition: gpiod.hpp:238
gpiod::line::event_wait
GPIOD_API bool event_wait(const ::std::chrono::nanoseconds &timeout) const
Wait for an event on this line.
gpiod::line_bulk::size
GPIOD_API unsigned int size(void) const noexcept
Get the number of lines currently held by this object.
gpiod::chip_iter::operator!=
GPIOD_API bool operator!=(const chip_iter &rhs) const noexcept
Check if this operator doesn't point to the same element.
gpiod::line_bulk::line_bulk
GPIOD_API line_bulk(void)=default
Default constructor.
gpiod::chip::get_lines
GPIOD_API line_bulk get_lines(const ::std::vector< unsigned int > &offsets) const
Get a set of lines exposed by this chip at given offsets.
gpiod::chip::find_line
GPIOD_API line find_line(const ::std::string &name) const
Get the line exposed by this chip by name.
gpiod::line_bulk::iterator::operator->
GPIOD_API const line * operator->(void) const
Member access operator.
gpiod::begin
GPIOD_API line_iter begin(line_iter iter) noexcept
Support for range-based loops for line iterators.
gpiod::line::operator!
GPIOD_API bool operator!(void) const noexcept
Check if this object doesn't reference any GPIO line.
gpiod::chip::operator==
GPIOD_API bool operator==(const chip &rhs) const noexcept
Equality operator.
gpiod::line_bulk::MAX_LINES
static GPIOD_API const unsigned int MAX_LINES
Max number of lines that this object can hold.
Definition: gpiod.hpp:737
gpiod::line::set_value
GPIOD_API void set_value(int val) const
Set the value of this line.
gpiod::chip::OPEN_LOOKUP
@ OPEN_LOOKUP
Open based on the best guess what the supplied string is.
Definition: gpiod.hpp:183
gpiod::line::ACTIVE_LOW
@ ACTIVE_LOW
Line's active state is low.
Definition: gpiod.hpp:497
gpiod::chip::reset
GPIOD_API void reset(void) noexcept
Reset the internal smart pointer owned by this object.
gpiod::line_iter::operator!=
GPIOD_API bool operator!=(const line_iter &rhs) const noexcept
Check if this operator doesn't point to the same element.
gpiod::line::DIRECTION_OUTPUT
@ DIRECTION_OUTPUT
Line's direction setting is output.
Definition: gpiod.hpp:489
gpiod::end
GPIOD_API line_iter end(const line_iter &iter) noexcept
Support for range-based loops for line iterators.
gpiod::line::event_read
GPIOD_API line_event event_read(void) const
Read a line event.
gpiod::line_iter
Allows to iterate over all lines owned by a GPIO chip.
Definition: gpiod.hpp:972
gpiod::line::bias
GPIOD_API int bias(void) const
Get current bias of this line.
gpiod::line_request::FLAG_ACTIVE_LOW
static GPIOD_API const ::std::bitset< 32 > FLAG_ACTIVE_LOW
Set the active state to 'low' (high is the default).
Definition: gpiod.hpp:230
gpiod::line::line
GPIOD_API line(const line &other)=default
Copy constructor.
gpiod::line_bulk::line_bulk
GPIOD_API line_bulk(const line_bulk &other)=default
Copy constructor.
gpiod::line::reset
GPIOD_API void reset(void)
Reset the state of this object.
gpiod::chip::OPEN_BY_LABEL
@ OPEN_BY_LABEL
Assume the string is the label of the GPIO chip.
Definition: gpiod.hpp:189
gpiod::chip::find_lines
GPIOD_API line_bulk find_lines(const ::std::vector<::std::string > &names) const
Get a set of lines exposed by this chip by their names.
gpiod::line_request::EVENT_BOTH_EDGES
@ EVENT_BOTH_EDGES
Listen for all types of events.
Definition: gpiod.hpp:226
gpiod::line::set_flags
GPIOD_API void set_flags(::std::bitset< 32 > flags) const
Set configuration flags of this line.
gpiod::line::get_value
GPIOD_API int get_value(void) const
Read the line value.
gpiod::line::DIRECTION_INPUT
@ DIRECTION_INPUT
Line's direction setting is input.
Definition: gpiod.hpp:487
gpiod::chip_iter::chip_iter
GPIOD_API chip_iter(const chip_iter &other)=default
Copy constructor.
gpiod::line::is_open_source
GPIOD_API bool is_open_source(void) const
Check if this line represents an open-source GPIO.
gpiod::line::is_requested
GPIOD_API bool is_requested(void) const
Check if this user has ownership of this line.
gpiod::line_request::consumer
::std::string consumer
Consumer name to pass to the request.
Definition: gpiod.hpp:243
gpiod::line::is_used
GPIOD_API bool is_used(void) const
Check if this line is used by the kernel or other user space process.
gpiod::line_event::FALLING_EDGE
@ FALLING_EDGE
Falling edge event.
Definition: gpiod.hpp:551
gpiod::line::set_config
GPIOD_API void set_config(int direction, ::std::bitset< 32 > flags, int value=0) const
Set configuration of this line.
gpiod::line::operator==
GPIOD_API bool operator==(const line &rhs) const noexcept
Check if two line objects reference the same GPIO line.
gpiod::line_bulk::line_bulk
GPIOD_API line_bulk(const ::std::vector< line > &lines)
Construct a line_bulk from a vector of lines.
gpiod::line_bulk::iterator::operator!=
GPIOD_API bool operator!=(const iterator &rhs) const noexcept
Check if this operator doesn't point to the same element.
gpiod::line::set_direction_input
GPIOD_API void set_direction_input() const
Change the direction this line to input.
gpiod::line_bulk::operator[]
GPIOD_API line & operator[](unsigned int offset)
Get the line at given offset without bounds checking.
gpiod::chip_iter::operator*
GPIOD_API const chip & operator*(void) const
Dereference current element.
gpiod::line_bulk::iterator::iterator
GPIOD_API iterator(void)=default
Default constructor.
gpiod::chip::operator!
GPIOD_API bool operator!(void) const noexcept
Check if this object doesn't hold a reference to a GPIO chip.
gpiod::line::release
GPIOD_API void release(void) const
Release the line if it was previously requested.
gpiod::line::consumer
GPIOD_API ::std::string consumer(void) const
Get the consumer of this line (if any).
gpiod::line::line
GPIOD_API line(line &&other)=default
Move constructor.
gpiod::line::BIAS_PULL_UP
@ BIAS_PULL_UP
Line's internal pull-up bias is enabled.
Definition: gpiod.hpp:511
gpiod::line_bulk::iterator::operator*
GPIOD_API const line & operator*(void) const
Dereference current element.
gpiod::line_iter::~line_iter
GPIOD_API ~line_iter(void)=default
Destructor.
gpiod::line_request::FLAG_OPEN_SOURCE
static GPIOD_API const ::std::bitset< 32 > FLAG_OPEN_SOURCE
The line is an open-source port.
Definition: gpiod.hpp:232
gpiod::chip::open
GPIOD_API void open(const ::std::string &device, int how=OPEN_LOOKUP)
Open a GPIO chip.
gpiod::line::operator=
GPIOD_API line & operator=(line &&other)=default
Move assignment operator.
gpiod::line_bulk::request
GPIOD_API void request(const line_request &config, const std::vector< int > default_vals=std::vector< int >()) const
Request all lines held by this object.
gpiod::line::event_get_fd
GPIOD_API int event_get_fd(void) const
Get the event file descriptor associated with this line.
gpiod::line::operator!=
GPIOD_API bool operator!=(const line &rhs) const noexcept
Check if two line objects reference different GPIO lines.
gpiod::line::BIAS_AS_IS
@ BIAS_AS_IS
Line's bias state is unknown.
Definition: gpiod.hpp:507
gpiod::chip::get_all_lines
GPIOD_API line_bulk get_all_lines(void) const
Get all lines exposed by this chip.
gpiod::line::event_read_multiple
GPIOD_API ::std::vector< line_event > event_read_multiple(void) const
Read multiple line events.
gpiod::line_iter::operator=
GPIOD_API line_iter & operator=(const line_iter &other)=default
Assignment operator.
gpiod::line_bulk::set_direction_output
GPIOD_API void set_direction_output(const ::std::vector< int > &values) const
Change the direction all lines held by this object to output.
gpiod::line_event
Describes a single GPIO line event.
Definition: gpiod.hpp:543
gpiod::chip::operator!=
GPIOD_API bool operator!=(const chip &rhs) const noexcept
Inequality operator.
gpiod::chip_iter::operator=
GPIOD_API chip_iter & operator=(chip_iter &&other)=default
Move assignment operator.
gpiod::line_iter::operator*
GPIOD_API const line & operator*(void) const
Dereference current element.
gpiod::line_event::RISING_EDGE
@ RISING_EDGE
Rising edge event.
Definition: gpiod.hpp:549
gpiod::line_bulk::operator=
GPIOD_API line_bulk & operator=(const line_bulk &other)=default
Assignment operator.