From f78a765b64d1b85d4017334706e23523834ed128 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Wed, 9 Feb 2000 07:51:41 +0000 Subject: [PATCH] initial command support for dt282x --- comedi/comedi_module.h | 1 + comedi/drivers/dt282x.c | 69 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/comedi/comedi_module.h b/comedi/comedi_module.h index 53db6b8f..cd04e733 100644 --- a/comedi/comedi_module.h +++ b/comedi/comedi_module.h @@ -140,6 +140,7 @@ struct comedi_subdevice_struct{ int (*trig[5])(comedi_device *,comedi_subdevice *,comedi_trig *); int (*do_cmd)(comedi_device *,comedi_subdevice *); + int (*do_cmdtest)(comedi_device *,comedi_subdevice *,comedi_cmd *); int (*poll)(comedi_device *,comedi_subdevice *); int (*cancel)(comedi_device *,comedi_subdevice *); int (*do_lock)(comedi_device *,comedi_subdevice *); diff --git a/comedi/drivers/dt282x.c b/comedi/drivers/dt282x.c index 7da8671b..e6c0df53 100644 --- a/comedi/drivers/dt282x.c +++ b/comedi/drivers/dt282x.c @@ -655,14 +655,13 @@ static int dt282x_ai_mode0(comedi_device * dev, comedi_subdevice * s, comedi_tri return 1; } -#if 0 -static int dt282x_ai_cmd(comedi_device * dev, comedi_subdevice * s) +#ifdef CONFIG_COMEDI_VER08 +static int dt282x_ai_cmdtest(comedi_device * dev, comedi_subdevice * s,comedi_cmd *cmd) { int err=0; - comedi_cmd *cmd=&s->cur_cmd; if(cmd->start_src!=TRIG_NOW || - cmd->start_arg!=0 ||| + cmd->start_arg!=0 || cmd->scan_begin_arg!=0 || cmd->convert_src!=TRIG_TIMER || cmd->scan_end_src!=TRIG_COUNT || @@ -685,10 +684,67 @@ static int dt282x_ai_cmd(comedi_device * dev, comedi_subdevice * s) } if(cmd->stop_src!=TRIG_COUNT && cmd->stop_src!=TRIG_NONE){ err=1; + } + + if(err)return -EINVAL; + + return 0; +} + +static int dt282x_ai_cmd(comedi_device * dev, comedi_subdevice * s) +{ + comedi_cmd *cmd=&s->cmd; + int timer; + + timer=dt282x_ns_to_timer(&cmd->convert_arg); + outw(timer, dev->iobase + DT2821_TMRCTR); + + if(cmd->scan_begin_src==TRIG_FOLLOW){ + /* internal trigger */ + devpriv->supcsr = DT2821_ERRINTEN | DT2821_DS0; + }else{ + /* external trigger */ + devpriv->supcsr = DT2821_ERRINTEN | DT2821_DS0 | DT2821_DS1; + } + update_supcsr(DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_ADCINIT); + devpriv->adcsr = 0; + + devpriv->ntrig=cmd->stop_arg*cmd->scan_end_arg; + devpriv->nread=devpriv->ntrig; + + devpriv->dma_dir=DMA_MODE_READ; + devpriv->current_dma_chan=0; + prep_ai_dma(dev,0,0); + enable_dma(devpriv->dma[0].chan); + if(devpriv->ntrig){ + prep_ai_dma(dev,1,0); + enable_dma(devpriv->dma[1].chan); + devpriv->supcsr |= DT2821_DDMA; + update_supcsr(0); + } + + devpriv->adcsr = DT2821_ADCLK | DT2821_IADDONE; + update_adcsr(0); + dt282x_load_changain(dev,cmd->chanlist_len,cmd->chanlist); + + devpriv->adcsr = DT2821_ADCLK | DT2821_IADDONE; + update_adcsr(0); + + update_supcsr(DT2821_PRLD); + wait_for(!mux_busy(), + comedi_error(dev, "timeout\n"); + return -ETIME; + ); + + if(cmd->scan_begin_src==TRIG_FOLLOW){ + update_supcsr(DT2821_STRIG); + }else{ + devpriv->supcsr |= DT2821_XTRIG; + update_supcsr(0); } - return -EINVAL; + return 0; } #endif @@ -1121,7 +1177,8 @@ static int dt282x_attach(comedi_device * dev, comedi_devconfig * it) s->trig[0]=dt282x_ai_mode0; s->trig[1]=dt282x_ai_mode1; s->trig[4]=dt282x_ai_mode4; -#if 0 +#if CONFIG_COMEDI_VER08 + s->do_cmdtest=dt282x_ai_cmdtest; s->do_cmd=dt282x_ai_cmd; #endif s->cancel=dt282x_ai_cancel; -- 2.26.2