equal
deleted
inserted
replaced
14 TIMEVAL last_time_set = TIMEVAL_MAX; |
14 TIMEVAL last_time_set = TIMEVAL_MAX; |
15 |
15 |
16 struct timeval last_sig; |
16 struct timeval last_sig; |
17 |
17 |
18 timer_t timer; |
18 timer_t timer; |
|
19 |
|
20 void TimerCleanup(void) |
|
21 { |
|
22 /* only used in realtime apps */ |
|
23 } |
19 |
24 |
20 void EnterMutex(void) |
25 void EnterMutex(void) |
21 { |
26 { |
22 pthread_mutex_lock(&CanFestival_mutex); |
27 pthread_mutex_lock(&CanFestival_mutex); |
23 } |
28 } |
34 TimeDispatch(); |
39 TimeDispatch(); |
35 LeaveMutex(); |
40 LeaveMutex(); |
36 // printf("getCurrentTime() return=%u\n", p.tv_usec); |
41 // printf("getCurrentTime() return=%u\n", p.tv_usec); |
37 } |
42 } |
38 |
43 |
39 void initTimer(void) |
44 void TimerInit(void) |
40 { |
45 { |
41 struct sigevent sigev; |
46 struct sigevent sigev; |
42 |
47 |
43 // Take first absolute time ref. |
48 // Take first absolute time ref. |
44 gettimeofday(&last_sig,NULL); |
49 gettimeofday(&last_sig,NULL); |
50 sigev.sigev_notify_function = timer_notify; |
55 sigev.sigev_notify_function = timer_notify; |
51 |
56 |
52 timer_create (CLOCK_REALTIME, &sigev, &timer); |
57 timer_create (CLOCK_REALTIME, &sigev, &timer); |
53 } |
58 } |
54 |
59 |
55 void StopTimerLoop(void) |
60 void StopTimerLoop(TimerCallback_t exitfunction) |
56 { |
61 { |
57 EnterMutex(); |
62 EnterMutex(); |
58 timer_delete (timer); |
63 timer_delete (timer); |
|
64 exitfunction(NULL,0); |
59 LeaveMutex(); |
65 LeaveMutex(); |
60 } |
66 } |
61 |
67 |
62 void StartTimerLoop(TimerCallback_t init_callback) |
68 void StartTimerLoop(TimerCallback_t init_callback) |
63 { |
69 { |
64 initTimer(); |
|
65 EnterMutex(); |
70 EnterMutex(); |
66 // At first, TimeDispatch will call init_callback. |
71 // At first, TimeDispatch will call init_callback. |
67 SetAlarm(NULL, 0, init_callback, 0, 0); |
72 SetAlarm(NULL, 0, init_callback, 0, 0); |
68 LeaveMutex(); |
73 LeaveMutex(); |
69 } |
74 } |