From 4a9dd8e9d33620b986ad484d6a9c508eabb6a2af Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Mon, 29 Apr 2002 18:22:41 +0000 Subject: [PATCH] added comedi_data_read_delayed() --- include/comedilib.h | 2 ++ lib/data.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/comedilib.h b/include/comedilib.h index ed31b79..c76a87b 100644 --- a/include/comedilib.h +++ b/include/comedilib.h @@ -118,6 +118,8 @@ lsampl_t comedi_from_phys(double data,comedi_range *rng,lsampl_t maxdata); /* syncronous stuff */ int comedi_data_read(comedi_t *it,unsigned int subd,unsigned int chan, unsigned int range,unsigned int aref,lsampl_t *data); +int comedi_data_read_delayed(comedi_t *it,unsigned int subd,unsigned int chan, + unsigned int range,unsigned int aref,lsampl_t *data, unsigned int micro_sec); int comedi_data_write(comedi_t *it,unsigned int subd,unsigned int chan, unsigned int range,unsigned int aref,lsampl_t data); int comedi_dio_config(comedi_t *it,unsigned int subd,unsigned int chan, diff --git a/lib/data.c b/lib/data.c index f80a473..f67914d 100644 --- a/lib/data.c +++ b/lib/data.c @@ -173,3 +173,41 @@ int comedi_data_read(comedi_t *it,unsigned int subdev,unsigned int chan,unsigned } } +int comedi_data_read_delayed( comedi_t *it, unsigned int subdev, unsigned int chan, unsigned int range, + unsigned int aref, lsampl_t *data, unsigned int nano_sec) +{ + subdevice *s; + comedi_insnlist ilist; + comedi_insn insn[3]; + lsampl_t delay = nano_sec; + + if( !valid_chan( it, subdev, chan ) ) + return -1; + + s = it->subdevices + subdev; + + memset(&insn,0,sizeof(insn)); + + // setup, no conversions + insn[0].insn = INSN_READ; + insn[0].n = 0; + insn[0].data = data; + insn[0].subdev = subdev; + insn[0].chanspec = CR_PACK( chan, range, aref ); + // delay + insn[1].insn = INSN_WAIT; + insn[1].n = 1; + insn[1].data = &delay; + // take conversion + insn[2].insn = INSN_READ; + insn[2].n = 1; + insn[2].data = data; + insn[2].subdev = subdev; + insn[2].chanspec = CR_PACK( chan, range, aref ); + + ilist.insns = insn; + ilist.n_insns = sizeof(insn) / sizeof(insn[0]); + + return comedi_do_insnlist(it, &ilist); +} + -- 2.26.2