Lines Matching +full:clear +full:- +full:bit
1 // SPDX-License-Identifier: GPL-2.0+
4 * Driver for DAQCard-700 DIO/AI
7 * COMEDI - Linux Control and Measurement Device Interface
13 * Description: National Instruments PCMCIA DAQCard-700
16 * Devices: [National Instruments] PCMCIA DAQ-Card-700 (ni_daq_700)
20 * The daqcard-700 appears in Comedi as a digital I/O subdevice (0) with
21 * 16 channels and a analog input subdevice (1) with 16 single-ended channels
24 * Digital: The channel 0 corresponds to the daqcard-700's output
25 * port, bit 0; channel 8 corresponds to the input port, bit 0.
27 * Digital direction configuration: channels 0-7 output, 8-15 input.
29 * Analog: The input range is 0 to 4095 with a default of -10 to +10 volts.
31 * 0 for -10 to 10V bipolar
32 * 1 for -5 to 5V bipolar
33 * 2 for -2.5 to 2.5V bipolar
47 #define DIO_W 0x04 /* WO 8bit */
48 #define DIO_R 0x05 /* RO 8bit */
49 #define CMD_R1 0x00 /* WO 8bit */
50 #define CMD_R2 0x07 /* RW 8bit */
51 #define CMD_R3 0x05 /* W0 8bit */
52 #define STA_R1 0x00 /* RO 8bit */
53 #define STA_R2 0x01 /* RO 8bit */
54 #define ADFIFO_R 0x02 /* RO 16bit */
55 #define ADCLEAR_R 0x01 /* WO 8bit */
56 #define CDA_R0 0x08 /* RW 8bit */
57 #define CDA_R1 0x09 /* RW 8bit */
58 #define CDA_R2 0x0A /* RW 8bit */
59 #define CMO_R 0x0B /* RO 8bit */
60 #define TIC_R 0x06 /* WO 8bit */
84 outb(s->state & 0xff, dev->iobase + DIO_W); in daq700_dio_insn_bits()
87 val = s->state & 0xff; in daq700_dio_insn_bits()
88 val |= inb(dev->iobase + DIO_R) << 8; in daq700_dio_insn_bits()
92 return insn->n; in daq700_dio_insn_bits()
107 s->io_bits = 0x00ff; in daq700_dio_insn_config()
109 return insn->n; in daq700_dio_insn_config()
119 status = inb(dev->iobase + STA_R2); in daq700_ai_eoc()
121 return -EOVERFLOW; in daq700_ai_eoc()
122 status = inb(dev->iobase + STA_R1); in daq700_ai_eoc()
124 return -ENODATA; in daq700_ai_eoc()
127 return -EBUSY; in daq700_ai_eoc()
137 unsigned int chan = CR_CHAN(insn->chanspec); in daq700_ai_rinsn()
138 unsigned int aref = CR_AREF(insn->chanspec); in daq700_ai_rinsn()
139 unsigned int range = CR_RANGE(insn->chanspec); in daq700_ai_rinsn()
148 outb(r3_bits | (range & 0x03), dev->iobase + CMD_R3); in daq700_ai_rinsn()
151 /* set mask scan bit high to disable scanning */ in daq700_ai_rinsn()
152 outb(chan | 0x80, dev->iobase + CMD_R1); in daq700_ai_rinsn()
157 for (n = 0; n < insn->n; n++) { in daq700_ai_rinsn()
159 outb(0x00, dev->iobase + CMD_R2); /* enable ADC conversions */ in daq700_ai_rinsn()
160 outb(0x30, dev->iobase + CMO_R); /* mode 0 out0 L, from H */ in daq700_ai_rinsn()
161 outb(0x00, dev->iobase + ADCLEAR_R); /* clear the ADC FIFO */ in daq700_ai_rinsn()
162 /* read 16bit junk from FIFO to clear */ in daq700_ai_rinsn()
163 inw(dev->iobase + ADFIFO_R); in daq700_ai_rinsn()
165 outb(0x32, dev->iobase + CMO_R); in daq700_ai_rinsn()
173 d = inw(dev->iobase + ADFIFO_R); in daq700_ai_rinsn()
175 /* Bipolar Offset Binary: 0 to 4095 for -10 to +10 */ in daq700_ai_rinsn()
187 * Multiple-channel scanning is disabled.
189 * The analog input range is set to +-10 V
190 * The analog input mode is single-ended.
197 unsigned long iobase = dev->iobase; in daq700_ai_config()
200 outb(0x00, iobase + CMD_R2); /* clear all bits */ in daq700_ai_config()
201 outb(0x00, iobase + CMD_R3); /* set +-10 range */ in daq700_ai_config()
203 outb(0x00, iobase + TIC_R); /* clear counter interrupt */ in daq700_ai_config()
204 outb(0x00, iobase + ADCLEAR_R); /* clear the ADC FIFO */ in daq700_ai_config()
205 inw(iobase + ADFIFO_R); /* read 16bit junk from FIFO to clear */ in daq700_ai_config()
215 link->config_flags |= CONF_AUTO_SET_IO; in daq700_auto_attach()
219 dev->iobase = link->resource[0]->start; in daq700_auto_attach()
225 /* DAQCard-700 dio */ in daq700_auto_attach()
226 s = &dev->subdevices[0]; in daq700_auto_attach()
227 s->type = COMEDI_SUBD_DIO; in daq700_auto_attach()
228 s->subdev_flags = SDF_READABLE | SDF_WRITABLE; in daq700_auto_attach()
229 s->n_chan = 16; in daq700_auto_attach()
230 s->range_table = &range_digital; in daq700_auto_attach()
231 s->maxdata = 1; in daq700_auto_attach()
232 s->insn_bits = daq700_dio_insn_bits; in daq700_auto_attach()
233 s->insn_config = daq700_dio_insn_config; in daq700_auto_attach()
234 s->io_bits = 0x00ff; in daq700_auto_attach()
236 /* DAQCard-700 ai */ in daq700_auto_attach()
237 s = &dev->subdevices[1]; in daq700_auto_attach()
238 s->type = COMEDI_SUBD_AI; in daq700_auto_attach()
239 s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF; in daq700_auto_attach()
240 s->n_chan = 16; in daq700_auto_attach()
241 s->maxdata = BIT(12) - 1; in daq700_auto_attach()
242 s->range_table = &range_daq700_ai; in daq700_auto_attach()
243 s->insn_read = daq700_ai_rinsn; in daq700_auto_attach()
278 "Comedi driver for National Instruments PCMCIA DAQCard-700 DIO/AI");