summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@avtech.domain.avtechpulse.com>1999-12-31 20:17:42 -0500
committerroot <root@avtech.domain.avtechpulse.com>1999-12-31 20:17:42 -0500
commit41e73b50f0addac28ee0e87fe10043dc6d45ba68 (patch)
tree03ef5764d63837452eedc07dc682d2d6ebfc3c63
parent2a637c5759191f2911cdf5548d05496600e0655a (diff)
make hardware-detect flags global
-rw-r--r--bus.c18
-rw-r--r--globals.h7
-rw-r--r--gpib.c40
-rw-r--r--menus.c5
4 files changed, 40 insertions, 30 deletions
diff --git a/bus.c b/bus.c
index 06a3efe..abb5b5c 100644
--- a/bus.c
+++ b/bus.c
@@ -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++) {
diff --git a/globals.h b/globals.h
index d55351c..353a6cf 100644
--- a/globals.h
+++ b/globals.h
@@ -776,6 +776,12 @@ typedef struct {
typedef struct {
+ int beaglebone;
+ int gpib;
+} HWDetectStruct;
+
+
+typedef struct {
ConstraintsStruct Constraints;
ChannelStruct ChannelState[max_channels];
FlashStruct Flash;
@@ -787,6 +793,7 @@ typedef struct {
TimeStruct Timers;
MenuStatusStruct MenuStatus;
RemoteStruct Remote;
+ HWDetectStruct HWDetect;
} GlobalStruct;
diff --git a/gpib.c b/gpib.c
index ccf72ee..c1c097b 100644
--- a/gpib.c
+++ b/gpib.c
@@ -242,8 +242,6 @@
/* TNT4882 GLOBAL VARIABLES -------------------------------------------------*/
-int is_gpib;
-
int INTERFACE_ERROR; /* Error Code */
int INTERFACE_STATUS; /* Interface Status */
unsigned char MR_4882_status[5]; /* 4882 status memory registers */
@@ -425,9 +423,9 @@ void GPIB_initialize(void)
// test to detect TNT chip
if ((TNT_In(R_sts2) & 0xB0) == 0x90) {
- is_gpib = 1;
+ globals.HWDetect.gpib = 1;
} else {
- is_gpib = 0;
+ globals.HWDetect.gpib = 0;
printf ("Error: TNT4882 chip not found\n");
return;
}
@@ -478,7 +476,7 @@ static void TNT_Adr_Mode()
void GPIB_change_address(int new_address)
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return;
}
@@ -636,7 +634,7 @@ int GPIB_check_for_device_clear_signal(void)
/* added by MJC - June 20/06 */
/* reset interface if a device clear is received */
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return FALSE;
}
@@ -654,7 +652,7 @@ int GPIB_check_for_messages(char *gpib_buf)
{
#define ib_empty (!(strlen(gpib_buf)))
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return FALSE;
}
@@ -686,7 +684,7 @@ int GPIB_check_for_messages(char *gpib_buf)
int GPIB_handle_new_input(char *gpib_buf)
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return FALSE;
}
@@ -774,7 +772,7 @@ static void TNT_Holdoff_off()
int GPIB_send_query_response(char *out_buffer)
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return OK;
}
@@ -901,7 +899,7 @@ int GPIB_send_query_response(char *out_buffer)
void GPIB_check_remote_status (int *is_remote, int *is_lockout)
{
*is_remote = *is_lockout = 0;
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return;
}
@@ -919,7 +917,7 @@ void GPIB_check_remote_status (int *is_remote, int *is_lockout)
unsigned char GPIB_response_already_pending ()
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return 0;
}
@@ -929,7 +927,7 @@ unsigned char GPIB_response_already_pending ()
void GPIB_go_to_local ()
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return;
}
@@ -940,7 +938,7 @@ void GPIB_go_to_local ()
void GPIB_clear_events ()
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return;
}
@@ -970,7 +968,7 @@ unsigned int GPIB_get_ESE ()
unsigned int GPIB_get_STB ()
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return 0;
}
@@ -980,7 +978,7 @@ unsigned int GPIB_get_STB ()
void GPIB_set_ESR (unsigned int byte,int operation)
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return;
}
@@ -990,7 +988,7 @@ void GPIB_set_ESR (unsigned int byte,int operation)
void GPIB_set_SRE (unsigned int byte,int operation)
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return;
}
@@ -1000,7 +998,7 @@ void GPIB_set_SRE (unsigned int byte,int operation)
void GPIB_set_ESE (unsigned int byte,int operation)
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return;
}
@@ -1010,7 +1008,7 @@ void GPIB_set_ESE (unsigned int byte,int operation)
void GPIB_Set_Execution_Error ()
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return;
}
@@ -1020,7 +1018,7 @@ void GPIB_Set_Execution_Error ()
void GPIB_Set_Command_Error ()
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return;
}
@@ -1030,7 +1028,7 @@ void GPIB_Set_Command_Error ()
void GPIB_Set_Query_Error ()
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return;
}
@@ -1040,7 +1038,7 @@ void GPIB_Set_Query_Error ()
void GPIB_Set_Device_Dependent_Error ()
{
- if (!is_gpib) {
+ if (!globals.HWDetect.gpib) {
return;
}
diff --git a/menus.c b/menus.c
index 8231707..7abc8a5 100644
--- a/menus.c
+++ b/menus.c
@@ -2820,6 +2820,11 @@ void Menu_Check_Buttons(void)
int lower_encoder_val;
int encoder_change;
+ // abort if not running on the target board with the I2C bus
+ if (!globals.HWDetect.beaglebone) {
+ return;
+ }
+
/* get keypad state */
Read_Keypad(&button_port_val,&upper_encoder_val,&lower_encoder_val);