libgpiod
line.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-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 
29 class offset
30 {
31 public:
36  offset(unsigned int off = 0) : _m_offset(off) { }
37 
42  offset(const offset& other) = default;
43 
48  offset(offset&& other) = default;
49 
50  ~offset() = default;
51 
57  offset& operator=(const offset& other) = default;
58 
64  offset& operator=(offset&& other) noexcept = default;
65 
69  operator unsigned int() const noexcept
70  {
71  return this->_m_offset;
72  }
73 
74 private:
75  unsigned int _m_offset;
76 };
77 
81 enum class value
82 {
83  INACTIVE = 0,
85  ACTIVE = 1,
87 };
88 
92 enum class direction
93 {
94  AS_IS = 1,
96  INPUT,
98  OUTPUT,
100 };
101 
105 enum class edge
106 {
107  NONE = 1,
109  RISING,
111  FALLING,
113  BOTH,
115 };
116 
120 enum class bias
121 {
122  AS_IS = 1,
124  UNKNOWN,
126  DISABLED,
128  PULL_UP,
130  PULL_DOWN,
132 };
133 
137 enum class drive
138 {
139  PUSH_PULL = 1,
141  OPEN_DRAIN,
143  OPEN_SOURCE,
145 };
146 
150 enum class clock
151 {
152  MONOTONIC = 1,
154  REALTIME,
156  HTE,
157  /*<< Line uses the hardware timestamp engine for event timestamps. */
158 };
159 
163 using offsets = ::std::vector<offset>;
164 
168 using values = ::std::vector<value>;
169 
173 using value_mapping = ::std::pair<offset, value>;
174 
179 using value_mappings = ::std::vector<value_mapping>;
180 
187 ::std::ostream& operator<<(::std::ostream& out, value val);
188 
195 ::std::ostream& operator<<(::std::ostream& out, direction dir);
196 
203 ::std::ostream& operator<<(::std::ostream& out, edge edge);
204 
211 ::std::ostream& operator<<(::std::ostream& out, bias bias);
212 
219 ::std::ostream& operator<<(::std::ostream& out, drive drive);
220 
227 ::std::ostream& operator<<(::std::ostream& out, clock clock);
228 
235 ::std::ostream& operator<<(::std::ostream& out, const values& vals);
236 
243 ::std::ostream& operator<<(::std::ostream& out, const offsets& offs);
244 
252 ::std::ostream& operator<<(::std::ostream& out, const value_mapping& mapping);
253 
261 ::std::ostream& operator<<(::std::ostream& out, const value_mappings& mappings);
262 
263 } /* namespace line */
264 
265 } /* namespace gpiod */
266 
267 #endif /* __LIBGPIOD_CXX_LINE_HPP__ */
Definition: chip-info.hpp:18
edge
Edge detection settings.
Definition: line.hpp:105
::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:36
::std::vector< value > values
Vector of line values.
Definition: line.hpp:168
offset & operator=(const offset &other)=default
Assignment operator.
value
Logical line states.
Definition: line.hpp:81
direction
Direction settings.
Definition: line.hpp:92
clock
Event clock settings.
Definition: line.hpp:150
bias
Internal bias settings.
Definition: line.hpp:120
::std::vector< offset > offsets
Vector of line offsets.
Definition: line.hpp:163
Wrapper around unsigned int for representing line offsets.
Definition: line.hpp:29
::std::pair< offset, value > value_mapping
Represents a mapping of a line offset to line logical state.
Definition: line.hpp:173
::std::vector< value_mapping > value_mappings
Vector of offset->value mappings. Each mapping is defined as a pair of an unsigned and signed integer...
Definition: line.hpp:179
drive
Drive settings.
Definition: line.hpp:137