3 implements comedi_data_*() functions
5 COMEDI - Linux Control and Measurement Device Interface
6 Copyright (C) 2000 David A. Schleef <ds@schleef.org>
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.
24 #include "../comedi.h"
25 #include "../comedilib.h"
26 #include "../comedidev.h"
28 #include <linux/string.h>
29 #include <linux/delay.h>
31 int comedi_data_write(void *dev
, unsigned int subdev
, unsigned int chan
,
32 unsigned int range
, unsigned int aref
, unsigned int data
)
34 struct comedi_insn insn
;
36 memset(&insn
, 0, sizeof(insn
));
37 insn
.insn
= INSN_WRITE
;
41 insn
.chanspec
= CR_PACK(chan
, range
, aref
);
43 return comedi_do_insn(dev
, &insn
);
46 int comedi_data_read(void *dev
, unsigned int subdev
, unsigned int chan
,
47 unsigned int range
, unsigned int aref
, unsigned int *data
)
49 struct comedi_insn insn
;
51 memset(&insn
, 0, sizeof(insn
));
52 insn
.insn
= INSN_READ
;
56 insn
.chanspec
= CR_PACK(chan
, range
, aref
);
58 return comedi_do_insn(dev
, &insn
);
61 int comedi_data_read_hint(void *dev
, unsigned int subdev
,
62 unsigned int chan
, unsigned int range
,
65 struct comedi_insn insn
;
66 unsigned int dummy_data
;
68 memset(&insn
, 0, sizeof(insn
));
69 insn
.insn
= INSN_READ
;
71 insn
.data
= &dummy_data
;
73 insn
.chanspec
= CR_PACK(chan
, range
, aref
);
75 return comedi_do_insn(dev
, &insn
);
78 int comedi_data_read_delayed(void *dev
, unsigned int subdev
,
79 unsigned int chan
, unsigned int range
,
80 unsigned int aref
, unsigned int *data
,
81 unsigned int nano_sec
)
85 retval
= comedi_data_read_hint(dev
, subdev
, chan
, range
, aref
);
89 udelay((nano_sec
+ 999) / 1000);
91 return comedi_data_read(dev
, subdev
, chan
, range
, aref
, data
);