• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     ni_labpc.h
3 
4     Header for ni_labpc.c and ni_labpc_cs.c
5 
6     Copyright (C) 2003 Frank Mori Hess <fmhess@users.sourceforge.net>
7 
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12 
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License
19     along with this program; if not, write to the Free Software
20     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 
22 */
23 
24 #ifndef _NI_LABPC_H
25 #define _NI_LABPC_H
26 
27 #define EEPROM_SIZE	256	/*  256 byte eeprom */
28 #define NUM_AO_CHAN	2	/*  boards have two analog output channels */
29 
30 enum labpc_register_layout { labpc_plus_layout, labpc_1200_layout };
31 enum transfer_type { fifo_not_empty_transfer, fifo_half_full_transfer,
32 	isa_dma_transfer
33 };
34 
35 struct labpc_boardinfo {
36 	const char *name;
37 	int device_id;		/*  device id for pci and pcmcia boards */
38 	int ai_speed;		/*  maximum input speed in nanoseconds */
39 
40 	/*  1200 has extra registers compared to pc+ */
41 	enum labpc_register_layout register_layout;
42 	int has_ao;		/*  has analog output true/false */
43 	const struct comedi_lrange *ai_range_table;
44 	const int *ai_range_code;
45 
46 	/*  board can auto scan up in ai channels, not just down */
47 	unsigned ai_scan_up:1;
48 
49 	/* uses memory mapped io instead of ioports */
50 	unsigned has_mmio:1;
51 };
52 
53 struct labpc_private {
54 	struct mite_struct *mite;	/*  for mite chip on pci-1200 */
55 	/*  number of data points left to be taken */
56 	unsigned long long count;
57 	/*  software copy of analog output values */
58 	unsigned int ao_value[NUM_AO_CHAN];
59 	/*  software copys of bits written to command registers */
60 	unsigned int cmd1;
61 	unsigned int cmd2;
62 	unsigned int cmd3;
63 	unsigned int cmd4;
64 	unsigned int cmd5;
65 	unsigned int cmd6;
66 	/*  store last read of board status registers */
67 	unsigned int stat1;
68 	unsigned int stat2;
69 	/*
70 	 * value to load into board's counter a0 (conversion pacing) for timed
71 	 * conversions
72 	 */
73 	unsigned int divisor_a0;
74 	/*
75 	 * value to load into board's counter b0 (master) for timed conversions
76 	 */
77 	unsigned int divisor_b0;
78 	/*
79 	 * value to load into board's counter b1 (scan pacing) for timed
80 	 * conversions
81 	 */
82 	unsigned int divisor_b1;
83 	unsigned int dma_chan;	/*  dma channel to use */
84 	u16 *dma_buffer;	/*  buffer ai will dma into */
85 	phys_addr_t dma_addr;
86 	/* transfer size in bytes for current transfer */
87 	unsigned int dma_transfer_size;
88 	/* we are using dma/fifo-half-full/etc. */
89 	enum transfer_type current_transfer;
90 	/* stores contents of board's eeprom */
91 	unsigned int eeprom_data[EEPROM_SIZE];
92 	/* stores settings of calibration dacs */
93 	unsigned int caldac[16];
94 	/*
95 	 * function pointers so we can use inb/outb or readb/writeb as
96 	 * appropriate
97 	 */
98 	unsigned int (*read_byte) (unsigned long address);
99 	void (*write_byte) (unsigned int byte, unsigned long address);
100 };
101 
102 int labpc_common_attach(struct comedi_device *dev,
103 			unsigned int irq, unsigned long isr_flags);
104 void labpc_common_detach(struct comedi_device *dev);
105 
106 extern const int labpc_1200_ai_gain_bits[];
107 extern const struct comedi_lrange range_labpc_1200_ai;
108 
109 #endif /* _NI_LABPC_H */
110