3 comedi/drivers/aio_iiro_16.c
5 Driver for Access I/O Products PC-104 AIO-IIRO-16 Digital I/O board
6 Copyright (C) 2006 C&C Technologies, Inc.
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.
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.
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.
26 Description: Access I/O Products PC-104 IIRO16 Relay And Isolated Input Board
27 Author: Zachary Ware <zach.ware@cctechnol.com>
29 [Access I/O] PC-104 AIO12-8
32 Configuration Options:
33 [0] - I/O port base address
37 #include "../comedidev.h"
38 #include <linux/ioport.h>
40 #define AIO_IIRO_16_SIZE 0x08
41 #define AIO_IIRO_16_RELAY_0_7 0x00
42 #define AIO_IIRO_16_INPUT_0_7 0x01
43 #define AIO_IIRO_16_IRQ 0x02
44 #define AIO_IIRO_16_RELAY_8_15 0x04
45 #define AIO_IIRO_16_INPUT_8_15 0x05
47 static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
48 struct comedi_subdevice *s,
49 struct comedi_insn *insn,
54 s->state |= data[0] & data[1];
55 outb(s->state & 0xff, dev->iobase + AIO_IIRO_16_RELAY_0_7);
56 outb((s->state >> 8) & 0xff,
57 dev->iobase + AIO_IIRO_16_RELAY_8_15);
65 static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev,
66 struct comedi_subdevice *s,
67 struct comedi_insn *insn,
71 data[1] |= inb(dev->iobase + AIO_IIRO_16_INPUT_0_7);
72 data[1] |= inb(dev->iobase + AIO_IIRO_16_INPUT_8_15) << 8;
77 static int aio_iiro_16_attach(struct comedi_device *dev,
78 struct comedi_devconfig *it)
80 struct comedi_subdevice *s;
83 ret = comedi_request_region(dev, it->options[0], AIO_IIRO_16_SIZE);
87 ret = comedi_alloc_subdevices(dev, 2);
91 s = &dev->subdevices[0];
92 s->type = COMEDI_SUBD_DIO;
93 s->subdev_flags = SDF_WRITABLE;
96 s->range_table = &range_digital;
97 s->insn_bits = aio_iiro_16_dio_insn_bits_write;
99 s = &dev->subdevices[1];
100 s->type = COMEDI_SUBD_DIO;
101 s->subdev_flags = SDF_READABLE;
104 s->range_table = &range_digital;
105 s->insn_bits = aio_iiro_16_dio_insn_bits_read;
110 static struct comedi_driver aio_iiro_16_driver = {
111 .driver_name = "aio_iiro_16",
112 .module = THIS_MODULE,
113 .attach = aio_iiro_16_attach,
114 .detach = comedi_legacy_detach,
116 module_comedi_driver(aio_iiro_16_driver);
118 MODULE_AUTHOR("Comedi http://www.comedi.org");
119 MODULE_DESCRIPTION("Comedi low-level driver");
120 MODULE_LICENSE("GPL");