diff options
author | root <root@avtech.domain.avtechpulse.com> | 2000-01-01 00:30:55 +0900 |
---|---|---|
committer | root <root@avtech.domain.avtechpulse.com> | 2000-01-01 00:30:55 +0900 |
commit | 3636beafd37af537f864fb898b7375626236d0a4 (patch) | |
tree | 2816b5af784be22458eaf25b126f96ff96feeddd /bus.c | |
parent | 93a0b81a4e630821392cb0f469ef8f3fbed46a3b (diff) |
abstract the hardware identification checks
Diffstat (limited to 'bus.c')
-rw-r--r-- | bus.c | 33 |
1 files changed, 21 insertions, 12 deletions
@@ -356,18 +356,23 @@ void bus_init() globals.HWDetect.beaglebone = util_is_beaglebone(); globals.HWDetect.olimex = util_is_olimex(); + // TODO update once Olimex carrier board is ready + globals.HWDetect.has_i2c = globals.HWDetect.beaglebone || globals.HWDetect.olimex; + globals.HWDetect.has_gpmc = globals.HWDetect.beaglebone; + globals.HWDetect.has_gpio = globals.HWDetect.beaglebone; + printf("Beaglebone: %d. Olimex: %d.\n", globals.HWDetect.beaglebone, globals.HWDetect.olimex); - if (!globals.HWDetect.beaglebone && !globals.HWDetect.olimex) { - printf("No recognized hardware. Bus stuff disabled!\n"); - } else { + if (globals.HWDetect.has_gpmc) { gpmc_setup(); - extbus = (uint8_t*) util_mapmemoryblock(0x01000000, 0x100); + gpmc_printinfo(); + } else { + printf("No recognized hardware. gpmc bus stuff disabled!\n"); + } - //gpmc_printinfo(); - + if (globals.HWDetect.has_gpio) { int i; for (i = 0; i < SIZEOFARRAY(gpio_pins); i++) { // these pins all happen to default to the correct mode (7) @@ -386,13 +391,15 @@ void bus_init() g_usleep(10); bus_setpin(RST_GPIB, 1); g_usleep(10); + } else { + printf("No recognized hardware. gpio stuff disabled!\n"); } } int bus_getpin(int pin) { - if (globals.HWDetect.beaglebone) { + if (globals.HWDetect.has_gpio) { return gpio_readvalue(gpio_pins[pin]); } else { return 0; @@ -401,21 +408,21 @@ int bus_getpin(int pin) void bus_setpin(int pin, int value) { - if (globals.HWDetect.beaglebone) { + if (globals.HWDetect.has_gpio) { gpio_writevalue(gpio_pins[pin], value & 0x1); } } void bus_writebyte(uint8_t address, uint8_t data) { - if (globals.HWDetect.beaglebone) { + if (globals.HWDetect.has_gpmc) { *(extbus + address) = data; } } uint8_t bus_readbyte(uint8_t address) { - if (globals.HWDetect.beaglebone) { + if (globals.HWDetect.has_gpmc) { return *(extbus + address); } else { return 0; @@ -424,12 +431,14 @@ uint8_t bus_readbyte(uint8_t address) void bus_shutdown() { - if (globals.HWDetect.beaglebone) { + if (globals.HWDetect.has_gpmc) { util_unmapmemoryblock((void*) extbus, 0x100); + } + + if (globals.HWDetect.has_gpio) { int i; for (i = 0; i < SIZEOFARRAY(gpio_pins); i++) { gpio_unexport(gpio_pins[i]); - } } } |