2 * Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
3 * Author: Michael Ring <mail@michael-ring.org>
4 * Copyright (c) 2014 Intel Corporation.
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #include <mraa/common.h>
32 #include "arm/raspberry_pi.h"
34 #define PLATFORM_NAME_RASPBERRY_PI_B_REV_1 "Raspberry Pi Model B Rev 1"
35 #define PLATFORM_NAME_RASPBERRY_PI_A_REV_2 "Raspberry Pi Model A Rev 2"
36 #define PLATFORM_NAME_RASPBERRY_PI_B_REV_2 "Raspberry Pi Model B Rev 2"
37 #define PLATFORM_NAME_RASPBERRY_PI_B_PLUS_REV_1 "Raspberry Pi Model B+ Rev 1"
38 #define PLATFORM_NAME_RASPBERRY_PI_COMPUTE_MODULE_REV_1 "Raspberry Pi Compute Module Rev 1"
39 #define PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1 "Raspberry Pi Model A+ Rev 1"
40 #define PLATFORM_NAME_RASPBERRY_PI2_B_REV_1 "Raspberry Pi 2 Model B Rev 1"
41 #define PLATFORM_RASPBERRY_PI_B_REV_1 1
42 #define PLATFORM_RASPBERRY_PI_A_REV_2 2
43 #define PLATFORM_RASPBERRY_PI_B_REV_2 3
44 #define PLATFORM_RASPBERRY_PI_B_PLUS_REV_1 4
45 #define PLATFORM_RASPBERRY_PI_COMPUTE_MODULE_REV_1 5
46 #define PLATFORM_RASPBERRY_PI_A_PLUS_REV_1 6
47 #define PLATFORM_RASPBERRY_PI2_B_REV_1 7
48 #define MMAP_PATH "/dev/mem"
49 #define BCM2835_PERI_BASE 0x20000000
50 #define BCM2835_GPIO_BASE (BCM2835_PERI_BASE + 0x200000)
51 #define BCM2836_PERI_BASE 0x3f000000
52 #define BCM2836_GPIO_BASE (BCM2836_PERI_BASE + 0x200000)
53 #define BCM2835_BLOCK_SIZE (4 * 1024)
54 #define BCM2836_BLOCK_SIZE (4 * 1024)
55 #define BCM283X_GPSET0 0x001c
56 #define BCM283X_GPCLR0 0x0028
57 #define BCM2835_GPLEV0 0x0034
61 static uint8_t* mmap_reg = NULL;
62 static int mmap_fd = 0;
64 static unsigned int mmap_count = 0;
65 static int platform_detected = 0;
68 mraa_raspberry_pi_spi_init_pre(int index)
70 char devpath[MAX_SIZE];
71 sprintf(devpath, "/dev/spidev%u.0", plat->spi_bus[index].bus_id);
72 if (!mraa_file_exist(devpath)) {
73 syslog(LOG_ERR, "spi: Device not initialized");
74 syslog(LOG_ERR, "spi: If you run a kernel >=3.18 then you will have to add dtparam=spi=on "
75 "to /boot/config.txt and reboot");
76 syslog(LOG_INFO, "spi: trying modprobe for spi-bcm2708");
77 system("modprobe spi-bcm2708 >/dev/null 2>&1");
78 system("modprobe spi_bcm2708 >/dev/null 2>&1");
79 if (!mraa_file_exist(devpath)) {
80 return MRAA_ERROR_NO_RESOURCES;
87 mraa_raspberry_pi_i2c_init_pre(unsigned int bus)
89 char devpath[MAX_SIZE];
90 sprintf(devpath, "/dev/i2c-%u", bus);
91 if (!mraa_file_exist(devpath)) {
92 syslog(LOG_INFO, "spi: trying modprobe for i2c-bcm2708 & i2c-dev");
93 system("modprobe i2c-bcm2708 >/dev/null 2>&1");
94 system("modprobe i2c-dev >/dev/null 2>&1");
95 system("modprobe i2c_bcm2708 >/dev/null 2>&1");
96 system("modprobe i2c_dev >/dev/null 2>&1");
98 if (!mraa_file_exist(devpath)) {
99 syslog(LOG_ERR, "i2c: Device not initialized");
100 if (platform_detected == PLATFORM_RASPBERRY_PI_B_REV_1) {
101 syslog(LOG_ERR, "i2c: If you run a kernel >=3.18 then you will have to add "
102 "dtparam=i2c0=on to /boot/config.txt and reboot");
104 syslog(LOG_ERR, "i2c: If you run a kernel >=3.18 then you will have to add "
105 "dtparam=i2c1=on to /boot/config.txt and reboot");
107 return MRAA_ERROR_NO_RESOURCES;
113 mraa_raspberry_pi_mmap_write(mraa_gpio_context dev, int value)
115 volatile uint32_t* addr;
117 *(volatile uint32_t*) (mmap_reg + BCM283X_GPSET0 + (dev->pin / 32) * 4) =
118 (uint32_t)(1 << (dev->pin % 32));
120 *(volatile uint32_t*) (mmap_reg + BCM283X_GPCLR0 + (dev->pin / 32) * 4) =
121 (uint32_t)(1 << (dev->pin % 32));
127 mraa_raspberry_pi_mmap_unsetup()
129 if (mmap_reg == NULL) {
130 syslog(LOG_ERR, "raspberry mmap: null register cant unsetup");
131 return MRAA_ERROR_INVALID_RESOURCE;
133 munmap(mmap_reg, mmap_size);
135 if (close(mmap_fd) != 0) {
136 return MRAA_ERROR_INVALID_RESOURCE;
142 mraa_raspberry_pi_mmap_read(mraa_gpio_context dev)
144 uint32_t value = *(volatile uint32_t*) (mmap_reg + BCM2835_GPLEV0 + (dev->pin / 32) * 4);
145 if (value & (uint32_t)(1 << (dev->pin % 32))) {
152 mraa_raspberry_pi_mmap_setup(mraa_gpio_context dev, mraa_boolean_t en)
155 syslog(LOG_ERR, "raspberry mmap: context not valid");
156 return MRAA_ERROR_INVALID_HANDLE;
160 if (dev->mmap_write == NULL && dev->mmap_read == NULL) {
161 syslog(LOG_ERR, "raspberry mmap: can't disable disabled mmap gpio");
162 return MRAA_ERROR_INVALID_PARAMETER;
164 dev->mmap_write = NULL;
165 dev->mmap_read = NULL;
167 if (mmap_count == 0) {
168 return mraa_raspberry_pi_mmap_unsetup();
173 if (dev->mmap_write != NULL && dev->mmap_read != NULL) {
174 syslog(LOG_ERR, "raspberry mmap: can't enable enabled mmap gpio");
175 return MRAA_ERROR_INVALID_PARAMETER;
178 // Might need to make some elements of this thread safe.
179 // For example only allow one thread to enter the following block
180 // to prevent mmap'ing twice.
181 if (mmap_reg == NULL) {
182 if ((mmap_fd = open(MMAP_PATH, O_RDWR)) < 0) {
183 syslog(LOG_ERR, "raspberry map: unable to open resource0 file");
184 return MRAA_ERROR_INVALID_HANDLE;
187 if (platform_detected == PLATFORM_RASPBERRY_PI2_B_REV_1) {
188 mmap_reg = (uint8_t*) mmap(NULL, BCM2836_BLOCK_SIZE, PROT_READ | PROT_WRITE,
189 MAP_FILE | MAP_SHARED, mmap_fd, BCM2836_GPIO_BASE);
191 mmap_reg = (uint8_t*) mmap(NULL, BCM2835_BLOCK_SIZE, PROT_READ | PROT_WRITE,
192 MAP_FILE | MAP_SHARED, mmap_fd, BCM2835_GPIO_BASE);
194 if (mmap_reg == MAP_FAILED) {
195 syslog(LOG_ERR, "raspberry mmap: failed to mmap");
198 return MRAA_ERROR_NO_RESOURCES;
201 dev->mmap_write = &mraa_raspberry_pi_mmap_write;
202 dev->mmap_read = &mraa_raspberry_pi_mmap_read;
211 mraa_board_t* b = (mraa_board_t*) malloc(sizeof(mraa_board_t));
217 char* line = malloc(len);
219 FILE* fh = fopen("/proc/cpuinfo", "r");
221 while (getline(&line, &len, fh) != -1) {
222 if (strncmp(line, "Revision", 8) == 0) {
223 if (strstr(line, "0002") || strstr(line, "0003")) {
224 b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
225 platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
226 b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
227 } else if (strstr(line, "0004") || strstr(line, "0005") || strstr(line, "0006") ||
228 strstr(line, "000d") || strstr(line, "000e") || strstr(line, "000f")) {
229 b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_2;
230 platform_detected = PLATFORM_RASPBERRY_PI_B_REV_2;
231 b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
232 } else if (strstr(line, "0007") || strstr(line, "0008") || strstr(line, "0009")) {
233 b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_REV_2;
234 platform_detected = PLATFORM_RASPBERRY_PI_A_REV_2;
235 b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
236 } else if (strstr(line, "0010")) {
237 b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_PLUS_REV_1;
238 platform_detected = PLATFORM_RASPBERRY_PI_B_PLUS_REV_1;
239 b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
240 } else if (strstr(line, "0011")) {
241 b->platform_name = PLATFORM_NAME_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
242 platform_detected = PLATFORM_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
243 b->phy_pin_count = MRAA_RASPBERRY_PI_COMPUTE_MODULE_PINCOUNT;
244 } else if (strstr(line, "0012")) {
245 b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1;
246 platform_detected = PLATFORM_RASPBERRY_PI_A_PLUS_REV_1;
247 b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
248 } else if (strstr(line, "a01041")) {
249 b->platform_name = PLATFORM_NAME_RASPBERRY_PI2_B_REV_1;
250 platform_detected = PLATFORM_RASPBERRY_PI2_B_REV_1;
251 b->phy_pin_count = MRAA_RASPBERRY_PI2_B_REV_1_PINCOUNT;
253 b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
254 platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
255 b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
265 b->adc_supported = 0;
266 b->pwm_default_period = 500;
267 b->pwm_max_period = 2147483;
268 b->pwm_min_period = 1;
270 b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * b->phy_pin_count);
272 advance_func->spi_init_pre = &mraa_raspberry_pi_spi_init_pre;
273 advance_func->i2c_init_pre = &mraa_raspberry_pi_i2c_init_pre;
274 advance_func->gpio_mmap_setup = &mraa_raspberry_pi_mmap_setup;
276 strncpy(b->pins[0].name, "INVALID", 8);
277 b->pins[0].capabilites = (mraa_pincapabilities_t){ 0, 0, 0, 0, 0, 0, 0, 0 };
279 strncpy(b->pins[1].name, "3V3", 8);
280 b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
282 strncpy(b->pins[2].name, "5V", 8);
283 b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
285 strncpy(b->pins[3].name, "SDA0", 8);
286 b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
287 b->pins[3].gpio.pinmap = 2;
288 b->pins[3].gpio.mux_total = 0;
289 b->pins[3].i2c.pinmap = 0;
290 b->pins[3].i2c.mux_total = 0;
292 strncpy(b->pins[4].name, "5V", 8);
293 b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
295 strncpy(b->pins[5].name, "SCL0", 8);
296 b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 1, 0, 0 };
297 b->pins[5].gpio.pinmap = 3;
298 b->pins[5].gpio.mux_total = 0;
299 b->pins[5].i2c.pinmap = 0;
300 b->pins[5].i2c.mux_total = 0;
302 strncpy(b->pins[6].name, "GND", 8);
303 b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
305 strncpy(b->pins[7].name, "GPIO4", 8);
306 b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
307 b->pins[7].gpio.pinmap = 4;
308 b->pins[7].gpio.mux_total = 0;
310 strncpy(b->pins[8].name, "UART_TX", 8);
311 b->pins[8].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
312 b->pins[8].gpio.pinmap = 14;
313 b->pins[8].gpio.mux_total = 0;
314 b->pins[8].uart.parent_id = 0;
315 b->pins[8].uart.mux_total = 0;
317 strncpy(b->pins[9].name, "GND", 8);
318 b->pins[9].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
320 strncpy(b->pins[10].name, "UART_RX", 8);
321 b->pins[10].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 1 };
322 b->pins[10].gpio.pinmap = 15;
323 b->pins[10].gpio.mux_total = 0;
324 b->pins[10].uart.parent_id = 0;
325 b->pins[10].uart.mux_total = 0;
327 strncpy(b->pins[11].name, "GPIO17", 8);
328 b->pins[11].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
329 b->pins[11].gpio.pinmap = 17;
330 b->pins[11].gpio.mux_total = 0;
332 strncpy(b->pins[12].name, "GPIO18", 8);
333 b->pins[12].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
334 b->pins[12].gpio.pinmap = 18;
335 b->pins[12].gpio.mux_total = 0;
337 if (platform_detected == PLATFORM_RASPBERRY_PI_B_REV_1) {
338 strncpy(b->pins[13].name, "GPIO21", 8);
339 b->pins[13].gpio.pinmap = 21;
341 strncpy(b->pins[13].name, "GPIO27", 8);
342 b->pins[13].gpio.pinmap = 27;
344 b->pins[13].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
345 b->pins[13].gpio.mux_total = 0;
347 strncpy(b->pins[14].name, "GND", 8);
348 b->pins[14].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
350 strncpy(b->pins[15].name, "GPIO22", 8);
351 b->pins[15].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
352 b->pins[15].gpio.pinmap = 22;
353 b->pins[15].gpio.mux_total = 0;
355 strncpy(b->pins[16].name, "GPIO23", 8);
356 b->pins[16].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
357 b->pins[16].gpio.pinmap = 23;
358 b->pins[16].gpio.mux_total = 0;
360 strncpy(b->pins[17].name, "3V3", 8);
361 b->pins[17].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
363 strncpy(b->pins[18].name, "GPIO24", 8);
364 b->pins[18].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
365 b->pins[18].gpio.pinmap = 24;
366 b->pins[18].gpio.mux_total = 0;
368 strncpy(b->pins[19].name, "SPI_MOSI", 8);
369 b->pins[19].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
370 b->pins[19].gpio.pinmap = 10;
371 b->pins[19].gpio.mux_total = 0;
372 b->pins[19].spi.pinmap = 0;
373 b->pins[19].spi.mux_total = 0;
375 strncpy(b->pins[20].name, "GND", 8);
376 b->pins[20].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
378 strncpy(b->pins[21].name, "SPI_MISO", 8);
379 b->pins[21].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
380 b->pins[21].gpio.pinmap = 9;
381 b->pins[21].gpio.mux_total = 0;
382 b->pins[21].spi.pinmap = 0;
383 b->pins[21].spi.mux_total = 0;
385 strncpy(b->pins[22].name, "GPIO25", 8);
386 b->pins[22].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
387 b->pins[22].gpio.pinmap = 25;
388 b->pins[22].gpio.mux_total = 0;
390 strncpy(b->pins[23].name, "SPI_CLK", 8);
391 b->pins[23].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
392 b->pins[23].gpio.pinmap = 11;
393 b->pins[23].gpio.mux_total = 0;
394 b->pins[23].spi.pinmap = 0;
395 b->pins[23].spi.mux_total = 0;
397 strncpy(b->pins[24].name, "SPI_CS0", 8);
398 b->pins[24].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
399 b->pins[24].gpio.pinmap = 8;
400 b->pins[24].gpio.mux_total = 0;
401 b->pins[24].spi.pinmap = 0;
402 b->pins[24].spi.mux_total = 0;
404 strncpy(b->pins[25].name, "GND", 8);
405 b->pins[25].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
407 strncpy(b->pins[26].name, "SPI_CS1", 8);
408 b->pins[26].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 1, 0, 0, 0 };
409 b->pins[26].gpio.pinmap = 7;
410 b->pins[26].gpio.mux_total = 0;
411 b->pins[26].spi.pinmap = 0;
412 b->pins[26].spi.mux_total = 0;
414 if ((platform_detected == PLATFORM_RASPBERRY_PI_A_REV_2) ||
415 (platform_detected == PLATFORM_RASPBERRY_PI_B_REV_2)) {
416 strncpy(b->pins[27].name, "5V", 8);
417 b->pins[27].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
419 strncpy(b->pins[28].name, "3V3", 8);
420 b->pins[28].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
422 strncpy(b->pins[29].name, "GPIO8", 8);
423 b->pins[29].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
424 b->pins[29].gpio.pinmap = 8;
425 b->pins[29].gpio.mux_total = 0;
427 strncpy(b->pins[30].name, "GPIO9", 8);
428 b->pins[30].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
429 b->pins[30].gpio.pinmap = 9;
430 b->pins[30].gpio.mux_total = 0;
432 strncpy(b->pins[31].name, "GPIO10", 8);
433 b->pins[31].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
434 b->pins[31].gpio.pinmap = 10;
435 b->pins[31].gpio.mux_total = 0;
437 strncpy(b->pins[32].name, "GPIO11", 8);
438 b->pins[32].gpio.pinmap = 11;
439 b->pins[32].gpio.mux_total = 0;
440 b->pins[32].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
442 strncpy(b->pins[33].name, "GND", 8);
443 b->pins[33].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
445 strncpy(b->pins[34].name, "GND", 8);
446 b->pins[34].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
450 b->i2c_bus_count = 1;
452 if (platform_detected == PLATFORM_RASPBERRY_PI_B_REV_1)
453 b->i2c_bus[0].bus_id = 0;
455 b->i2c_bus[0].bus_id = 1;
456 b->i2c_bus[0].sda = 3;
457 b->i2c_bus[0].scl = 5;
459 b->spi_bus_count = 1;
461 b->spi_bus[0].bus_id = 0;
462 b->spi_bus[0].slave_s = 0;
463 b->spi_bus[0].cs = 24;
464 b->spi_bus[0].mosi = 19;
465 b->spi_bus[0].miso = 21;
466 b->spi_bus[0].sclk = 23;
468 b->uart_dev_count = 1;
470 b->uart_dev[0].rx = 10;
471 b->uart_dev[0].tx = 8;
473 if ((platform_detected == PLATFORM_RASPBERRY_PI_A_PLUS_REV_1) ||
474 (platform_detected == PLATFORM_RASPBERRY_PI_B_PLUS_REV_1) ||
475 (platform_detected == PLATFORM_RASPBERRY_PI2_B_REV_1)) {
477 strncpy(b->pins[27].name, "ID_SD", 8);
478 b->pins[27].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
480 strncpy(b->pins[28].name, "ID_SC", 8);
481 b->pins[28].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
483 strncpy(b->pins[29].name, "GPIO05", 8);
484 b->pins[29].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
485 b->pins[29].gpio.pinmap = 5;
486 b->pins[29].gpio.mux_total = 0;
488 strncpy(b->pins[30].name, "GND", 8);
489 b->pins[30].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
491 strncpy(b->pins[31].name, "GPIO06", 8);
492 b->pins[31].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
493 b->pins[31].gpio.pinmap = 6;
494 b->pins[31].gpio.mux_total = 0;
496 strncpy(b->pins[32].name, "GPIO12", 8);
497 b->pins[32].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
498 b->pins[32].gpio.pinmap = 12;
499 b->pins[32].gpio.mux_total = 0;
501 strncpy(b->pins[33].name, "GPIO13", 8);
502 b->pins[33].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
503 b->pins[33].gpio.pinmap = 13;
504 b->pins[33].gpio.mux_total = 0;
506 strncpy(b->pins[34].name, "GND", 8);
507 b->pins[34].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
509 strncpy(b->pins[35].name, "GPIO19", 8);
510 b->pins[35].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
511 b->pins[35].gpio.pinmap = 19;
512 b->pins[35].gpio.mux_total = 0;
514 strncpy(b->pins[36].name, "GPIO16", 8);
515 b->pins[36].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
516 b->pins[36].gpio.pinmap = 16;
517 b->pins[36].gpio.mux_total = 0;
519 strncpy(b->pins[37].name, "GPIO26", 8);
520 b->pins[37].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
521 b->pins[37].gpio.pinmap = 26;
522 b->pins[37].gpio.mux_total = 0;
524 strncpy(b->pins[38].name, "GPIO20", 8);
525 b->pins[38].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
526 b->pins[38].gpio.pinmap = 20;
527 b->pins[38].gpio.mux_total = 0;
529 strncpy(b->pins[39].name, "GND", 8);
530 b->pins[39].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 0, 0, 0 };
532 strncpy(b->pins[40].name, "GPIO21", 8);
533 b->pins[40].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
534 b->pins[40].gpio.pinmap = 21;
535 b->pins[40].gpio.mux_total = 0;
540 for (i = 0; i < b->phy_pin_count; i++) {
541 if (b->pins[i].capabilites.gpio) {