Fixes for comedi_rt_timer. Still needs work; doesn't even
authorDavid Schleef <ds@schleef.org>
Tue, 3 Apr 2001 09:19:10 +0000 (09:19 +0000)
committerDavid Schleef <ds@schleef.org>
Tue, 3 Apr 2001 09:19:10 +0000 (09:19 +0000)
compile right now.

comedi/Config.in
comedi/drivers/Makefile
comedi/drivers/comedi_rt_timer.c

index 937e3c4ba17fdc30cb5ab9fc0ff62234f3d6d5f8..86c1ee4bcbe12726f58bbb7e927b2f938e97fd39 100644 (file)
@@ -106,6 +106,6 @@ dep_tristate 'Generic ISA driver for simple boards' CONFIG_COMEDI_POC $CONFIG_CO
 dep_tristate 'Skeleton driver' CONFIG_COMEDI_SKEL $CONFIG_COMEDI
 
 if [ "$CONFIG_COMEDI_RT" = "y" ];then
-       dep_tristate 'Real-time command emulator (timer)' CONFIG_COMEDI_XXX $CONFIG_COMEDI
+       dep_tristate 'Real-time command emulator (timer)' CONFIG_COMEDI_RT_TIMER $CONFIG_COMEDI
 fi
 
index d6b1e48a2bc4a79f74f2537b4b8c5b80f4246f22..b68ceed8d0992dfe8081bd1a9ec83b5d543525d5 100644 (file)
@@ -70,13 +70,13 @@ obj-$(CONFIG_COMEDI_QUATECH_DAQP)   += quatech_daqp_cs.o
 
 obj-$(CONFIG_COMEDI_PARPORT)           += comedi_parport.o
 
+obj-$(CONFIG_COMEDI_RT_TIMER)          += comedi_rt_timer.o
+
 obj-$(CONFIG_COMEDI_RTI800)            += rti800.o
 obj-$(CONFIG_COMEDI_RTI802)            += rti802.o
 
 obj-$(CONFIG_COMEDI_SKEL)              += skel.o
 
-obj-$(CONFIG_COMEDI_RT_TIMER)          += comedi_rt_timer.o
-
 #obj-m += $(obj-y)
 
 O_OBJS         := $(sort $(filter-out $(export-objs), $(obj-y)))
index a041ed03021f6a32fa55bec9b44748f5d7f978a1..2a09d791cc94eab57ec89a22aa1acc770d560308 100644 (file)
 
 
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/malloc.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/timex.h>
-#include <linux/timer.h>
+#include <linux/module.h>
 #include <asm/io.h>
 #include <linux/comedidev.h>
 #ifdef CONFIG_COMEDI_RTL_V1
 #include <rtai_sched.h>
 #endif
 
+/* Change this if you need more channels */
+#define N_CHANLIST 16
+
+
 static int timer_attach(comedi_device *dev,comedi_devconfig *it);
 static int timer_detach(comedi_device *dev);
 comedi_driver driver_timer={
+       module:         THIS_MODULE,
        driver_name:    "timer",
        attach:         timer_attach,
        detach:         timer_detach,
@@ -66,9 +63,11 @@ typedef struct{
        comedi_device *dev;
        comedi_subdevice *s;
        RT_TASK rt_task;
-       sampl_t *data;
-       comedi_trig trig;
        int soft_irq;
+       int n_chan;
+       int n_samples;
+       int chanlist[N_CHANLIST];
+       lsampl_t data[N_CHANLIST];
 }timer_private;
 #define devpriv ((timer_private *)dev->private)
 
@@ -86,9 +85,9 @@ static void timer_interrupt(int irq,void *d,struct pt_regs * regs)
 
 static inline void buf_add(comedi_device *dev,comedi_subdevice *s,sampl_t x)
 {
-       *(sampl_t *)(((void *)(s->cur_trig.data))+s->buf_int_ptr)=x&0xfff;
+       *(sampl_t *)((s->async->data)+s->buf_int_ptr)=x&0xfff;
        s->buf_int_ptr+=sizeof(sampl_t);
-       if(s->buf_int_ptr>=s->cur_trig.data_len){
+       if(s->buf_int_ptr>=s->async->data_len){
                s->buf_int_ptr=0;
                comedi_eobuf(dev,s);
        }
@@ -105,19 +104,25 @@ static void timer_ai_task_func(int d)
        int i,n,ret;
        int n_chan;
 
-       n_chan=s->cur_trig.n_chan;
+       n_chan=devpriv->n_chan;
 
-       for(n=0;n<my_trig->n;n++){
+       for(n=0;n<devpriv->n;n++){
                for(i=0;i<n_chan;i++){
                        it->n_chan=1;
                        it->data=devpriv->data+i;
-                       it->chanlist=my_trig->chanlist+i;
-
-                       ret=comedi_trig_ioctl(devpriv->device,devpriv->subd,it);
+                       it->chanlist=devpriv->chanlist+i;
 
+                       ret = comedi_data_read(devpriv->device,devpriv->subd,
+                               CR_CHAN(devpriv->chanlist[i]),
+                               CR_RANGE(devpriv->chanlist[i]),
+                               CR_AREF(devpriv->chanlist[i]),
+                               &data);
                        if(ret<0){
                                /* eek! */
                        }
+
+                       devpriv->data[i]=data;
+
                }
                for(i=0;i<n_chan;i++){
                        buf_add(dev,s,devpriv->data[i]);
@@ -316,7 +321,9 @@ static int timer_detach(comedi_device *dev)
 {
        printk("comedi%d: timer: remove\n",dev->minor);
        
+#ifdef CONFIG_COMEDI_RTL
        free_irq(devpriv->soft_irq,NULL);
+#endif
 
        return 0;
 }