From 78028e71a329a5dd1bc991ffcd7f378ca07be480 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Fri, 11 May 2001 04:29:11 +0000 Subject: [PATCH] added hack to fix broken rtlinux compatibility headers and let driver work for more than a half hour --- comedi/drivers/comedi_rt_timer.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/comedi/drivers/comedi_rt_timer.c b/comedi/drivers/comedi_rt_timer.c index 55872d06..0574f846 100644 --- a/comedi/drivers/comedi_rt_timer.c +++ b/comedi/drivers/comedi_rt_timer.c @@ -35,6 +35,26 @@ #include #include #include + +// 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 @@ -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) -- 2.26.2