Mercurial > hg > beaglert
annotate core/Clock.cpp @ 138:53e3c0a3295d ClockSync
Added xenomai version of Clock, now includes header
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sun, 13 Sep 2015 21:33:01 +0100 |
parents | 772dbb57442b |
children |
rev | line source |
---|---|
giuliomoro@135 | 1 #include "Clock.h" |
giuliomoro@135 | 2 |
giuliomoro@135 | 3 namespace Clock |
giuliomoro@135 | 4 { |
giuliomoro@136 | 5 #ifdef USE_JUCE |
giuliomoro@136 | 6 myClock_t getTimeUs(){ |
giuliomoro@136 | 7 struct timeval tv; |
giuliomoro@136 | 8 struct timezone tz; |
giuliomoro@136 | 9 int ret=gettimeofday(&tv, &tz); |
giuliomoro@136 | 10 if(ret == -1){ |
giuliomoro@136 | 11 printf("Error while getting time of the day\n"); |
giuliomoro@136 | 12 return -1; |
giuliomoro@136 | 13 } |
giuliomoro@136 | 14 myClock_t time=tv.tv_usec + tv.tv_sec*1e6; |
giuliomoro@136 | 15 // printf("Time is: %.6f\n", time/1000000.0); |
giuliomoro@136 | 16 // printf("Time is: %lld\n", time); |
giuliomoro@136 | 17 return time; |
giuliomoro@136 | 18 } |
giuliomoro@136 | 19 #else |
giuliomoro@136 | 20 myClock_t getTimeUs(){ |
giuliomoro@136 | 21 return (myClock_t)((rt_timer_read()+500)/1000); |
giuliomoro@136 | 22 } |
giuliomoro@136 | 23 #endif /* USE_JUCE */ |
giuliomoro@136 | 24 }; |