2 * Header file for NI general purpose counter support code (ni_tio.c)
4 * COMEDI - Linux Control and Measurement Device Interface
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #ifndef _COMEDI_NI_TIO_H
18 #define _COMEDI_NI_TIO_H
20 #include "../comedidev.h"
22 enum ni_gpct_register {
96 enum ni_gpct_variant {
97 ni_gpct_variant_e_series,
98 ni_gpct_variant_m_series,
103 struct ni_gpct_device *counter_dev;
104 unsigned int counter_index;
105 unsigned int chip_index;
106 u64 clock_period_ps; /* clock period in picoseconds */
107 struct mite_channel *mite_chan;
108 spinlock_t lock; /* protects 'mite_chan' */
111 struct ni_gpct_device {
112 struct comedi_device *dev;
113 void (*write)(struct ni_gpct *counter, unsigned int value,
114 enum ni_gpct_register);
115 unsigned int (*read)(struct ni_gpct *counter, enum ni_gpct_register);
116 enum ni_gpct_variant variant;
117 struct ni_gpct *counters;
118 unsigned int num_counters;
119 unsigned int regs[NITIO_NUM_REGS];
120 spinlock_t regs_lock; /* protects 'regs' */
123 struct ni_gpct_device *
124 ni_gpct_device_construct(struct comedi_device *dev,
125 void (*write)(struct ni_gpct *counter,
127 enum ni_gpct_register),
128 unsigned int (*read)(struct ni_gpct *counter,
129 enum ni_gpct_register),
130 enum ni_gpct_variant,
131 unsigned int num_counters);
132 void ni_gpct_device_destroy(struct ni_gpct_device *counter_dev);
133 void ni_tio_init_counter(struct ni_gpct *counter);
134 int ni_tio_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
135 struct comedi_insn *insn, unsigned int *data);
136 int ni_tio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
137 struct comedi_insn *insn, unsigned int *data);
138 int ni_tio_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
139 struct comedi_insn *insn, unsigned int *data);
140 int ni_tio_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
141 int ni_tio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
142 struct comedi_cmd *cmd);
143 int ni_tio_cancel(struct ni_gpct *counter);
144 void ni_tio_handle_interrupt(struct ni_gpct *counter,
145 struct comedi_subdevice *s);
146 void ni_tio_set_mite_channel(struct ni_gpct *counter,
147 struct mite_channel *mite_chan);
148 void ni_tio_acknowledge(struct ni_gpct *counter);
150 #endif /* _COMEDI_NI_TIO_H */