added hack to fix broken rtlinux compatibility headers and let driver work for more...
authorFrank Mori Hess <fmhess@speakeasy.net>
Fri, 11 May 2001 04:29:11 +0000 (04:29 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Fri, 11 May 2001 04:29:11 +0000 (04:29 +0000)
comedi/drivers/comedi_rt_timer.c

index 55872d0690e9c8413540dd5132950f2924d7b41a..0574f84645615f9ec375723e78eaa97e8e83c6f2 100644 (file)
 #include <rtl.h>
 #include <rtl_sched.h>
 #include <rtl_compat.h>
+
+// begin hack to fix HRT_TO_8254() function on rtlinux
+#undef HRT_TO_8254(x)
+#define HRT_TO_8254(x) nano2tick_hack(x)
+long long nano2tick_hack(long long ns)
+{
+       unsigned long most = ns >> 32;
+       unsigned long least = ns;
+       unsigned long denom = 838;
+       unsigned long remainder = (most % denom);
+
+       most /= denom;
+       least = remainder * (0xffffffff / denom) + (remainder + least) / denom;
+
+       ns = (long long) most * (long long) 0x100000000 + (long long) least;
+
+       return ns;
+}
+// end hack
+
 #endif
 #ifdef CONFIG_COMEDI_RTAI
 #include <rtai.h>
@@ -44,7 +64,6 @@
 /* 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);
 static comedi_driver driver_timer={
@@ -335,7 +354,6 @@ static int timer_cmd(comedi_device *dev,comedi_subdevice *s)
                comedi_error(dev, "error initalizing task");
                return ret;
        }
-
        now=rt_get_time();
        ret = rt_task_make_periodic(&devpriv->rt_task,now+delay,period);
        if(ret < 0)