/******************************************************************************
 *
 * drvGpib.h,v 
 *
 ******************************************************************************/
/***********************************************************************
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory, and the Regents of the University of
* California, as Operator of Los Alamos National Laboratory, and
* Berliner Elektronenspeicherring-Gesellschaft m.b.H. (BESSY).
* gpibCore is distributed subject to a Software License Agreement
* found in file LICENSE that is included with this distribution.
***********************************************************************/
/*
 *Common part of interfaces to generic GPIB driver
 *
 * Current Author: Benjamin Franksen
 * Original Author: John Winans
 */
#ifndef DRVGPIB_H
#define DRVGPIB_H
#ifdef __cplusplus
extern "C" {
#endif	/* __cplusplus */

/* Devices can have adresses from 0 to 31. Thus max of 32 devices  */
/* A device can have both a primary and a secondary address*/
/* Primary address 31 is untalk/unlisten. Secondary address 31 not allowed */
#define IBAPERLINK    32	/* max number of gpib addresses per link */
#define IBNOSECONDARY -1	/* if secondary==-1 then primary only */
#define checkGpibAddr(a)  ( (a)>=0 && (a)<31 )
#define checkSecondary(a) (((a)==IBNOSECONDARY) || ( (a)>=0 && (a)<31) )

/* GPIB Addressed Commands*/
#define IBSDC "\x04"	/* Selective Device Clear */
#define IBGTL "\x01"	/* Go to local */

/* GPIB Universial Commands*/
#define IBDCL 0x14	/* Device Clear */
#define IBLLO 0x11	/* Local Lockout */
#define IBSPE 0x18	/* Serial Poll Enable */
#define IBSPD 0x19	/* Serial Poll Disable */

/* following described here because both                 */
/* drvGpibInterface.h and drvHwGpibInterface.h use them. */
typedef long (*srqHandlerFunc) (void *parm, int statusByte);
typedef struct ibLink ibLink;

/*definition of externs*/
typedef struct drvGpibEt drvGpibEt;
extern drvGpibEt drvGpib;
extern void drvGpibRegister();
extern long drvGpibLinkInit(ibLink * pibLink);
extern long drvGpibLinkStart(ibLink * pibLink);
extern void drvGpibSrqHappened(ibLink * pibLink);
extern int drvGpibResetLink(int link);
/* addr is 100*primary + secondary */
extern int drvGpibLogData(int link, int addr, int onOff);
/*val (0,1) => (no, yes) */
extern long drvGpibPoll(int link, int addr, int onOff);
/*drvGpibPollInhibit is deprecated*/
extern long drvGpibPollInhibit(int link, int addr);
/*Gpib Interact*/
extern int GI();
/* debug flags */
extern int ibDebug;         /* turns on debug messages from this driver */
extern int ibSrqDebug;      /* turns on ONLY srq related debug messages */
/* configuration flags (1 or 0) */
extern int ibSrqLock;       /* stop ALL srq checking & polling */
extern int ibTimeoutSquelch;/* if true suppress timeout messages */
/* configuration parameters */
extern int ibSrqTimeout;    /* # of seconds to wait for (solicited) SRQs */
extern int ibSrqRingSize;   /* max # of events stored in the SRQ event ring */
extern int ibSrqPollTimeout;/* # of msec to wait for poll response */
extern double ibSrqPollRate;/* # of seconds between srqStatus requests */

#ifdef __cplusplus
}
#endif	/* __cplusplus */
/*
 *
 * drvGpib.h,v
 * Revision 1.4  2003/04/10 15:17:03  mrk
 * open source license
 *
 * Revision 1.3  2003/03/14 16:46:54  mrk
 * Changes for March 2003 version
 *
 * Revision 1.2  2002/11/01 19:29:57  mrk
 * More changes for ioctl replacement
 *
 * Revision 1.1  2002/10/18 17:21:06  mrk
 * moved to here
 *
 * Revision 1.3  2001/10/24 15:49:37  mrk
 * changes for baseR3.14.0beta1
 *
 * Revision 1.2  2001/04/17 18:40:07  mrk
 * Changes to get ready for bitBus support which will be implemented with bitBus
 *
 * Revision 1.1.1.1  2001/02/15 14:52:51  mrk
 * Import sources
 *
 * Revision 1.2  2000/05/19 20:37:36  franksen
 * fixed debug messages; overhauled report functions; fixed bug in HiDEOSGpibInit;
 * adapted everything to upper/lower interface seperation
 *
 * Revision 1.1  2000/05/19 20:19:03  franksen
 * added drvGpib.h, drvHwGpibInterface.h to separate lower from upper interface
 *
 * Revision 1.2  2000/05/19 12:57:42  franksen
 * use errlogPrintf; fixed bug in drvGpibGetLink;
 * changed type of link/gpibAddr from short to int
 *
 * Revision 1.1.1.1  2000/03/21 18:06:35  franksen
 * unbundled gpib first version
 *
 *****************************************************************************/
#endif	/* DRVGPIB_H */
