1 /*
2  * @(#)$Id: proscope.h,v 2.0 2008/12/17 17:35:46 baccala Exp $
3  *
4  * Copyright (C) 1997 - 2000 Tim Witham <twitham@quiknet.com>
5  *
6  * (see the files README and COPYING for more details)
7  *
8  * This file defines ProbeScope serial bits and function prototypes.
9  *
10  */
11 
12 /* convenience/readability macro */
13 #define BIT_MASK(bitnum)	(1 << (bitnum))
14 
15 /* Radio Shack ProbeScope serial data protocol bit definitions */
16 
17 #define PS_WAIT		BIT_MASK(0) /* WAITING! for trigger? */
18 
19 #define PS_10V		BIT_MASK(2) /* voltage switch */
20 #define PS_100V		BIT_MASK(3)
21 #define PS_AC		BIT_MASK(4) /* coupling switch */
22 #define PS_DC		BIT_MASK(5)
23 
24 #define PS_SINGLE	BIT_MASK(0) /* trigger mode */
25 #define PS_MEXT		BIT_MASK(3) /* trigger type Plus/Minus Ext/Int */
26 #define PS_PEXT		BIT_MASK(4)
27 #define PS_MINT		BIT_MASK(5) /* (documentation was off-by-one here) */
28 #define PS_PINT		BIT_MASK(6)
29 
30 #define PS_TP5		BIT_MASK(2) /* Trigger Plus/Minus 0.n */
31 #define PS_TP3		BIT_MASK(3)
32 #define PS_TP1		BIT_MASK(4)
33 #define PS_TM1		BIT_MASK(5)
34 #define PS_TM3		BIT_MASK(6)
35 
36 #define PS_OVERFLOW	BIT_MASK(0)
37 #define PS_UNDERFLOW	BIT_MASK(1)
38 #define PS_MINUS	BIT_MASK(3)
39 
40 #ifdef PSDEBUG
41 #undef PSDEBUG
42 #define PSDEBUG(format, arg) printf(format, arg)
43 #else
44 #define PSDEBUG(format, arg) ;
45 #endif
46 
47 typedef struct ProbeScope {	/* The state of the ProbeScope */
48   short probed;
49   short found;
50   short wait;
51   short volts;
52   char *coupling;
53   unsigned char trigger;
54   short level;
55   short dvm;
56   unsigned char flags;
57 } ProbeScope;
58 extern ProbeScope ps;
59 
60 extern int init_serial_probescope(void);
61 extern int init_serial_bitscope(void);
62 extern void flush_serial(int fd);
63 extern void cleanup_serial(int fd);
64 extern int getonebyte(int fd);
65 
66 extern int idprobescope(int fd);
67