diff -r f45fd4cd3832 -r 34654679f262 doc/doxygen/html/timers__xeno_8c-source.html --- a/doc/doxygen/html/timers__xeno_8c-source.html Fri Jul 06 10:53:15 2007 +0200 +++ b/doc/doxygen/html/timers__xeno_8c-source.html Mon Jul 16 08:56:03 2007 +0200 @@ -18,7 +18,7 @@
  • Globals
  • +drivers » timers_xeno

    timers_xeno.c

    Go to the documentation of this file.
    00001 #include <stdlib.h>
     00002 #include <unistd.h>
     00003 #include <sys/mman.h>
    @@ -32,74 +32,74 @@
     00011 #include "can_driver.h"
     00012 #include "timer.h"
     00013 
    -00014 #define TIMERLOOP_TASK_CREATED        1
    +00014 #define TIMERLOOP_TASK_CREATED        1
     00015 
    -00016 RT_MUTEX CanFestival_mutex;
    -00017 RT_TASK timerloop_task;
    -00018 RTIME last_time_read;
    -00019 RTIME last_occured_alarm;
    -00020 RTIME last_alarm_set;
    +00016 RT_MUTEX CanFestival_mutex;
    +00017 RT_TASK timerloop_task;
    +00018 RTIME last_time_read;
    +00019 RTIME last_occured_alarm;
    +00020 RTIME last_alarm_set;
     00021 
    -00022 char stop_timer=0;
    +00022 char stop_timer=0;
     00023 
    -00024 void cleanup_all(void)
    +00024 void cleanup_all(void)
     00025 {
    -00026         rt_task_delete(&timerloop_task);
    +00026         rt_task_delete(&timerloop_task);
     00027 }
    -00028 void StopTimerLoop(void)
    +00028 void StopTimerLoop(void)
     00029 {
    -00030         stop_timer = 1;
    -00031         rt_task_unblock(&timerloop_task);
    +00030         stop_timer = 1;
    +00031         rt_task_unblock(&timerloop_task);
     00032 }
     00033 
     00034 
    -00035 void EnterMutex(void)
    +00035 void EnterMutex(void)
     00036 {
    -00037         rt_mutex_lock(&CanFestival_mutex, TM_INFINITE); 
    +00037         rt_mutex_lock(&CanFestival_mutex, TM_INFINITE); 
     00038 }
     00039 
    -00040 void LeaveMutex(void)
    +00040 void LeaveMutex(void)
     00041 {
    -00042         rt_mutex_unlock(&CanFestival_mutex);
    +00042         rt_mutex_unlock(&CanFestival_mutex);
     00043 }
     00044 
    -00045 void timerloop_task_proc(void *arg)
    +00045 void timerloop_task_proc(void *arg)
     00046 {
     00047         int ret;
     00048         do{
     00049                 do{
    -00050                         last_occured_alarm = last_alarm_set;
    -00051                         EnterMutex();
    -00052                         TimeDispatch();
    -00053                         LeaveMutex();
    -00054                         while ((ret = rt_task_sleep_until(last_alarm_set)) == -EINTR);
    +00050                         last_occured_alarm = last_alarm_set;
    +00051                         EnterMutex();
    +00052                         TimeDispatch();
    +00053                         LeaveMutex();
    +00054                         while ((ret = rt_task_sleep_until(last_alarm_set)) == -EINTR);
     00055                 }while (ret == 0);
    -00056         }while (!stop_timer);
    +00056         }while (!stop_timer);
     00057         printf("End of TimerLoop, code %d\n",ret);
     00058 }
     00059 
    -00060 void StartTimerLoop(TimerCallback_t init_callback)
    +00060 void StartTimerLoop(TimerCallback_t init_callback)
     00061 {
     00062         int ret;
    -00063         stop_timer = 0;
    +00063         stop_timer = 0;
     00064         char taskname[32];
     00065         snprintf(taskname, sizeof(taskname), "timerloop-%d", getpid());
     00066 
     00067         mlockall(MCL_CURRENT | MCL_FUTURE);
     00068 
     00069         //create timerloop_task
    -00070         ret = rt_task_create(&timerloop_task, taskname, 0, 50, 0);
    +00070         ret = rt_task_create(&timerloop_task, taskname, 0, 50, 0);
     00071         if (ret) {
     00072                 printf("Failed to create timerloop_task, code %d\n",errno);
     00073                 return;
     00074         }
     00075         
    -00076         getElapsedTime();
    -00077         last_alarm_set = last_time_read;
    -00078         last_occured_alarm = last_alarm_set;
    -00079         SetAlarm(NULL, 0, init_callback, 0, 0);
    +00076         getElapsedTime();
    +00077         last_alarm_set = last_time_read;
    +00078         last_occured_alarm = last_alarm_set;
    +00079         SetAlarm(NULL, 0, init_callback, 0, 0);
     00080         // start timerloop_task
    -00081         ret = rt_task_start(&timerloop_task,&timerloop_task_proc,NULL);
    +00081         ret = rt_task_start(&timerloop_task,&timerloop_task_proc,NULL);
     00082         if (ret) {
     00083                 printf("Failed to start timerloop_task, code %d\n",errno);
     00084                 goto error;
    @@ -108,10 +108,10 @@
     00087         return;
     00088         
     00089 error:
    -00090         cleanup_all();
    +00090         cleanup_all();
     00091 }
     00092 
    -00093 void CreateReceiveTask(CAN_PORT fd0, TASK_HANDLE *ReceiveLoop_task, void* ReceiveLoop_task_proc)
    +00093 void CreateReceiveTask(CAN_PORT fd0, TASK_HANDLE *ReceiveLoop_task, void* ReceiveLoop_task_proc)
     00094 {
     00095         int ret;
     00096         static int id = 0;
    @@ -135,23 +135,23 @@
     00114         }
     00115 }
     00116 
    -00117 void WaitReceiveTaskEnd(TASK_HANDLE *Thread)
    +00117 void WaitReceiveTaskEnd(TASK_HANDLE *Thread)
     00118 {
     00119         rt_task_delete(Thread);
     00120 }
     00121 
    -00122 void setTimer(TIMEVAL value)
    +00122 void setTimer(TIMEVAL value)
     00123 {
    -00124         last_alarm_set = (value == TIMEVAL_MAX) ? TIMEVAL_MAX : last_time_read + value;
    -00125         rt_task_unblock(&timerloop_task);
    +00124         last_alarm_set = (value == TIMEVAL_MAX) ? TIMEVAL_MAX : last_time_read + value;
    +00125         rt_task_unblock(&timerloop_task);
     00126 }
     00127 
    -00128 TIMEVAL getElapsedTime(void)
    +00128 TIMEVAL getElapsedTime(void)
     00129 {
    -00130         last_time_read = rt_timer_ticks2ns(rt_timer_read());
    -00131         return last_time_read - last_occured_alarm;
    +00130         last_time_read = rt_timer_ticks2ns(rt_timer_read());
    +00131         return last_time_read - last_occured_alarm;
     00132 }
    -

    Generated on Fri Jun 8 08:51:38 2007 for CanFestival by  +
    Generated on Mon Jul 2 19:10:16 2007 for CanFestival by  doxygen 1.5.1