GCC Code Coverage Report


Directory: ./
File: util/BBBUtils.cpp
Date: 2026-10-29 08:11:58
Exec Total Coverage
Lines: 376 486 77.4%
Functions: 17 23 73.9%
Branches: 509 1040 48.9%

Line Branch Exec Source
1 /*
2 * This file is part of the Falcon Player (FPP) and is Copyright (C)
3 * 2013-2022 by the Falcon Player Developers.
4 *
5 * The Falcon Player (FPP) is free software, and is covered under
6 * multiple Open Source licenses. Please see the included 'LICENSES'
7 * file for descriptions of what files are covered by each license.
8 *
9 * This source file is covered under the LGPL v2.1 as described in the
10 * included LICENSE.LGPL file.
11 */
12
13 #include "fpp-pch.h"
14
15 #include "fpp-json.h"
16
17 #include "BBBUtils.h"
18 #include <sys/mman.h>
19 #include <dirent.h>
20 #include <fcntl.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23
24 #include "../common.h"
25
26 static BeagleBoneType BBB_TYPE = Unknown;
27 124 BeagleBoneType getBeagleBoneType() {
28
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 15 times.
124 if (BBB_TYPE == Unknown) {
29 109 FILE* file = fopen("/proc/device-tree/model", "r");
30
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if (file) {
31 char buf[256];
32
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 fgets(buf, 256, file);
33
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 fclose(file);
34
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (strcmp(buf, "SanCloud BeagleBone Enhanced") == 0) {
35 ✗ BBB_TYPE = SanCloudEnhanced;
36
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 98 times.
109 } else if (strcmp(&buf[10], "PocketBeagle") == 0) {
37 11 BBB_TYPE = PocketBeagle;
38
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 21 times.
98 } else if (strcmp(buf, "BeagleBoard.org PocketBeagle2") == 0) {
39 77 BBB_TYPE = PocketBeagle;
40
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 } else if (strcmp(buf, "BeagleBoard.org BeaglePlay") == 0) {
41 ✗ BBB_TYPE = BeaglePlay;
42
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 } else if (strcmp(&buf[10], "BeagleBone Black Wireless") == 0) {
43 ✗ BBB_TYPE = BlackWireless;
44
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 } else if (strcmp(&buf[10], "BeagleBone Green Wireless") == 0) {
45 ✗ BBB_TYPE = GreenWireless;
46
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 } else if (strcmp(&buf[10], "BeagleBone Green") == 0) {
47 ✗ BBB_TYPE = Green;
48 } else {
49 21 BBB_TYPE = Black;
50 }
51 } else {
52 ✗ BBB_TYPE = Black;
53 }
54 }
55 124 return BBB_TYPE;
56 }
57
58 static std::vector<BBBPinCapabilities> BBB_PINS;
59
60 // 1MHz frequence
61 // #define HZ 1000000.0f
62 #define HZ 10000.0f
63
64 // static uint32_t bbGPIOMap[] = { 3, 0, 1, 2 };
65 static uint32_t bbGPIOMap[] = { 0, 0, 0, 0 };
66 static const char* bbbPWMDeviceName = "/sys/class/pwm/pwmchip";
67 static FILE* bbbPWMDutyFiles[] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
68
69 static volatile bool registersMemMapped = false;
70
71 ✗ static int getBBBPWMChipNum(int pwm) {
72 static const char* bbbPWMChipNums[] = { "48300200", "48302200", "48304200" };
73 char buf[256];
74 ✗ for (int x = 0; x < 10; x++) {
75 ✗ snprintf(buf, sizeof(buf), "/sys/bus/platform/drivers/ehrpwm/%s.pwm/pwm/pwmchip%d", bbbPWMChipNums[pwm], x);
76 ✗ if (access(buf, F_OK) == 0) {
77 ✗ return x;
78 }
79 }
80 ✗ return 0;
81 }
82
83 6217 static void setupBBBMemoryMap() {
84
2/2
✓ Branch 0 taken 6091 times.
✓ Branch 1 taken 126 times.
6217 if (registersMemMapped) {
85 6091 return;
86 }
87
88 126 std::map<std::string, std::pair<int, int>> labelMapping;
89 // newer kernels will number the chips differently so we'll use the
90 // memory locations to figure out the mapping to the gpio0-3 that we use
91 126 int x = 0;
92 #ifdef IS_GPIOD_CXX_V2
93 // libgpiod v2: iterate through chips by path
94
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 126 times.
1386 for (int chipNum = 0; chipNum < 10; chipNum++) {
95
1/2
✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
1260 std::string chipPath = "/dev/gpiochip" + std::to_string(chipNum);
96
3/4
✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 680 times.
✓ Branch 3 taken 580 times.
1260 if (FileExists(chipPath)) {
97 try {
98
2/4
✓ Branch 0 taken 680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 680 times.
✗ Branch 3 not taken.
680 auto chip = gpiod::chip(chipPath);
99
1/2
✓ Branch 0 taken 680 times.
✗ Branch 1 not taken.
680 std::string lab = chip.get_info().label();
100
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 588 times.
680 if (lab.contains("tps65219-gpio")) {
101
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 labelMapping[lab] = { 0, chipNum };
102
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 496 times.
588 } else if (lab.contains("4201000.gpio")) {
103
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 labelMapping[lab] = { 1, chipNum };
104
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 404 times.
496 } else if (lab.contains("600000.gpio")) {
105
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 labelMapping[lab] = { 2, chipNum };
106
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 312 times.
404 } else if (lab.contains("601000.gpio")) {
107
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 labelMapping[lab] = { 3, chipNum };
108 }
109 680 } catch (...) {
110 // Chip doesn't exist, continue
111 ✗ break;
112 ✗ }
113 }
114
1/2
✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
1260 }
115 #else
116 for (auto&& chip : gpiod::make_chip_iter()) {
117 std::string lab = chip.label();
118 if (lab.contains("tps65219-gpio")) {
119 labelMapping[lab] = { 0, x };
120 } else if (lab.contains("4201000.gpio")) {
121 labelMapping[lab] = { 1, x };
122 } else if (lab.contains("600000.gpio")) {
123 labelMapping[lab] = { 2, x };
124 } else if (lab.contains("601000.gpio")) {
125 labelMapping[lab] = { 3, x };
126 }
127 x++;
128 }
129 #endif
130
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 const std::string dirName("/sys/class/gpio");
131
3/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 32 times.
126 if (DirectoryExists(dirName)) {
132
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 DIR* dir = opendir(dirName.c_str());
133 struct dirent* entry;
134
3/4
✓ Branch 0 taken 1598 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1504 times.
✓ Branch 3 taken 94 times.
1598 while ((entry = readdir(dir)) != NULL) {
135
1/2
✓ Branch 0 taken 1504 times.
✗ Branch 1 not taken.
3008 std::string fn = entry->d_name;
136
2/2
✓ Branch 0 taken 564 times.
✓ Branch 1 taken 940 times.
1504 if (fn.starts_with("gpiochip")) {
137
2/4
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 564 times.
✗ Branch 3 not taken.
564 std::string fn2 = dirName + "/" + fn;
138 char buf[PATH_MAX + 1];
139 564 realpath(fn2.c_str(), buf);
140
141
2/4
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 564 times.
✗ Branch 3 not taken.
564 std::string lab = GetFileContents(fn2 + "/label");
142
1/2
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
564 TrimWhiteSpace(lab);
143
1/2
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
564 std::string target = buf;
144
1/2
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
564 int start = std::atoi(fn.substr(8).c_str());
145 #ifdef PLATFORM_BB64
146
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 470 times.
564 if (lab.contains("tps65219-gpio")) {
147
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 labelMapping[lab] = { 0, start };
148
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 376 times.
470 } else if (lab.contains("4201000.gpio")) {
149
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 labelMapping[lab] = { 1, start };
150
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 282 times.
376 } else if (lab.contains("600000.gpio")) {
151
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 labelMapping[lab] = { 2, start };
152
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 188 times.
282 } else if (lab.contains("601000.gpio")) {
153
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 labelMapping[lab] = { 3, start };
154 }
155 #else
156 ✗ if (target.contains("44e07000.gpio")) {
157 ✗ labelMapping[lab] = { 0, start };
158 ✗ } else if (target.contains("4804c000.gpio")) {
159 ✗ labelMapping[lab] = { 1, start };
160 ✗ } else if (target.contains("481ac000.gpio")) {
161 ✗ labelMapping[lab] = { 2, start };
162 ✗ } else if (target.contains("481ae000.gpio")) {
163 ✗ labelMapping[lab] = { 3, start };
164 }
165 #endif
166 564 }
167 1504 }
168
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 closedir(dir);
169 }
170 #ifdef IS_GPIOD_CXX_V2
171 // libgpiod v2: iterate through chips by path
172 126 int curChip = 0;
173
3/4
✓ Branch 0 taken 622 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 498 times.
✓ Branch 3 taken 124 times.
622 for (int chipNum = 0; chipNum < 10 && curChip < 4; chipNum++) {
174
1/2
✓ Branch 0 taken 498 times.
✗ Branch 1 not taken.
498 std::string chipPath = "/dev/gpiochip" + std::to_string(chipNum);
175
3/4
✓ Branch 0 taken 498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 496 times.
498 if (!FileExists(chipPath)) {
176 2 break;
177 }
178 try {
179
2/4
✓ Branch 0 taken 496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 496 times.
✗ Branch 3 not taken.
496 auto chip = gpiod::chip(chipPath);
180
1/2
✓ Branch 0 taken 496 times.
✗ Branch 1 not taken.
496 std::string clabel = chip.get_info().label();
181
1/2
✓ Branch 0 taken 496 times.
✗ Branch 1 not taken.
496 TrimWhiteSpace(clabel);
182
3/4
✓ Branch 0 taken 496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 368 times.
✓ Branch 3 taken 128 times.
496 if (labelMapping.contains(clabel)) {
183
1/2
✓ Branch 0 taken 368 times.
✗ Branch 1 not taken.
368 bbGPIOMap[labelMapping[clabel].first] = curChip;
184 } else {
185 #ifdef PLATFORM_BBB
186 // if mapping by base fails, try using specific line labels
187
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 auto info = chip.get_line_info(0);
188 128 std::string name = info.name();
189
3/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 95 times.
128 if (name == "NC") {
190
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 info = chip.get_line_info(13);
191 33 name = info.name();
192 }
193
8/10
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 107 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✓ Branch 7 taken 96 times.
✓ Branch 8 taken 32 times.
✓ Branch 9 taken 96 times.
128 if (name == "[mdio_data]" || name == "P1.28 [I2C2_SCL]") {
194 32 bbGPIOMap[0] = curChip;
195
8/10
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 75 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✓ Branch 7 taken 64 times.
✓ Branch 8 taken 32 times.
✓ Branch 9 taken 64 times.
96 } else if (name == "P8_25 [mmc1_dat0]" || name == "P2.33") {
196 32 bbGPIOMap[1] = curChip;
197
10/14
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 43 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 43 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 43 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 11 times.
✓ Branch 11 taken 32 times.
✓ Branch 12 taken 32 times.
✓ Branch 13 taken 32 times.
64 } else if (name == "P9_15B" || name == "[SYSBOOT 7]" || name == "P2.20") {
198 32 bbGPIOMap[2] = curChip;
199
6/10
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 32 times.
✗ Branch 9 not taken.
32 } else if (name == "[mii col]" || name == "P1.03 [USB1]") {
200 32 bbGPIOMap[3] = curChip;
201 }
202 #endif
203 128 }
204 496 ++curChip;
205 496 } catch (...) {
206 // Chip doesn't exist, continue
207 ✗ break;
208 ✗ }
209
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 2 times.
498 }
210 #else
211 int curChip = 0;
212 for (auto& a : gpiod::make_chip_iter()) {
213 // std::string cname = a.name();
214 std::string clabel = a.label();
215 TrimWhiteSpace(clabel);
216 if (labelMapping.contains(clabel)) {
217 bbGPIOMap[labelMapping[clabel].first] = curChip;
218 } else {
219 #ifdef PLATFORM_BBB
220 // if mapping by base fails, try using specific line labels
221 auto line = a.get_line(0);
222 if (line.name() == "NC") {
223 line.release();
224 line = a.get_line(13);
225 }
226 std::string name = line.name();
227 if (name == "[mdio_data]" || name == "P1.28 [I2C2_SCL]") {
228 bbGPIOMap[0] = curChip;
229 } else if (name == "P8_25 [mmc1_dat0]" || name == "P2.33") {
230 bbGPIOMap[1] = curChip;
231 } else if (name == "P9_15B" || name == "[SYSBOOT 7]" || name == "P2.20") {
232 bbGPIOMap[2] = curChip;
233 } else if (name == "[mii col]" || name == "P1.03 [USB1]") {
234 bbGPIOMap[3] = curChip;
235 }
236 line.release();
237 #endif
238 }
239 ++curChip;
240 if (curChip == 4) {
241 break;
242 }
243 }
244 #endif
245 126 registersMemMapped = true;
246 126 }
247
248 // ------------------------------------------------------------------------
249
250 1933 BBBPinCapabilities::BBBPinCapabilities(const std::string& n, uint32_t k) :
251
2/4
✓ Branch 0 taken 1933 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1933 times.
✗ Branch 3 not taken.
3866 GPIODCapabilities(n, k) {
252
1/2
✓ Branch 0 taken 1933 times.
✗ Branch 1 not taken.
1933 setupBBBMemoryMap();
253 1933 gpioIdx = bbGPIOMap[k / 32];
254 1933 gpio = k % 32;
255 1933 _pruPin[0] = -1;
256 1933 _pruPin[1] = -1;
257 1933 }
258 4284 BBBPinCapabilities::BBBPinCapabilities(const std::string& n, uint32_t g, uint32_t o) :
259
2/4
✓ Branch 0 taken 4284 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4284 times.
✗ Branch 3 not taken.
8568 GPIODCapabilities(n, g) {
260
1/2
✓ Branch 0 taken 4284 times.
✗ Branch 1 not taken.
4284 setupBBBMemoryMap();
261 4284 gpioIdx = bbGPIOMap[g];
262 4284 gpio = o;
263 4284 _pruPin[0] = -1;
264 4284 _pruPin[1] = -1;
265 4284 }
266
267 #ifdef PLATFORM_BB64
268 109 int BBBPinCapabilities::mappedGPIOIdx() const {
269 109 int mp = 0;
270
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 109 times.
545 for (int x = 0; x < 4; x++) {
271
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 327 times.
436 if (bbGPIOMap[x] == gpioIdx) {
272 109 mp = x;
273 }
274 }
275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (mp == 1) {
276 // MCU Domain
277 ✗ return 0;
278 }
279
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 108 times.
109 if (mp == 3) {
280 // gpio1, all pins are in the first 32
281 1 return 3;
282 }
283 // gpio0, map 32-63 to 1 and 64-95 to 2
284
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if (gpio < 64) {
285 108 return 1;
286 }
287 ✗ return 2;
288 }
289 6 int BBBPinCapabilities::mappedGPIO() const {
290 6 int mp = 0;
291
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 for (int x = 0; x < 4; x++) {
292
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
24 if (bbGPIOMap[x] == gpioIdx) {
293 6 mp = x;
294 }
295 }
296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (mp == 1) {
297 // MCU Domain
298 ✗ return gpio;
299 }
300
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 if (mp == 3) {
301 // gpio1, all pins are in the first 32
302 1 return gpio;
303 }
304 // gpio0, map 32-63 to 1 and 64-95 to 2
305
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (gpio < 64) {
306 5 return gpio - 32;
307 }
308 ✗ return gpio - 64;
309 }
310 #else
311 531 int BBBPinCapabilities::mappedGPIOIdx() const {
312
1/2
✓ Branch 0 taken 1243 times.
✗ Branch 1 not taken.
1243 for (int x = 0; x < 4; x++) {
313
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 712 times.
1243 if (bbGPIOMap[x] == gpioIdx) {
314 531 return x;
315 }
316 }
317 ✗ return gpioIdx;
318 }
319 464 int BBBPinCapabilities::mappedGPIO() const {
320 464 return gpio;
321 }
322 #endif
323
324 108 Json::Value BBBPinCapabilities::toJSON() const {
325 108 Json::Value ret = PinCapabilities::toJSON();
326 #ifdef PLATFORM_BBB
327 ✗ if (gpioIdx < 4) {
328 // somewhat for compatibility with the old kernel GPIO numbers on the BBB's
329 ✗ int kgpio = mappedGPIOIdx() * 32 + gpio;
330 ✗ ret["gpio"] = kgpio;
331 }
332 #endif
333
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 50 times.
108 if (_pruPin[0] != -1) {
334
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 ret["pru"] = 0;
335
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 ret["pruPin"] = _pruPin[0];
336
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
58 ret["pru0Pin"] = _pruPin[0];
337 }
338
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 56 times.
108 if (_pruPin[1] != -1) {
339
2/4
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
52 ret["pru"] = 1;
340
2/4
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
52 ret["pruPin"] = _pruPin[1];
341
2/4
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
52 ret["pru1Pin"] = _pruPin[1];
342 }
343 108 return ret;
344 ✗ }
345
346 ✗ bool BBBPinCapabilities::supportPWM() const {
347 ✗ return pwm != -1;
348 }
349 459 void BBBPinCapabilities::releasePin() const {
350 459 GPIODCapabilities::releasePin();
351
5/10
✓ Branch 0 taken 459 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 459 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 459 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 459 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 459 times.
✗ Branch 9 not taken.
459 if (FileExists("/usr/bin/pinctrl") && name[0] == 'P' && (name[2] == '_' || name[2] == '-')) {
352 char pinName[16];
353 459 snprintf(pinName, sizeof(pinName), "%s", name.c_str());
354
1/2
✓ Branch 0 taken 459 times.
✗ Branch 1 not taken.
459 if (pinName[2] == '-') {
355 459 pinName[2] = '_';
356 }
357
358 char buf[256];
359 459 snprintf(buf, sizeof(buf), "/usr/bin/pinctrl -s %s reset", pinName);
360
1/2
✓ Branch 0 taken 459 times.
✗ Branch 1 not taken.
459 system(buf);
361 }
362 459 }
363
364 564 int BBBPinCapabilities::configPin(const std::string& m,
365 bool directionOut,
366 const std::string& desc) const {
367
1/2
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
564 std::string mode = m;
368 564 int rc = 0; // the gpio request's result; pinmux-only modes can't fail here
369
1/2
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
564 bool enableI2C = mode == "i2c";
370
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 564 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
564 if (i2cBus >= 0 && !enableI2C) {
371 ✗ enableOledScreen(i2cBus, false);
372 }
373
374 char pinName[16];
375 char dir_name[256];
376 564 snprintf(pinName, sizeof(pinName), "%s", name.c_str());
377
1/2
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
564 if (pinName[2] == '-') {
378 564 pinName[2] = '_';
379 }
380
381
2/4
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 564 times.
564 if (m == "gpio_od") {
382 // Open-drain GPIO for bit-banged I2C. Mux the pad ONCE as bidirectional
383 // GPIO with pull-up: gpio_pu keeps the receiver (RXACTIVE / INPUT_EN)
384 // enabled so a released open-drain line stays readable. The open-drain
385 // drive itself lives in the gpiod layer. Do NOT use gpio_out here (it
386 // disables the receiver and breaks ACK/reads) and do NOT re-mux per bit.
387 #ifdef PLATFORM_BBB
388 ✗ snprintf(dir_name, sizeof(dir_name),
389 "/sys/devices/platform/ocp/ocp:%s_pinmux/state", pinName);
390 ✗ FILE* sdir = fopen(dir_name, "w");
391 ✗ if (sdir) {
392 ✗ fprintf(sdir, "gpio_pu\n");
393 ✗ fclose(sdir);
394 }
395 #endif
396 ✗ if (FileExists("/usr/bin/pinctrl") && pinName[0] == 'P' && pinName[2] == '_') {
397 char buf[256];
398 ✗ snprintf(buf, sizeof(buf), "/usr/bin/pinctrl -s %s gpio_pu", pinName);
399 ✗ system(buf);
400 }
401 ✗ return GPIODCapabilities::configPin("gpio_od", false, desc);
402 }
403
404 #ifdef PLATFORM_BBB
405 // On the AM335x beagles, each pin is only attached to one PRU
406
7/10
✓ Branch 0 taken 266 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 264 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 264 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 264 times.
266 if (mode == "pru0out" || mode == "pru1out") {
407
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 mode = "pruout";
408 }
409
5/10
✓ Branch 0 taken 266 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 266 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 266 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 266 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 266 times.
266 if (mode == "pru0in" || mode == "pru1in") {
410 ✗ mode = "pruin";
411 }
412
413 266 snprintf(dir_name, sizeof(dir_name),
414 "/sys/devices/platform/ocp/ocp:%s_pinmux/state",
415 pinName);
416
1/2
✓ Branch 0 taken 266 times.
✗ Branch 1 not taken.
266 FILE* dir = fopen(dir_name, "w");
417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266 times.
266 if (dir) {
418 ✗ fprintf(dir, "%s\n", mode.c_str());
419 ✗ fclose(dir);
420 }
421 #endif
422
423
2/4
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 564 times.
✗ Branch 3 not taken.
564 if (mode == "i2c") {
424 // GPIODCapabilities::configPin("gpio", false, desc);
425
2/4
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 564 times.
✗ Branch 3 not taken.
564 } else if (mode == "pwm") {
426 // GPIODCapabilities::configPin("gpio", false, desc);
427
10/14
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 556 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 556 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 556 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 556 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 177 times.
✓ Branch 11 taken 379 times.
✓ Branch 12 taken 185 times.
✓ Branch 13 taken 379 times.
564 } else if (mode == "pruout" || mode == "pru0out" || mode == "pru1out") {
428
2/4
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 185 times.
✗ Branch 3 not taken.
555 GPIODCapabilities::configPin("gpio", false, desc);
429
9/14
✓ Branch 0 taken 379 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 379 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 379 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 363 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 363 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 363 times.
✓ Branch 12 taken 274 times.
✓ Branch 13 taken 105 times.
379 } else if (mode == "pruin" || mode == "pru0in" || mode == "pru1in") {
430 #ifdef PLATFORM_BB64
431
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
48 GPIODCapabilities::configPin("gpio", false, desc);
432 #endif
433
3/4
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✓ Branch 3 taken 104 times.
363 } else if (mode == "uart") {
434 #ifdef PLATFORM_BB64
435
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
3 GPIODCapabilities::configPin("gpio", false, desc);
436 #endif
437 } else {
438 // gpio
439
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 rc = GPIODCapabilities::configPin(m, directionOut, desc);
440 }
441
442
5/10
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 564 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 564 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 564 times.
✗ Branch 9 not taken.
564 if (FileExists("/usr/bin/pinctrl") && pinName[0] == 'P' && pinName[2] == '_') {
443 char buf[256];
444 // Use the normalized "mode", not the original "m": on am335x the pinctrl
445 // tool only knows "pruout"/"pruin" (each pin binds to a single PRU) and
446 // pru0out/pru1out were already collapsed to pruout above. On AM62x the
447 // tool takes pru0out/pru1out and "mode" is left un-normalized, so this is
448 // correct on both platforms. Passing the raw pru0out/pru1out here made
449 // pinctrl reject the mode ("Unknown mode") and left the pin as gpio.
450
1/2
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
564 std::string pm = mode;
451
2/4
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 564 times.
564 if (m == "default") {
452 ✗ pm = "gpio";
453 }
454
6/8
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362 times.
✓ Branch 3 taken 202 times.
✓ Branch 4 taken 362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 362 times.
✓ Branch 7 taken 202 times.
564 if (m == "gpio" && directionOut) {
455
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 pm = "gpio_out";
456 }
457 564 snprintf(buf, 256, "/usr/bin/pinctrl -s %s %s", pinName, pm.c_str());
458 // printf("%s\n", buf);
459
1/2
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
564 system(buf);
460 564 }
461
462
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 564 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
564 if (i2cBus >= 0 && enableI2C) {
463 ✗ enableOledScreen(i2cBus, true);
464 }
465 564 return rc;
466 564 }
467
468 ✗ bool BBBPinCapabilities::setupPWM(int maxValue) const {
469 ✗ if (pwm != -1 && (bbbPWMDutyFiles[pwm * 2 + subPwm] == nullptr)) {
470 // set pin
471 ✗ setupBBBMemoryMap();
472
473 ✗ configPin("pwm", true, "PWM");
474 ✗ int chipNum = getBBBPWMChipNum(pwm);
475 char dir_name[128];
476 ✗ snprintf(dir_name, sizeof(dir_name), "%s%d/export", bbbPWMDeviceName, chipNum);
477 ✗ FILE* dir = fopen(dir_name, "w");
478 ✗ if (!dir) {
479 ✗ return false;
480 }
481 ✗ fprintf(dir, "%d", subPwm);
482 ✗ fclose(dir);
483
484 ✗ snprintf(dir_name, sizeof(dir_name), "%s%d/pwm%d/period",
485 ✗ bbbPWMDeviceName, chipNum, subPwm);
486 ✗ dir = fopen(dir_name, "w");
487 ✗ if (!dir) {
488 ✗ return false;
489 }
490 ✗ fprintf(dir, "%d", maxValue);
491 ✗ fclose(dir);
492
493 ✗ snprintf(dir_name, sizeof(dir_name), "%s%d/pwm%d/duty_cycle",
494 ✗ bbbPWMDeviceName, chipNum, subPwm);
495 ✗ dir = fopen(dir_name, "w");
496 ✗ if (!dir) {
497 ✗ return false;
498 }
499 ✗ fprintf(dir, "0");
500 ✗ fflush(dir);
501 ✗ bbbPWMDutyFiles[pwm * 2 + subPwm] = dir;
502
503 ✗ snprintf(dir_name, sizeof(dir_name), "%s%d/pwm%d/enable",
504 ✗ bbbPWMDeviceName, chipNum, subPwm);
505 ✗ dir = fopen(dir_name, "w");
506 ✗ if (!dir) {
507 ✗ return false;
508 }
509 ✗ fprintf(dir, "1");
510 ✗ fclose(dir);
511 ✗ return true;
512 }
513 ✗ return false;
514 }
515
516 ✗ void BBBPinCapabilities::setPWMValue(int value) const {
517 ✗ if (pwm != -1 && bbbPWMDutyFiles[pwm * 2 + subPwm]) {
518 ✗ setupBBBMemoryMap();
519 ✗ fprintf(bbbPWMDutyFiles[pwm * 2 + subPwm], "%d", value);
520 ✗ fflush(bbbPWMDutyFiles[pwm * 2 + subPwm]);
521 }
522 ✗ }
523 // PWM locations
524 #define PWMSS0_BASE 0x48300000
525 #define PWMSS1_BASE 0x48302000
526 #define PWMSS2_BASE 0x48304000
527
528 ✗ int BBBPinCapabilities::getPWMRegisterAddress() const {
529 // need to add 0x200 to the base address to get the
530 // address to the eHRPWM register which is what we really use
531 ✗ if (pwm == 0) {
532 ✗ return PWMSS0_BASE + 0x200;
533 ✗ } else if (pwm == 1) {
534 ✗ return PWMSS1_BASE + 0x200;
535 ✗ } else if (pwm == 2) {
536 ✗ return PWMSS2_BASE + 0x200;
537 }
538 ✗ return 0;
539 }
540
541 class NullBBBPinCapabilities : public BBBPinCapabilities {
542 public:
543 126 NullBBBPinCapabilities() :
544
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
378 BBBPinCapabilities("-none-", 0, 0) {}
545 3 virtual const PinCapabilities* ptr() const override { return nullptr; }
546 };
547 static NullBBBPinCapabilities NULL_BBB_INSTANCE;
548
549 1203 const PinCapabilities& BBBPinProvider::getPinByName(const std::string& name) {
550
2/2
✓ Branch 0 taken 29556 times.
✓ Branch 1 taken 3 times.
29559 for (auto& a : BBB_PINS) {
551
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 28356 times.
29556 if (a.name == name) {
552 1200 return a;
553 }
554 }
555 3 return NULL_BBB_INSTANCE;
556 }
557
558 ✗ const PinCapabilities& BBBPinProvider::getPinByGPIO(int chip, int gpio) {
559 #ifdef PLATFORM_BBB
560 ✗ if (chip == 0) {
561 ✗ chip = gpio / 32;
562 ✗ gpio = gpio % 32;
563 }
564 #endif
565 ✗ for (auto& a : BBB_PINS) {
566 ✗ if (a.gpioIdx == chip && a.gpio == gpio) {
567 ✗ return a;
568 }
569 }
570 ✗ return NULL_BBB_INSTANCE;
571 }
572
573 109 void BBBPinProvider::Init() {
574
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if (BBB_PINS.empty()) {
575 #ifdef PLATFORM_BBB
576
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 21 times.
32 if (getBeagleBoneType() == PocketBeagle) {
577
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-02", 87).setPRU(1, 9);
578
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-04", 89).setPRU(1, 11);
579
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-06", 5).setI2C(1);
580
3/6
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
22 BBB_PINS.emplace_back("P1-08", 2).setPwm(0, 0).setUART("ttyS2-rx");
581
3/6
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
22 BBB_PINS.emplace_back("P1-10", 3).setPwm(0, 1).setUART("ttyS2-tx");
582
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-12", 4).setI2C(1);
583
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-20", 20);
584
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-26", 12).setI2C(2);
585
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-28", 13).setI2C(2);
586
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-29", 117).setPRU(0, 7);
587
3/6
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
22 BBB_PINS.emplace_back("P1-30", 43).setPRU(1, 15).setUART("ttyS0-tx");
588
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-31", 114).setPRU(0, 4);
589
3/6
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
22 BBB_PINS.emplace_back("P1-32", 42).setPRU(1, 14).setUART("ttyS0-rx");
590
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-33", 111).setPRU(0, 1).setPwm(0, 1);
591
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-34", 26);
592
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-35", 88).setPRU(1, 10);
593
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P1-36", 110).setPRU(0, 0).setPwm(0, 0);
594
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-01", 50).setPwm(1, 0);
595
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-02", 59);
596
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-03", 23).setPwm(2, 1);
597
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-04", 58);
598
3/6
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
22 BBB_PINS.emplace_back("P2-05", 30).setUART("ttyS4-rx");
599
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-06", 57);
600
3/6
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
22 BBB_PINS.emplace_back("P2-07", 31).setUART("ttyS4-tx");
601
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-08", 60);
602
3/6
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
22 BBB_PINS.emplace_back("P2-09", 15).setUART("ttyS1-tx");
603
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-10", 52);
604
3/6
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
22 BBB_PINS.emplace_back("P2-11", 14).setUART("ttyS1-rx");
605
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-17", 65);
606
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-18", 47);
607
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-19", 27);
608
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-20", 64);
609
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-22", 46);
610
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-24", 44).setPRU(0, 14);
611
3/6
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
22 BBB_PINS.emplace_back("P2-25", 41).setUART("ttyS4-tx");
612
3/6
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
22 BBB_PINS.emplace_back("P2-27", 40).setUART("ttyS4-rx");
613
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-28", 116).setPRU(0, 6);
614
3/6
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
22 BBB_PINS.emplace_back("P2-29", 7).setUART("ttyS3-tx");
615
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-30", 113).setPRU(0, 3);
616
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-31", 19);
617
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-32", 112).setPRU(0, 2);
618
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-33", 45).setPRU(0, 15);
619
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-34", 115).setPRU(0, 5);
620
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 BBB_PINS.emplace_back("P2-35", 86).setPRU(1, 8);
621 } else {
622
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-03", 38);
623
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-04", 39);
624
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-05", 34);
625
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-06", 35);
626
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-07", 66);
627
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-08", 67);
628
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-09", 69);
629
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-10", 68);
630
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-11", 45).setPRU(0, 15);
631
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-12", 44).setPRU(0, 14);
632
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-13", 23).setPwm(2, 1);
633
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-14", 26);
634
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-15", 47);
635
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-16", 46);
636
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-17", 27);
637
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-18", 65);
638
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-19", 22).setPwm(2, 0);
639
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-20", 63).setPRU(1, 13);
640
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-21", 62).setPRU(1, 12);
641
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-22", 37);
642
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-23", 36);
643
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-24", 33);
644
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-25", 32);
645
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-26", 61);
646
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-27", 86).setPRU(1, 8);
647
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-28", 88).setPRU(1, 10);
648
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-29", 87).setPRU(1, 9);
649
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-30", 89).setPRU(1, 11);
650
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-31", 10);
651
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-32", 11);
652
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-33", 9);
653
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-34", 81).setPwm(1, 1);
654
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-35", 8);
655
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-36", 80).setPwm(1, 0);
656
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
42 BBB_PINS.emplace_back("P8-37", 78).setUART("ttyS5-tx");
657
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
42 BBB_PINS.emplace_back("P8-38", 79).setUART("ttyS5-rx");
658
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-39", 76).setPRU(1, 6);
659
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-40", 77).setPRU(1, 7);
660
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-41", 74).setPRU(1, 4);
661
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-42", 75).setPRU(1, 5);
662
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-43", 72).setPRU(1, 2);
663
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-44", 73).setPRU(1, 3);
664
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-45", 70).setPRU(1, 0).setPwm(2, 0);
665
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P8-46", 71).setPRU(1, 1).setPwm(2, 1);
666
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
42 BBB_PINS.emplace_back("P9-11", 30).setUART("ttyS4-rx");
667
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-12", 60);
668
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
42 BBB_PINS.emplace_back("P9-13", 31).setUART("ttyS4-tx");
669
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-14", 50).setPwm(1, 0);
670
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-15", 48);
671
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-16", 51).setPwm(1, 1);
672
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-17", 5).setI2C(1);
673
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-18", 4).setI2C(1);
674
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-19", 13).setI2C(2);
675
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-20", 12).setI2C(2);
676
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
42 BBB_PINS.emplace_back("P9-21", 3).setPwm(0, 1).setUART("ttyS2-tx");
677
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
42 BBB_PINS.emplace_back("P9-22", 2).setPwm(0, 0).setUART("ttyS2-rx");
678
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-23", 49);
679
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
42 BBB_PINS.emplace_back("P9-24", 15).setUART("ttyS1-tx");
680
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-25", 117).setPRU(0, 7);
681
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
42 BBB_PINS.emplace_back("P9-26", 14).setUART("ttyS1-rx");
682
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-27", 115).setPRU(0, 5);
683
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-28", 113).setPRU(0, 3);
684
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-29", 111).setPRU(0, 1).setPwm(0, 1);
685
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-30", 112).setPRU(0, 2);
686
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-31", 110).setPRU(0, 0).setPwm(0, 0);
687
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-41", 20);
688
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-91", 116).setPRU(0, 6);
689
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
42 BBB_PINS.emplace_back("P9-42", 7).setUART("ttyS3-tx");
690
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 BBB_PINS.emplace_back("P9-92", 114).setPRU(0, 4);
691 }
692 #endif
693 #ifdef PLATFORM_BB64
694 77 BeagleBoneType tp = getBeagleBoneType();
695
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if (tp == PocketBeagle) {
696 // The ttyS numbers are the PocketBeagle 2 device tree's serial
697 // aliases, not TI's UART numbers: UART0 is ttyS7, UART2 is ttyS6
698 // and UART6 is ttyS2 (the console). ttyS0 is the wakeup UART that
699 // the firmware owns, and reaches no header pin.
700
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-02", 3, 10).setPRU(1, 0);
701
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-04", 3, 12).setPRU(1, 2);
702
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P1-06", 3, 13).setUART("ttyS1-rx");
703
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P1-08", 3, 14).setUART("ttyS1-tx");
704
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P1-10", 3, 7).setUART("ttyS2-rx");
705
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P1-12", 3, 8).setUART("ttyS2-tx");
706
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-13", 2, 36).setPRU(0, 13);
707
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-19", 3, 1).setPRU(0, 0);
708
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P1-20", 2, 50).setPRU(1, 5).setPRU(0, 13).setUART("ttyS4-tx");
709
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-21", 3, 6).setPRU(0, 16);
710
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-23", 3, 5).setPRU(0, 4);
711
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-25", 3, 4).setPRU(0, 3);
712
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P1-26", 2, 44).setUART("ttyS4-tx").setI2C(2);
713
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-27", 3, 3).setPRU(0, 2);
714
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P1-28", 2, 43).setPRU(0, 19).setUART("ttyS4-rx").setI2C(2);
715
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-29", 2, 62).setPRU(1, 17).setPRU(0, 7);
716
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P1-30", 3, 21).setUART("ttyS7-tx");
717
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-31", 2, 59).setPRU(1, 13).setPRU(0, 4);
718
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P1-32", 3, 20).setUART("ttyS7-rx");
719
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-33", 2, 56).setPRU(1, 10).setPRU(0, 1);
720
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-33b", 3, 29);
721
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-34", 3, 2).setPRU(0, 1);
722
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-35", 2, 88).setPRU(1, 1); ///?
723
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-36", 2, 55).setPRU(1, 9).setPRU(0, 0);
724
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P1-36b", 3, 28);
725
726
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-01", 3, 11);
727
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-02", 2, 45).setUART("ttyS6-rx").setPRU(1, 0).setPRU(0, 8);
728
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-03", 3, 9);
729
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-04", 2, 46).setUART("ttyS6-tx").setPRU(1, 1).setPRU(0, 9);
730
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-05", 3, 24).setUART("ttyS5-rx");
731
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-06", 2, 47).setUART("ttyS3-rx").setPRU(1, 2).setPRU(0, 10);
732
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-07", 3, 25).setUART("ttyS5-tx");
733
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-08", 2, 48).setUART("ttyS3-tx").setPRU(1, 3).setPRU(0, 11);
734
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-09", 3, 22).setUART("ttyS6-rx");
735
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-10", 2, 91).setPRU(1, 4); ///?
736
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-11", 3, 23).setUART("ttyS6-tx");
737
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-17", 2, 64).setPRU(1, 19).setPRU(0, 19); ///?
738
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-18", 2, 53).setUART("ttyS2-rx").setPRU(1, 16).setPRU(0, 17);
739
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-19", 3, 0).setPRU(1, 16);
740
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-20", 2, 49).setUART("ttyS4-rx").setPRU(1, 4).setPRU(0, 12);
741
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-22", 2, 63).setPRU(1, 18).setPRU(0, 18);
742
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-24", 2, 51).setUART("ttyS5-rx").setPRU(1, 6).setPRU(0, 14);
743
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-25", 3, 19);
744
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-27", 3, 18);
745
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-28", 2, 61).setPRU(1, 15).setPRU(0, 6);
746
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-29", 2, 40).setPRU(0, 16);
747
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-29b", 3, 17);
748
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-30", 2, 58).setPRU(1, 12).setPRU(0, 3);
749
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-31", 3, 15).setPRU(1, 3);
750
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-32", 2, 57).setPRU(1, 11).setPRU(0, 2);
751
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-33", 2, 52).setPRU(1, 7).setPRU(0, 15).setUART("ttyS5-tx");
752
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-34", 2, 60).setPRU(1, 14).setPRU(0, 5);
753
3/6
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
154 BBB_PINS.emplace_back("P2-35", 2, 54).setUART("ttyS2-tx").setPRU(1, 8).setPRU(0, 16);
754
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 BBB_PINS.emplace_back("P2-36", 3, 16);
755 } else {
756 ✗ printf("Unknown type: %d\n", getBeagleBoneType());
757 }
758 #endif
759 }
760 109 }
761
762 108 std::vector<std::string> BBBPinProvider::getPinNames() {
763 108 std::vector<std::string> ret;
764
2/2
✓ Branch 0 taken 6037 times.
✓ Branch 1 taken 108 times.
6145 for (auto& a : BBB_PINS) {
765
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 ret.push_back(a.name);
766 }
767 108 return ret;
768 ✗ }
769 2 const PinCapabilities& BBBPinProvider::getPinByUART(const std::string& n) {
770
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 for (auto& a : BBB_PINS) {
771
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 33 times.
35 if (a.uart == n) {
772 2 return a;
773 }
774 }
775 ✗ return NULL_BBB_INSTANCE;
776 }
777