diff options
Diffstat (limited to 'bus.c')
-rw-r--r-- | bus.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -15,6 +15,7 @@ #include <unistd.h> #include <stdbool.h> #include <inttypes.h> +#include "globals.h" #include "bus.h" #define GPIO_SYSFSPATH "/sys/class/gpio" @@ -360,18 +361,17 @@ static unsigned gpio_pins[] = { GPIO0_X + 22, // i.e., GPIO0_22 static volatile uint8_t* extbus; -static bool isbb = false; void bus_init() { - isbb = util_isbeaglebone(); + globals.HWDetect.beaglebone = util_isbeaglebone(); - if (!isbb) { + if (!globals.HWDetect.beaglebone) { printf("This doesn't seem to be a beaglebone.. bus stuff disabled!\n"); } - if (isbb) { + if (globals.HWDetect.beaglebone) { gpmc_setup(); extbus = (uint8_t*) util_mapmemoryblock(0x01000000, 0x100); @@ -396,7 +396,7 @@ void bus_init() int bus_getpin(int pin) { - if (isbb) { + if (globals.HWDetect.beaglebone) { return gpio_readvalue(gpio_pins[pin]); } else { return 0; @@ -405,21 +405,21 @@ int bus_getpin(int pin) void bus_setpin(int pin, int value) { - if (isbb) { + if (globals.HWDetect.beaglebone) { gpio_writevalue(gpio_pins[pin], value & 0x1); } } void bus_writebyte(uint8_t address, uint8_t data) { - if (isbb) { + if (globals.HWDetect.beaglebone) { *(extbus + address) = data; } } uint8_t bus_readbyte(uint8_t address) { - if (isbb) { + if (globals.HWDetect.beaglebone) { return *(extbus + address); } else { return 0; @@ -428,7 +428,7 @@ uint8_t bus_readbyte(uint8_t address) void bus_shutdown() { - if (isbb) { + if (globals.HWDetect.beaglebone) { util_unmapmemoryblock((void*) extbus, 0x100); int i; for (i = 0; i < SIZEOFARRAY(gpio_pins); i++) { |