GCC Code Coverage Report


Directory: ./
File: util/BBBUtils.cpp
Date: 2026-12-01 12:27:28
Exec Total Coverage
Lines: 448 512 87.5%
Functions: 21 23 91.3%
Branches: 587 1102 53.3%

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