1141398Sphk/*-
2141398Sphk * Copyright (c) 2005 Poul-Henning Kamp <phk@FreeBSD.org>
3141398Sphk * All rights reserved.
4141398Sphk *
5141398Sphk * Redistribution and use in source and binary forms, with or without
6141398Sphk * modification, are permitted provided that the following conditions
7141398Sphk * are met:
8141398Sphk * 1. Redistributions of source code must retain the above copyright
9141398Sphk *    notice, this list of conditions and the following disclaimer.
10141398Sphk * 2. Redistributions in binary form must reproduce the above copyright
11141398Sphk *    notice, this list of conditions and the following disclaimer in the
12141398Sphk *    documentation and/or other materials provided with the distribution.
13141398Sphk *
14141398Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15141398Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16141398Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17141398Sphk * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18141398Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19141398Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20141398Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21141398Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22141398Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23141398Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24141398Sphk * SUCH DAMAGE.
25141398Sphk *
26141398Sphk * $FreeBSD$
27141398Sphk *
28141398Sphk */
29141398Sphk
30141398Sphk#ifndef _DEV_IEEE488_UGPIB_H_
31141398Sphk#define _DEV_IEEE488_UGPIB_H_
32141398Sphk
33141398Sphk/* ibfoo() return values */
34141398Sphk#define EDVR	0		/* System error				*/
35141398Sphk#define ECIC	1		/* Not Active Controller		*/
36141398Sphk#define ENOL	2		/* Nobody listening			*/
37141398Sphk#define EADR	3		/* Controller not addressed		*/
38141398Sphk#define EARG	4		/* Invalid argument			*/
39141398Sphk#define ESAC	5		/* Not System Controller		*/
40141398Sphk#define EABO	6		/* I/O Aborted/Time out			*/
41141398Sphk#define ENEB	7		/* No such controller			*/
42141398Sphk#define EOIP	10		/* Async I/O in progress		*/
43141398Sphk#define ECAP	11		/* No such capability			*/
44141398Sphk#define EFSO	12		/* File system error			*/
45141398Sphk#define EBUS	14		/* Command byte xfer error		*/
46141398Sphk#define ESTB	15		/* Serial poll status byte lost		*/
47141398Sphk#define ESRQ	16		/* SRQ line stuck			*/
48141398Sphk#define ETAB	20		/* Table problem			*/
49141398Sphk
50141398Sphk/* ibsta bits */
51141398Sphk#define ERR	(1<<15)		/* Error				*/
52141398Sphk#define TIMO	(1<<14)		/* Timeout				*/
53141398Sphk#define END	(1<<13)		/* EOI/EOS				*/
54141398Sphk#define SRQI	(1<<12)		/* SRQ					*/
55141398Sphk#define RQS	(1<<11)		/* Device requests service		*/
56141398Sphk#define SPOLL	(1<<10)		/* Serial Poll				*/
57141398Sphk#define EVENT	(1<<9)		/* Event occured			*/
58141398Sphk#define CMPL	(1<<8)		/* I/O complete				*/
59141398Sphk#define LOK	(1<<7)		/* Lockout				*/
60141398Sphk#define REM	(1<<6)		/* Remote				*/
61141398Sphk#define CIC	(1<<5)		/* CIC					*/
62141398Sphk#define ATN	(1<<4)		/* ATN					*/
63141398Sphk#define TACS	(1<<3)		/* Talker				*/
64141398Sphk#define LACS	(1<<2)		/* Listener				*/
65141398Sphk#define DTAS	(1<<1)		/* Device trigger status		*/
66141398Sphk#define DCAS	(1<<0)		/* Device clear state			*/
67141398Sphk
68141398Sphk/* Timeouts */
69141398Sphk#define TNONE	0
70141398Sphk#define T10us	1
71141398Sphk#define T30us	2
72141398Sphk#define T100us	3
73141398Sphk#define T300us	4
74141398Sphk#define T1ms	5
75141398Sphk#define T3ms	6
76141398Sphk#define T10ms	7
77141398Sphk#define T30ms	8
78141398Sphk#define T100ms	9
79141398Sphk#define T300ms	10
80141398Sphk#define T1s	11
81141398Sphk#define T3s	12
82141398Sphk#define T10s	13
83141398Sphk#define T30s	14
84141398Sphk#define T100s	15
85141398Sphk#define T300s	16
86141398Sphk#define T1000s	17
87141398Sphk
88141398Sphk/* EOS bits */
89141398Sphk#define REOS	(1 << 10)
90141398Sphk#define XEOS	(1 << 11)
91141398Sphk#define BIN	(1 << 12)
92141398Sphk
93141398Sphk/* Bus commands */
94141777Sphk#define GTL	0x01		/* Go To Local				*/
95141777Sphk#define SDC	0x04		/* Selected Device Clear		*/
96141777Sphk#define GET	0x08		/* Group Execute Trigger		*/
97141398Sphk#define LAD	0x20		/* Listen address			*/
98141398Sphk#define UNL	0x3F		/* Unlisten				*/
99141398Sphk#define TAD	0x40		/* Talk address				*/
100141398Sphk#define UNT	0x5F		/* Untalk				*/
101141398Sphk
102141398Sphk#ifndef _KERNEL
103141398Sphk
104141768Sphkextern int ibcnt, iberr, ibsta;
105141398Sphk
106141398Sphkint ibask(int handle, int option, int *retval);
107141398Sphkint ibbna(int handle, char *bdname);
108141398Sphkint ibcac(int handle, int v);
109141398Sphkint ibclr(int handle);
110141398Sphkint ibcmd(int handle, void *buffer, long cnt);
111141398Sphkint ibcmda(int handle, void *buffer, long cnt);
112141398Sphkint ibconfig(int handle, int option, int value);
113141398Sphkint ibdev(int boardID, int pad, int sad, int tmo, int eot, int eos);
114141398Sphkint ibdiag(int handle, void *buffer, long cnt);
115141398Sphkint ibdma(int handle, int v);
116141398Sphkint ibeos(int handle, int eos);
117141737Sphkint ibeot(int handle, int eot);
118141398Sphkint ibevent(int handle, short *event);
119141398Sphkint ibfind(char *bdname);
120141398Sphkint ibgts(int handle, int v);
121141398Sphkint ibist(int handle, int v);
122141398Sphkint iblines(int handle, short *lines);
123141398Sphkint ibllo(int handle);
124141398Sphkint ibln(int handle, int padval, int sadval, short *listenflag);
125141398Sphkint ibloc(int handle);
126141398Sphkint ibonl(int handle, int v);
127141777Sphkint ibpad(int handle, int pad);
128141398Sphkint ibpct(int handle);
129141398Sphkint ibpoke(int handle, int option, int value);
130141398Sphkint ibppc(int handle, int v);
131141398Sphkint ibrd(int handle, void *buffer, long cnt);
132141398Sphkint ibrda(int handle, void *buffer, long cnt);
133141398Sphkint ibrdf(int handle, char *flname);
134141398Sphkint ibrdkey(int handle, void *buffer, int cnt);
135141398Sphkint ibrpp(int handle, char *ppr);
136141398Sphkint ibrsc(int handle, int v);
137141398Sphkint ibrsp(int handle, char *spr);
138141398Sphkint ibrsv(int handle, int v);
139141777Sphkint ibsad(int handle, int sad);
140141398Sphkint ibsgnl(int handle, int v);
141141398Sphkint ibsic(int handle);
142141398Sphkint ibsre(int handle, int v);
143141398Sphkint ibsrq(void (*func)(void));
144141398Sphkint ibstop(int handle);
145141398Sphkint ibtmo(int handle, int tmo);
146141398Sphkint ibtrap(int  mask, int mode);
147141398Sphkint ibtrg(int handle);
148141398Sphkint ibwait(int handle, int mask);
149141591Sphkint ibwrt(int handle, const void *buffer, long cnt);
150141591Sphkint ibwrta(int handle, const void *buffer, long cnt);
151141591Sphkint ibwrtf(int handle, const char *flname);
152141591Sphkint ibwrtkey(int handle, const void *buffer, int cnt);
153141398Sphkint ibxtrc(int handle, void *buffer, long cnt);
154141398Sphk#endif /* _KERNEL */
155141398Sphk#endif /* _DEV_IEEE488_UGPIB_H_ */
156