libgpiod  2.1
line.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-3.0-or-later */
2 /* SPDX-FileCopyrightText: 2021-2022 Bartosz Golaszewski <brgl@bgdev.pl> */
3 
8 #ifndef __LIBGPIOD_CXX_LINE_HPP__
9 #define __LIBGPIOD_CXX_LINE_HPP__
10 
11 #if !defined(__LIBGPIOD_GPIOD_CXX_INSIDE__)
12 #error "Only gpiod.hpp can be included directly."
13 #endif
14 
15 #include <ostream>
16 #include <utility>
17 #include <vector>
18 
19 namespace gpiod {
20 
24 namespace line {
25 
34 class offset
35 {
36 public:
41  offset(unsigned int off = 0) : _m_offset(off) { }
42 
47  offset(const offset& other) = default;
48 
53  offset(offset&& other) = default;
54 
55  ~offset() = default;
56 
62  offset& operator=(const offset& other) = default;
63 
69  offset& operator=(offset&& other) noexcept = default;
70 
74  operator unsigned int() const noexcept
75  {
76  return this->_m_offset;
77  }
78 
79 private:
80  unsigned int _m_offset;
81 };
82 
86 enum class value
87 {
88  INACTIVE = 0,
90  ACTIVE = 1,
92 };
93 
97 enum class direction
98 {
99  AS_IS = 1,
101  INPUT,
103  OUTPUT,
105 };
106 
110 enum class edge
111 {
112  NONE = 1,
114  RISING,
116  FALLING,
118  BOTH,
120 };
121 
125 enum class bias
126 {
127  AS_IS = 1,
129  UNKNOWN,
131  DISABLED,
133  PULL_UP,
135  PULL_DOWN,
137 };
138 
142 enum class drive
143 {
144  PUSH_PULL = 1,
146  OPEN_DRAIN,
148  OPEN_SOURCE,
150 };
151 
155 enum class clock
156 {
157  MONOTONIC = 1,
159  REALTIME,
161  HTE,
162  /*<< Line uses the hardware timestamp engine for event timestamps. */
163 };
164 
168 using offsets = ::std::vector<offset>;
169 
173 using values = ::std::vector<value>;
174 
178 using value_mapping = ::std::pair<offset, value>;
179 
184 using value_mappings = ::std::vector<value_mapping>;
185 
192 ::std::ostream& operator<<(::std::ostream& out, value val);
193 
200 ::std::ostream& operator<<(::std::ostream& out, direction dir);
201 
208 ::std::ostream& operator<<(::std::ostream& out, edge edge);
209 
216 ::std::ostream& operator<<(::std::ostream& out, bias bias);
217 
224 ::std::ostream& operator<<(::std::ostream& out, drive drive);
225 
232 ::std::ostream& operator<<(::std::ostream& out, clock clock);
233 
240 ::std::ostream& operator<<(::std::ostream& out, const values& vals);
241 
248 ::std::ostream& operator<<(::std::ostream& out, const offsets& offs);
249 
257 ::std::ostream& operator<<(::std::ostream& out, const value_mapping& mapping);
258 
266 ::std::ostream& operator<<(::std::ostream& out, const value_mappings& mappings);
267 
272 } /* namespace line */
273 
274 } /* namespace gpiod */
275 
276 #endif /* __LIBGPIOD_CXX_LINE_HPP__ */
The internal pull-down bias is enabled.
Line output is open-drain.
edge
Edge detection settings.
Definition: line.hpp:110
Line uses the realtime clock for edge event timestamps.
Direction is input - we're reading the state of a GPIO line.
::std::ostream & operator<<(::std::ostream &out, value val)
Stream insertion operator for logical line values.
offset(unsigned int off=0)
Constructor with implicit conversion from unsigned int.
Definition: line.hpp:41
Line detect falling edge events.
::std::vector< value > values
Vector of line values.
Definition: line.hpp:173
offset & operator=(const offset &other)=default
Assignment operator.
The internal bias state is unknown.
Request the line(s), but don't change current direction.
Line detects both rising and falling edge events.
Line detects rising edge events.
value
Logical line states.
Definition: line.hpp:86
Drive setting is push-pull.
direction
Direction settings.
Definition: line.hpp:97
clock
Event clock settings.
Definition: line.hpp:155
bias
Internal bias settings.
Definition: line.hpp:125
The internal pull-up bias is enabled.
Line uses the monotonic clock for edge event timestamps.
::std::vector< offset > offsets
Vector of line offsets.
Definition: line.hpp:168
Wrapper around unsigned int for representing line offsets.
Definition: line.hpp:34
Line edge detection is disabled.
::std::pair< offset, value > value_mapping
Represents a mapping of a line offset to line logical state.
Definition: line.hpp:178
Direction is output - we're driving the GPIO line.
::std::vector< value_mapping > value_mappings
Vector of offset->value mappings.
Definition: line.hpp:184
drive
Drive settings.
Definition: line.hpp:142
The internal bias is disabled.
Line output is open-source.