Added missing HRT functionality, cleanup

This commit is contained in:
Lorenz Meier 2014-01-02 01:18:12 +01:00
parent e35598eb6b
commit eb47a164cb
1 changed files with 7 additions and 4 deletions

View File

@ -3,11 +3,14 @@
#include <drivers/drv_hrt.h>
#include <stdio.h>
uint64_t hrt_absolute_time()
{
hrt_abstime hrt_absolute_time() {
struct timeval te;
gettimeofday(&te, NULL); // get current time
unsigned long long us = static_cast<uint64_t>(te.tv_sec) * 1e6 + te.tv_usec; // caculate us
printf("us: %lld\n", us);
hrt_abstime us = static_cast<uint64_t>(te.tv_sec) * 1e6 + te.tv_usec; // caculate us
return us;
}
hrt_abstime hrt_elapsed_time(const volatile hrt_abstime *then) {
// not thread safe
return hrt_absolute_time() - *then;
}