Skip to content

Commit f194320

Browse files
authored
Merge pull request #183 from adafruit/fix-issue-178
Fix GPIO regression from BeagleBone Blue support
2 parents 41359aa + d75e0c8 commit f194320

File tree

8 files changed

+267
-141
lines changed

8 files changed

+267
-141
lines changed

source/c_pinmux.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ BBIO_err set_pin_mode(const char *key, const char *mode)
3636
if (NULL == f) {
3737
return BBIO_ACCESS;
3838
}
39-
syslog(LOG_DEBUG, "set_pin_mode() :: Pinmux file %s access OK", path);
39+
syslog(LOG_DEBUG, "Adafruit_BBIO: set_pin_mode() :: Pinmux file %s access OK", path);
4040
fprintf(f, "%s", mode);
4141
fclose(f);
42-
syslog(LOG_DEBUG, "set_pin_mode() :: Set pinmux mode to %s for %s", mode, pin);
42+
syslog(LOG_DEBUG, "Adafruit_BBIO: set_pin_mode() :: Set pinmux mode to %s for %s", mode, pin);
4343
return BBIO_OK;
4444
}

source/c_pwm.c

Lines changed: 48 additions & 48 deletions
Large diffs are not rendered by default.

source/common.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,6 @@ int get_spi_bus_path_number(unsigned int spi)
538538

539539
/*
540540
Refer to: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
541-
542541
Robert C. Nelson maintains the BeagleBoard.org Debian images and
543542
suggested adding this check to see if u-boot overlays are enabled.
544543
@@ -554,6 +553,7 @@ int uboot_overlay_enabled(void) {
554553
file = popen(cmd, "r");
555554
if (file == NULL) {
556555
fprintf(stderr, "error: uboot_overlay_enabled() failed to run cmd=%s\n", cmd);
556+
syslog(LOG_ERR, "Adafruit_BBIO: error: uboot_overlay_enabled() failed to run cmd=%s\n", cmd);
557557
return -1;
558558
}
559559
uboot_overlay = fgetc(file);
@@ -577,6 +577,7 @@ int pocketbeagle(void) {
577577
file = popen(cmd, "r");
578578
if (file == NULL) {
579579
fprintf(stderr, "error: pocketbeagle() failed to run cmd=%s\n", cmd);
580+
syslog(LOG_ERR, "Adafruit_BBIO: error: pocketbeagle() failed to run cmd=%s\n", cmd);
580581
return -1;
581582
}
582583
pocketbeagle = fgetc(file);
@@ -589,6 +590,35 @@ int pocketbeagle(void) {
589590
}
590591
}
591592

593+
594+
/*
595+
Check if board is a BeagleBone Blue
596+
597+
Refer to GitHub issue for more information:
598+
https://github.com/adafruit/adafruit-beaglebone-io-python/issues/178
599+
*/
600+
int beaglebone_blue(void) {
601+
const char *cmd = "/bin/grep -c 'TI AM335x BeagleBone Blue' /proc/device-tree/model";
602+
char blue;
603+
FILE *file = NULL;
604+
605+
file = popen(cmd, "r");
606+
if (file == NULL) {
607+
fprintf(stderr, "error: beaglebone_blue() failed to run cmd=%s\n", cmd);
608+
syslog(LOG_ERR, "Adafruit_BBIO: error: beaglebone_blue() failed to run cmd=%s\n", cmd);
609+
return -1;
610+
}
611+
blue = fgetc(file);
612+
pclose(file);
613+
614+
if(blue == '1') {
615+
return 1;
616+
} else {
617+
return 0;
618+
}
619+
}
620+
621+
592622
BBIO_err load_device_tree(const char *name)
593623
{
594624
char line[256];
@@ -745,7 +775,7 @@ void initlog(int level, const char* ident, int option)
745775
option = BBIO_LOG_OPTION;
746776
}
747777
openlog(ident, option, LOG_LOCAL1);
748-
syslog(LOG_NOTICE, "libadafruit-bbio version %s initialized", "<unknown>");
778+
syslog(LOG_NOTICE, "Adafruit_BBIO: version %s initialized", "<unknown>");
749779

750780
initialized = 1;
751781
}

source/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ BBIO_err load_device_tree(const char *name);
8080
BBIO_err unload_device_tree(const char *name);
8181
int device_tree_loaded(const char *name);
8282
BBIO_err get_pwm_by_key(const char *key, pwm_t **pwm);
83+
int uboot_overlay_enabled(void);
84+
int beaglebone_blue(void);
85+
int pocketbeagle(void);
8386

8487
#define BBIO_LOG_OPTION LOG_CONS | LOG_PID | LOG_NDELAY
8588
void initlog(int level, const char* ident, int option);

0 commit comments

Comments
 (0)