libgpiod
Loading...
Searching...
No Matches
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
29class offset
30{
31public:
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
74private:
75 unsigned int _m_offset;
76};
77
81enum class value
82{
83 INACTIVE = 0,
85 ACTIVE = 1,
87};
88
92enum class direction
93{
94 AS_IS = 1,
96 INPUT,
98 OUTPUT,
100};
101
105enum class edge
106{
107 NONE = 1,
109 RISING,
111 FALLING,
113 BOTH,
115};
116
120enum class bias
121{
122 AS_IS = 1,
124 UNKNOWN,
126 DISABLED,
128 PULL_UP,
130 PULL_DOWN,
132};
133
137enum class drive
138{
139 PUSH_PULL = 1,
145};
146
150enum class clock
151{
152 MONOTONIC = 1,
154 REALTIME,
156 HTE,
157 /*<< Line uses the hardware timestamp engine for event timestamps. */
158};
159
163using offsets = ::std::vector<offset>;
164
168using values = ::std::vector<value>;
169
173using value_mapping = ::std::pair<offset, value>;
174
179using 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__ */
Wrapper around unsigned int for representing line offsets.
Definition line.hpp:30
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:36
offset & operator=(const offset &other)=default
Assignment operator.
::std::vector< offset > offsets
Vector of line offsets.
Definition line.hpp:163
::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
edge
Edge detection settings.
Definition line.hpp:106
direction
Direction settings.
Definition line.hpp:93
::std::pair< offset, value > value_mapping
Represents a mapping of a line offset to line logical state.
Definition line.hpp:173
::std::vector< value > values
Vector of line values.
Definition line.hpp:168
clock
Event clock settings.
Definition line.hpp:151
::std::ostream & operator<<(::std::ostream &out, value val)
Stream insertion operator for logical line values.
drive
Drive settings.
Definition line.hpp:138
bias
Internal bias settings.
Definition line.hpp:121
value
Logical line states.
Definition line.hpp:82
Definition chip-info.hpp:18