17
17
#include < algorithm>
18
18
19
19
#include " software_port.hpp"
20
- #include " gpio_accessor .hpp"
20
+ #include " runtime_gpio .hpp"
21
21
22
22
namespace modm ::platform
23
23
{
@@ -37,7 +37,7 @@ namespace modm::platform
37
37
*
38
38
* Port port;
39
39
* // set pin C8
40
- * GpioAccessor pin = port[0];
40
+ * RtGpio pin = port[0];
41
41
* pin.set();
42
42
*
43
43
* auto reversedPins = port | std::views::reverse;
@@ -56,10 +56,10 @@ class RandomAccessPort : public SoftwareGpioPort<Gpios...>
56
56
{
57
57
public:
58
58
using Index = int_fast8_t ;
59
- static constexpr inline size_t Size{sizeof ...(Gpios)};
59
+ static constexpr size_t Size{sizeof ...(Gpios)};
60
60
61
61
private:
62
- static constexpr inline std::array<GpioAccessor , Size> GpioPins = [](){
62
+ static constexpr std::array<RtGpio , Size> gpioPins = [](){
63
63
auto gpios = makeGpioArray<Gpios...>();
64
64
// Reverse pin order to match SoftwareGpioPort indexing
65
65
std::reverse (gpios.begin (), gpios.end ());
@@ -77,53 +77,53 @@ class RandomAccessPort : public SoftwareGpioPort<Gpios...>
77
77
public:
78
78
using iterator_category = std::random_access_iterator_tag;
79
79
using difference_type = Index;
80
- using value_type = GpioAccessor ;
81
- using reference = const GpioAccessor &;
80
+ using value_type = RtGpio ;
81
+ using reference = RtGpio &;
82
82
83
83
constexpr GpioIterator () = default;
84
84
constexpr explicit GpioIterator (Index index) : index_{index}
85
85
{}
86
86
87
- constexpr inline GpioIterator&
87
+ constexpr GpioIterator&
88
88
operator +=(difference_type diff) { index_ += diff; return *this ; }
89
89
90
- constexpr inline GpioIterator&
90
+ constexpr GpioIterator&
91
91
operator -=(difference_type diff) { index_ -= diff; return *this ; }
92
92
93
- constexpr inline reference
94
- operator *() const { return RandomAccessPort::GpioPins [index_]; }
93
+ constexpr reference
94
+ operator *() const { return RandomAccessPort::gpioPins [index_]; }
95
95
96
- constexpr inline reference
97
- operator [](difference_type diff) const { return RandomAccessPort::GpioPins [index_ + diff]; }
96
+ constexpr reference
97
+ operator [](difference_type diff) const { return RandomAccessPort::gpioPins [index_ + diff]; }
98
98
99
- constexpr inline GpioIterator&
99
+ constexpr GpioIterator&
100
100
operator ++() { ++index_; return *this ; }
101
101
102
- constexpr inline GpioIterator&
102
+ constexpr GpioIterator&
103
103
operator --() { --index_; return *this ; }
104
104
105
- constexpr inline GpioIterator
105
+ constexpr GpioIterator
106
106
operator ++(int ) { GpioIterator tmp{*this }; ++index_; return tmp; }
107
107
108
- constexpr inline GpioIterator
108
+ constexpr GpioIterator
109
109
operator --(int ) { GpioIterator tmp{*this }; --index_; return tmp; }
110
110
111
- constexpr inline difference_type
111
+ constexpr difference_type
112
112
operator -(const GpioIterator& rhs) const { return index_ - rhs.index_ ; }
113
113
114
- constexpr inline GpioIterator
114
+ constexpr GpioIterator
115
115
operator +(difference_type diff) const { return GpioIterator{index_ + diff}; }
116
116
117
- constexpr inline GpioIterator
117
+ constexpr GpioIterator
118
118
operator -(difference_type diff) const { return GpioIterator{index_ - diff}; }
119
119
120
- friend constexpr inline GpioIterator
120
+ friend constexpr GpioIterator
121
121
operator +(difference_type lhs, const GpioIterator& rhs) { return GpioIterator{lhs + rhs.index_ }; }
122
122
123
- friend constexpr inline GpioIterator
123
+ friend constexpr GpioIterator
124
124
operator -(difference_type lhs, const GpioIterator& rhs) { return GpioIterator{lhs - rhs.index_ }; }
125
125
126
- constexpr inline auto
126
+ constexpr auto
127
127
operator <=>(const GpioIterator& rhs) const = default ;
128
128
};
129
129
static_assert (std::random_access_iterator<GpioIterator>);
@@ -134,40 +134,40 @@ class RandomAccessPort : public SoftwareGpioPort<Gpios...>
134
134
constexpr GpioIterator
135
135
end () const { return GpioIterator{Size}; }
136
136
137
- constexpr const GpioAccessor &
137
+ constexpr const RtGpio &
138
138
operator [](Index index) const
139
139
{
140
- return GpioPins [index];
140
+ return gpioPins [index];
141
141
}
142
142
143
143
static void set (Index index, bool enable)
144
144
{
145
- GpioPins [index].set (enable);
145
+ gpioPins [index].set (enable);
146
146
}
147
147
148
148
static void set (Index index)
149
149
{
150
- GpioPins [index].set ();
150
+ gpioPins [index].set ();
151
151
}
152
152
153
153
static void reset (Index index)
154
154
{
155
- GpioPins [index].reset ();
155
+ gpioPins [index].reset ();
156
156
}
157
157
158
158
static void toggle (Index index)
159
159
{
160
- GpioPins [index].toggle ();
160
+ gpioPins [index].toggle ();
161
161
}
162
162
163
163
static bool read (Index index)
164
164
{
165
- return GpioPins [index].read ();
165
+ return gpioPins [index].read ();
166
166
}
167
167
168
168
static bool isSet (Index index)
169
169
{
170
- return GpioPins [index].isSet ();
170
+ return gpioPins [index].isSet ();
171
171
}
172
172
};
173
173
0 commit comments