1 // Precise timer routines for LINUX (C) LGB & A'rpi/ASTRAL
5 #define usleep(t) snooze(t)
13 const char timer_name
[] =
20 int usec_sleep(int usec_delay
)
24 ts
.tv_sec
= usec_delay
/ 1000000;
25 ts
.tv_nsec
= (usec_delay
% 1000000) * 1000;
26 return nanosleep(&ts
, NULL
);
28 return usleep(usec_delay
);
32 // Returns current time in microseconds
33 unsigned int GetTimer(void){
35 gettimeofday(&tv
,NULL
);
36 return tv
.tv_sec
* 1000000 + tv
.tv_usec
;
39 // Returns current time in milliseconds
40 unsigned int GetTimerMS(void){
42 gettimeofday(&tv
,NULL
);
43 return tv
.tv_sec
* 1000 + tv
.tv_usec
/ 1000;
46 // Initialize timer, must be called at least once at start