libgpiod 2.1.2
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
19namespace gpiod {
20
24namespace line {
25
34class offset
35{
36public:
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
79private:
80 unsigned int _m_offset;
81};
82
86enum class value
87{
88 INACTIVE = 0,
90 ACTIVE = 1,
92};
93
97enum class direction
98{
99 AS_IS = 1,
101 INPUT,
103 OUTPUT,
105};
106
110enum class edge
111{
112 NONE = 1,
114 RISING,
116 FALLING,
118 BOTH,
120};
121
125enum class bias
126{
127 AS_IS = 1,
129 UNKNOWN,
131 DISABLED,
133 PULL_UP,
135 PULL_DOWN,
137};
138
142enum class drive
143{
144 PUSH_PULL = 1,
150};
151
155enum class clock
156{
157 MONOTONIC = 1,
159 REALTIME,
161 HTE,
162 /*<< Line uses the hardware timestamp engine for event timestamps. */
163};
164
168using offsets = ::std::vector<offset>;
169
173using values = ::std::vector<value>;
174
178using value_mapping = ::std::pair<offset, value>;
179
184using 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__ */
Wrapper around unsigned int for representing line offsets.
Definition line.hpp:35
offset(const offset &other)=default
Copy constructor.
offset(offset &&other)=default
Move constructor.
offset & operator=(offset &&other) noexcept=default
Move assignment operator.
offset(unsigned int off=0)
Constructor with implicit conversion from unsigned int.
Definition line.hpp:41
offset & operator=(const offset &other)=default
Assignment operator.
::std::pair< offset, value > value_mapping
Represents a mapping of a line offset to line logical state.
Definition line.hpp:178
::std::vector< value_mapping > value_mappings
Vector of offset->value mappings.
Definition line.hpp:184
edge
Edge detection settings.
Definition line.hpp:111
@ FALLING
Line detect falling edge events.
@ BOTH
Line detects both rising and falling edge events.
@ RISING
Line detects rising edge events.
@ NONE
Line edge detection is disabled.
direction
Direction settings.
Definition line.hpp:98
@ OUTPUT
Direction is output - we're driving the GPIO line.
@ INPUT
Direction is input - we're reading the state of a GPIO line.
@ AS_IS
Request the line(s), but don't change current direction.
clock
Event clock settings.
Definition line.hpp:156
@ MONOTONIC
Line uses the monotonic clock for edge event timestamps.
@ REALTIME
Line uses the realtime clock for edge event timestamps.
::std::ostream & operator<<(::std::ostream &out, value val)
Stream insertion operator for logical line values.
::std::vector< value > values
Vector of line values.
Definition line.hpp:173
::std::vector< offset > offsets
Vector of line offsets.
Definition line.hpp:168
drive
Drive settings.
Definition line.hpp:143
@ PUSH_PULL
Drive setting is push-pull.
@ OPEN_SOURCE
Line output is open-source.
@ OPEN_DRAIN
Line output is open-drain.
bias
Internal bias settings.
Definition line.hpp:126
@ DISABLED
The internal bias is disabled.
@ PULL_UP
The internal pull-up bias is enabled.
@ PULL_DOWN
The internal pull-down bias is enabled.
@ UNKNOWN
The internal bias state is unknown.
value
Logical line states.
Definition line.hpp:87
@ ACTIVE
Line is active.
@ INACTIVE
Line is inactive.