libgpiod  1.6.2
gpiod.hpp
Go to the documentation of this file.
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_iter;
23 class chip_iter;
24 struct line_event;
25 
42 class chip
43 {
44 public:
45 
49  GPIOD_API chip(void) = default;
50 
56  GPIOD_API chip(const ::std::string& device, int how = OPEN_LOOKUP);
57 
62  GPIOD_API chip(const chip& other) = default;
63 
68  GPIOD_API chip(chip&& other) = default;
69 
75  GPIOD_API chip& operator=(const chip& other) = default;
76 
82  GPIOD_API chip& operator=(chip&& other) = default;
83 
87  GPIOD_API ~chip(void) = default;
88 
97  GPIOD_API void open(const ::std::string &device, int how = OPEN_LOOKUP);
98 
102  GPIOD_API void reset(void) noexcept;
103 
108  GPIOD_API ::std::string name(void) const;
109 
114  GPIOD_API ::std::string label(void) const;
115 
120  GPIOD_API unsigned int num_lines(void) const;
121 
127  GPIOD_API line get_line(unsigned int offset) const;
128 
134  GPIOD_API line find_line(const ::std::string& name) const;
135 
141  GPIOD_API line_bulk get_lines(const ::std::vector<unsigned int>& offsets) const;
142 
148 
154  GPIOD_API line_bulk find_lines(const ::std::vector<::std::string>& names) const;
155 
161  GPIOD_API bool operator==(const chip& rhs) const noexcept;
162 
168  GPIOD_API bool operator!=(const chip& rhs) const noexcept;
169 
174  GPIOD_API explicit operator bool(void) const noexcept;
175 
180  GPIOD_API bool operator!(void) const noexcept;
181 
186  enum : int {
187  OPEN_LOOKUP = 1,
189  OPEN_BY_PATH,
191  OPEN_BY_NAME,
197  };
198 
199 private:
200 
201  chip(::gpiod_chip* chip);
202 
203  void throw_if_noref(void) const;
204 
205  ::std::shared_ptr<::gpiod_chip> _m_chip;
206 
207  friend chip_iter;
208  friend line_iter;
209 };
210 
215 {
219  enum : int {
220  DIRECTION_AS_IS = 1,
232  };
233 
234  GPIOD_API static const ::std::bitset<32> FLAG_ACTIVE_LOW;
236  GPIOD_API static const ::std::bitset<32> FLAG_OPEN_SOURCE;
238  GPIOD_API static const ::std::bitset<32> FLAG_OPEN_DRAIN;
240  GPIOD_API static const ::std::bitset<32> FLAG_BIAS_DISABLE;
242  GPIOD_API static const ::std::bitset<32> FLAG_BIAS_PULL_DOWN;
244  GPIOD_API static const ::std::bitset<32> FLAG_BIAS_PULL_UP;
247  ::std::string consumer;
251  ::std::bitset<32> flags;
253 };
254 
262 class line
263 {
264 public:
265 
270 
275  GPIOD_API line(const line& other) = default;
276 
281  GPIOD_API line(line&& other) = default;
282 
288  GPIOD_API line& operator=(const line& other) = default;
289 
295  GPIOD_API line& operator=(line&& other) = default;
296 
300  GPIOD_API ~line(void) = default;
301 
306  GPIOD_API unsigned int offset(void) const;
307 
312  GPIOD_API ::std::string name(void) const;
313 
319  GPIOD_API ::std::string consumer(void) const;
320 
325  GPIOD_API int direction(void) const;
326 
331  GPIOD_API int active_state(void) const;
332 
337  GPIOD_API int bias(void) const;
338 
344  GPIOD_API bool is_used(void) const;
345 
350  GPIOD_API bool is_open_drain(void) const;
351 
356  GPIOD_API bool is_open_source(void) const;
357 
363  GPIOD_API void request(const line_request& config, int default_val = 0) const;
364 
368  GPIOD_API void release(void) const;
369 
374  GPIOD_API bool is_requested(void) const;
375 
380  GPIOD_API int get_value(void) const;
381 
386  GPIOD_API void set_value(int val) const;
387 
394  GPIOD_API void set_config(int direction, ::std::bitset<32> flags,
395  int value = 0) const;
396 
401  GPIOD_API void set_flags(::std::bitset<32> flags) const;
402 
407 
412  GPIOD_API void set_direction_output(int value = 0) const;
413 
420  GPIOD_API bool event_wait(const ::std::chrono::nanoseconds& timeout) const;
421 
427 
432  GPIOD_API ::std::vector<line_event> event_read_multiple(void) const;
433 
438  GPIOD_API int event_get_fd(void) const;
439 
444  GPIOD_API const chip& get_chip(void) const;
445 
449  GPIOD_API void update(void) const;
450 
458  GPIOD_API void reset(void);
459 
465  GPIOD_API bool operator==(const line& rhs) const noexcept;
466 
472  GPIOD_API bool operator!=(const line& rhs) const noexcept;
473 
478  GPIOD_API explicit operator bool(void) const noexcept;
479 
485  GPIOD_API bool operator!(void) const noexcept;
486 
490  enum : int {
491  DIRECTION_INPUT = 1,
495  };
496 
500  enum : int {
501  ACTIVE_LOW = 1,
503  ACTIVE_HIGH,
505  };
506 
510  enum : int {
511  BIAS_AS_IS = 1,
513  BIAS_DISABLE,
515  BIAS_PULL_UP,
519  };
520 
521 private:
522 
523  line(::gpiod_line* line, const chip& owner);
524 
525  void throw_if_null(void) const;
526  line_event make_line_event(const ::gpiod_line_event& event) const noexcept;
527 
528  ::gpiod_line* _m_line;
529  chip _m_chip;
530 
531  friend chip;
532  friend line_bulk;
533  friend line_iter;
534 };
535 
541 GPIOD_API line find_line(const ::std::string& name);
542 
547 {
551  enum : int {
552  RISING_EDGE = 1,
554  FALLING_EDGE,
556  };
557 
558  ::std::chrono::nanoseconds timestamp;
564 };
565 
573 {
574 public:
575 
579  GPIOD_API line_bulk(void) = default;
580 
586  GPIOD_API line_bulk(const ::std::vector<line>& lines);
587 
592  GPIOD_API line_bulk(const line_bulk& other) = default;
593 
598  GPIOD_API line_bulk(line_bulk&& other) = default;
599 
605  GPIOD_API line_bulk& operator=(const line_bulk& other) = default;
606 
612  GPIOD_API line_bulk& operator=(line_bulk&& other) = default;
613 
617  GPIOD_API ~line_bulk(void) = default;
618 
625  GPIOD_API void append(const line& new_line);
626 
632  GPIOD_API line& get(unsigned int offset);
633 
640  GPIOD_API line& operator[](unsigned int offset);
641 
646  GPIOD_API unsigned int size(void) const noexcept;
647 
652  GPIOD_API bool empty(void) const noexcept;
653 
657  GPIOD_API void clear(void);
658 
665  GPIOD_API void request(const line_request& config,
666  const ::std::vector<int> default_vals = ::std::vector<int>()) const;
667 
671  GPIOD_API void release(void) const;
672 
678  GPIOD_API ::std::vector<int> get_values(void) const;
679 
685  GPIOD_API void set_values(const ::std::vector<int>& values) const;
686 
695  GPIOD_API void set_config(int direction, ::std::bitset<32> flags,
696  const ::std::vector<int> values = ::std::vector<int>()) const;
697 
702  GPIOD_API void set_flags(::std::bitset<32> flags) const;
703 
708 
714  GPIOD_API void set_direction_output(const ::std::vector<int>& values) const;
715 
723  GPIOD_API line_bulk event_wait(const ::std::chrono::nanoseconds& timeout) const;
724 
729  GPIOD_API explicit operator bool(void) const noexcept;
730 
735  GPIOD_API bool operator!(void) const noexcept;
736 
740  GPIOD_API static const unsigned int MAX_LINES;
741 
745  class iterator
746  {
747  public:
748 
752  GPIOD_API iterator(void) = default;
753 
758  GPIOD_API iterator(const iterator& other) = default;
759 
764  GPIOD_API iterator(iterator&& other) = default;
765 
771  GPIOD_API iterator& operator=(const iterator& other) = default;
772 
778  GPIOD_API iterator& operator=(iterator&& other) = default;
779 
783  GPIOD_API ~iterator(void) = default;
784 
790 
795  GPIOD_API const line& operator*(void) const;
796 
801  GPIOD_API const line* operator->(void) const;
802 
809  GPIOD_API bool operator==(const iterator& rhs) const noexcept;
810 
817  GPIOD_API bool operator!=(const iterator& rhs) const noexcept;
818 
819  private:
820 
821  iterator(const ::std::vector<line>::iterator& it);
822 
823  ::std::vector<line>::iterator _m_iter;
824 
825  friend line_bulk;
826  };
827 
832  GPIOD_API iterator begin(void) noexcept;
833 
838  GPIOD_API iterator end(void) noexcept;
839 
840 private:
841 
842  void throw_if_empty(void) const;
843  void to_line_bulk(::gpiod_line_bulk* bulk) const;
844 
845  ::std::vector<line> _m_bulk;
846 };
847 
855 
862 
868 GPIOD_API chip_iter end(const chip_iter& iter) noexcept;
869 
874 {
875 public:
876 
880  GPIOD_API chip_iter(void) = default;
881 
886  GPIOD_API chip_iter(const chip_iter& other) = default;
887 
892  GPIOD_API chip_iter(chip_iter&& other) = default;
893 
899  GPIOD_API chip_iter& operator=(const chip_iter& other) = default;
900 
906  GPIOD_API chip_iter& operator=(chip_iter&& other) = default;
907 
911  GPIOD_API ~chip_iter(void) = default;
912 
918 
923  GPIOD_API const chip& operator*(void) const;
924 
929  GPIOD_API const chip* operator->(void) const;
930 
937  GPIOD_API bool operator==(const chip_iter& rhs) const noexcept;
938 
945  GPIOD_API bool operator!=(const chip_iter& rhs) const noexcept;
946 
947 private:
948 
949  chip_iter(::gpiod_chip_iter* iter);
950 
951  ::std::shared_ptr<::gpiod_chip_iter> _m_iter;
952  chip _m_current;
953 
954  friend chip_iter make_chip_iter(void);
955 };
956 
963 
969 GPIOD_API line_iter end(const line_iter& iter) noexcept;
970 
975 {
976 public:
977 
981  GPIOD_API line_iter(void) = default;
982 
987  GPIOD_API line_iter(const chip& owner);
988 
993  GPIOD_API line_iter(const line_iter& other) = default;
994 
999  GPIOD_API line_iter(line_iter&& other) = default;
1000 
1006  GPIOD_API line_iter& operator=(const line_iter& other) = default;
1007 
1014 
1018  GPIOD_API ~line_iter(void) = default;
1019 
1025 
1030  GPIOD_API const line& operator*(void) const;
1031 
1036  GPIOD_API const line* operator->(void) const;
1037 
1044  GPIOD_API bool operator==(const line_iter& rhs) const noexcept;
1045 
1052  GPIOD_API bool operator!=(const line_iter& rhs) const noexcept;
1053 
1054 private:
1055 
1056  ::std::shared_ptr<::gpiod_line_iter> _m_iter;
1057  line _m_current;
1058 };
1059 
1064 } /* namespace gpiod */
1065 
1066 #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:240
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:244
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:560
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:189
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:722
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:251
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:191
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:238
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:517
gpiod::line::ACTIVE_HIGH
@ ACTIVE_HIGH
Line's active state is high.
Definition: gpiod.hpp:503
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_API
#define GPIOD_API
Makes symbol visible.
Definition: gpiod.h:62
gpiod::line::active_state
GPIOD_API int active_state(void) const
Get current active state of this line.
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_request::request_type
int request_type
Type of the request.
Definition: gpiod.hpp:249
gpiod::chip
Represents a GPIO chip.
Definition: gpiod.hpp:43
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:215
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:746
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.h
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::line
Represents a single GPIO line.
Definition: gpiod.hpp:263
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:195
gpiod::line_bulk
Represents a set of GPIO lines.
Definition: gpiod.hpp:573
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:224
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:228
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:222
gpiod::line_event::timestamp
::std::chrono::nanoseconds timestamp
Best estimate of time of event occurrence in nanoseconds.
Definition: gpiod.hpp:558
gpiod::line_iter::line_iter
GPIOD_API line_iter(void)=default
Default constructor.
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:220
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:513
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:562
gpiod::line_request::EVENT_FALLING_EDGE
@ EVENT_FALLING_EDGE
Listen for falling edge events.
Definition: gpiod.hpp:226
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:874
gpiod::line::update
GPIOD_API void update(void) const
Re-read the line info from the kernel.
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::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:242
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::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_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::end
GPIOD_API line_iter end(const line_iter &iter) noexcept
Support for range-based loops for line iterators.
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::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:740
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:187
gpiod::line::ACTIVE_LOW
@ ACTIVE_LOW
Line's active state is low.
Definition: gpiod.hpp:501
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:493
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:975
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:234
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::make_chip_iter
GPIOD_API chip_iter make_chip_iter(void)
Create a new chip_iter.
gpiod::chip::OPEN_BY_LABEL
@ OPEN_BY_LABEL
Assume the string is the label of the GPIO chip.
Definition: gpiod.hpp:193
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:230
gpiod::line::set_flags
GPIOD_API void set_flags(::std::bitset< 32 > flags) const
Set configuration flags of this line.
gpiod::find_line
GPIOD_API line find_line(const ::std::string &name)
Find a GPIO line by name.
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:491
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:247
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:554
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:515
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:236
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::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::begin
GPIOD_API line_iter begin(line_iter iter) noexcept
Support for range-based loops for line iterators.
gpiod::line::BIAS_AS_IS
@ BIAS_AS_IS
Line's bias state is unknown.
Definition: gpiod.hpp:511
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:547
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:552
gpiod::line_bulk::operator=
GPIOD_API line_bulk & operator=(const line_bulk &other)=default
Assignment operator.