// splatisa.h: interface for the splatisa class.
//
//////////////////////////////////////////////////////////////////////

#include <conio.h>

				/* basic definitions */

#define   INP         _inpw
#define   OUTP	      _outpw

#define   VOID        void
#define   USIGN8      unsigned char
#define   USIGN16     unsigned int
#define   USIGN32     unsigned long
#define   bool        int
#define   true		  1
#define   false       0
	
				/* set up register structure */

typedef struct REG_LIST
{
  USIGN16        boardid;    /* board ID number */
  USIGN16        pmt_trs;    /* pmt integration threshold*/
  USIGN16        pmt_wnd;    /* pmt integration window */
  USIGN16        pmt_sat;    /* pmt stauration limit */
  USIGN16		 chn_trs;    /* channeltron integration threshold*/
  USIGN16        chn_wnd;    /* channeltron integration window */
  USIGN16        chn_enc;    /* channeltron --NOT USED-- */
  USIGN16        ltimeout;   /* wait time after laser fired */
  USIGN16		 t1_wait;    /* WAIT TIME AFTER PMT1 TRIGGERED AND START OF PMT 2 */
  USIGN16		 t2_wait;    /* TOTAL WAIT TIME FOR PMT 2 TO TRIGGER BEFORE RESET  */
  USIGN16        t3_wait;    /* WAIT TO TRIGGER LASER AFTER CHANNELTRON TRIGGERED  */
  USIGN16        mult_sum;   /* ---NOT USED--  ALWAYS SET TO 0X04 */
  USIGN16        errc;       /* ERROR CORRECTION FOR PMT1 TO PMT2 TO LASER */
  USIGN16        pmt_del;    /* WAIT TO TRIGGER LASER AFTER PMT TRIGGER */
  USIGN16        star;	     /*user registers */
  USIGN16        ptrvlt;     /*partical travel time from t1 to t2 AND CHANNELTRON COUNT*/
}  REG_LIST;

			  /* register mapping in I/O space */
#define  BRDID  	0x00
#define  PMTTRS  	0x02
#define  PMTWND  	0x04
#define  PMTSAT  	0x06
#define  CHNTRS  	0x08
#define  CHNWND  	0x0a
#define  CHNENC     0x0c
#define  LTIMEOUT	0x0e
#define  T1WAIT  	0x10
#define  T2WAIT  	0x12
#define  T3WAIT		0x14
#define  MULTSUM  	0x16
#define  ERRC	  	0x18
#define  PMTDEL	  	0x1a
#define  STAR		0x1c
#define  PTRVLT  	0x1e



	
   	  /*board id*/
unsigned short    bio;
REG_LIST   regs;	  /* create variable */
extern	void     splatisa();			       /*CONSTRUCTOR  */
extern	void     csplatisa();      /*DESTRUCTOR   */
extern	USIGN16  board_scan();     /*scan for board location in I/O space */
extern	void     reg_read();       /*read the boards registers and store in REG_LIST*/
extern	void     reg_default();    /* loads registers with default value */
extern	void     reset_board();
extern	void     single_trigger();
extern	void	 reg_bwrite();
extern	void save_data(FILE *FP);
extern	void     cont_trigger();
extern	USIGN16  board_status();
extern	bool     check_trigger();
extern	USIGN16  read_trvl();
extern	void     set_reg(USIGN16,USIGN16);