summaryrefslogtreecommitdiff
path: root/gpib.c
diff options
context:
space:
mode:
Diffstat (limited to 'gpib.c')
-rw-r--r--gpib.c66
1 files changed, 16 insertions, 50 deletions
diff --git a/gpib.c b/gpib.c
index 3945447..46b1e14 100644
--- a/gpib.c
+++ b/gpib.c
@@ -261,7 +261,9 @@ void TNT_4882_Status(int status_register,unsigned int byte,int operation)
{
int set_srq;
- MR_4882_status[STB] = TNT_In(R_spsr); // Get STB
+ if (globals.HWDetect.gpib) {
+ MR_4882_status[STB] = TNT_In(R_spsr); // Get STB
+ }
switch (operation) {
case SET:
@@ -417,9 +419,8 @@ void GPIB_initialize(void)
Requested_Count=0;
// test to detect TNT chip
- if ((TNT_In(R_sts2) & 0xB0) == 0x90) {
- globals.HWDetect.gpib = 1;
- } else {
+ globals.HWDetect.gpib = 1;
+ if ((TNT_In(R_sts2) & 0xB0) != 0x90) {
globals.HWDetect.gpib = 0;
printf ("Error: TNT4882 chip not found\n");
return;
@@ -588,12 +589,20 @@ static unsigned long int TNT_DATA_COUNT()
static void TNT_Out(int reg, unsigned int byte)
{
+ if (!globals.HWDetect.gpib) {
+ return;
+ }
+
bus_writebyte ((uint8_t) (TNT_Port + reg), (uint8_t) byte);
}
static unsigned char TNT_In(int reg)
{
+ if (!globals.HWDetect.gpib) {
+ return (unsigned char) 0;
+ }
+
return (unsigned char) bus_readbyte ((uint8_t) (TNT_Port + reg));
}
@@ -645,7 +654,7 @@ int GPIB_check_for_device_clear_signal(void)
}
-int GPIB_and_VXI_device_clear(void)
+void GPIB_and_VXI_device_clear(void)
{
TNT_Out(R_auxmr,F_clrDEC);
GPIB_and_VXI_clear_MAV();
@@ -806,10 +815,6 @@ void GPIB_and_VXI_start_query_response(gpointer ignore_this, gchar *in_string)
void GPIB_finish_query_response()
{
- if (!globals.HWDetect.gpib) {
- return;
- }
-
if (globals.Registers.pending_output_message == NULL) {
return;
}
@@ -945,10 +950,6 @@ void GPIB_check_remote_status (int *is_remote, int *is_lockout)
void GPIB_go_to_local ()
{
- if (!globals.HWDetect.gpib) {
- return;
- }
-
TNT_Out(R_auxmr,0x05); // issue TNT rtl command
return;
}
@@ -956,10 +957,6 @@ void GPIB_go_to_local ()
void GPIB_clear_events ()
{
- if (!globals.HWDetect.gpib) {
- return;
- }
-
TNT_4882_Status(ESR,0xff,CLEAR); // Clear ESR register
TNT_4882_Status(STB,0x20,CLEAR); // Clear ESB bit in STB
return;
@@ -986,11 +983,8 @@ unsigned int GPIB_get_ESE ()
unsigned int GPIB_and_VXI_get_STB ()
{
- if (!globals.HWDetect.gpib) {
- return 0;
- }
-
- return (TNT_In(R_spsr)&0xbf) | (((TNT_In(R_spsr)&0xbf) & MR_4882_status[SRE])?0x40:0);
+// return (TNT_In(R_spsr)&0xbf) | (((TNT_In(R_spsr)&0xbf) & MR_4882_status[SRE])?0x40:0);
+ return (MR_4882_status[STB]&0xbf) | (((MR_4882_status[STB]&0xbf) & MR_4882_status[SRE])?0x40:0);
}
@@ -1008,70 +1002,42 @@ void GPIB_and_VXI_clear_MAV()
void GPIB_set_ESR (unsigned int byte,int operation)
{
- if (!globals.HWDetect.gpib) {
- return;
- }
-
TNT_4882_Status(ESR,byte,operation);
}
void GPIB_set_SRE (unsigned int byte,int operation)
{
- if (!globals.HWDetect.gpib) {
- return;
- }
-
TNT_4882_Status(SRE,byte,operation);
}
void GPIB_set_ESE (unsigned int byte,int operation)
{
- if (!globals.HWDetect.gpib) {
- return;
- }
-
TNT_4882_Status(ESE,byte,operation);
}
void GPIB_Set_Execution_Error ()
{
- if (!globals.HWDetect.gpib) {
- return;
- }
-
TNT_4882_Status(ESR,0x10,1);
}
void GPIB_Set_Command_Error ()
{
- if (!globals.HWDetect.gpib) {
- return;
- }
-
TNT_4882_Status(ESR,0x20,1);
}
void GPIB_Set_Query_Error ()
{
- if (!globals.HWDetect.gpib) {
- return;
- }
-
TNT_4882_Status(ESR,0x04,1);
}
void GPIB_Set_Device_Dependent_Error ()
{
- if (!globals.HWDetect.gpib) {
- return;
- }
-
TNT_4882_Status(ESR,0x08,1);
}