mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-25 00:43:33 +08:00
OS X: Add missing time calls
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
#include "systemlib/param/param.h"
|
||||
#include "hrt_work.h"
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include "px4_time.h"
|
||||
|
||||
extern pthread_t _shell_task_id;
|
||||
|
||||
@@ -55,8 +56,26 @@ __BEGIN_DECLS
|
||||
|
||||
long PX4_TICKS_PER_SEC = sysconf(_SC_CLK_TCK);
|
||||
|
||||
#ifdef __PX4_DARWIN
|
||||
extern void hrt_init(void);
|
||||
|
||||
int px4_clock_gettime(clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
uint64_t currtime = hrt_absolute_time();
|
||||
|
||||
tp->tv_sec = currtime / (1000 * 1000);
|
||||
tp->tv_nsec = (currtime - (currtime * 1000 * 1000)) * 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int px4_clock_settime(clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
/* do nothing right now */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
namespace px4
|
||||
|
||||
Reference in New Issue
Block a user