49 uint64_t tm = mach_absolute_time();
50 static int numer = 0, denom = 0;
53 mach_timebase_info_data_t tb;
55 kern_return_t ret = mach_timebase_info(&tb);
57 if (ret != KERN_SUCCESS) abort();
66 t->tv_nsec = tm % 1000000000;
67 t->tv_sec = tm / 1000000000;
83 perror(
"clock_gettime");
87 uint32_t val = tp.tv_sec * 1000000 + tp.tv_nsec / 1000;
118 struct timespec wait,rest;
120 wait.tv_nsec=1000*uS;
121 while (nanosleep(&wait,&rest)) {
142 struct timespec wait,rest;
144 wait.tv_nsec=(mS%1000)*1000000;
145 while (nanosleep(&wait, &rest)) {
165 uint32_t diff = later - raw;
uint32_t PIOS_DELAY_DiffuS(uint32_t raw)
Subtract raw time from now and convert to us.
int clock_gettime(clockid_t clk_id, struct timespec *t)
uint32_t PIOS_DELAY_GetuS()
Query the Delay timer for the current uS.
Main PiOS header to include all the compiled in PiOS options.
static uint32_t get_monotonic_us_time(void)
uint32_t PIOS_DELAY_DiffuS2(uint32_t raw, uint32_t baseline)
Subrtact two raw times and convert to us.
uint32_t PIOS_DELAY_GetuSExpired(uint32_t t)
Calculates whether a given time has passed.
uint32_t PIOS_DELAY_GetuSSince(uint32_t t)
Calculate time in microseconds since a previous time.
int32_t PIOS_DELAY_Init(void)
static uint32_t base_time
int32_t PIOS_DELAY_WaitmS(uint32_t mS)
int32_t PIOS_DELAY_WaituS(uint32_t uS)
uint32_t PIOS_DELAY_GetRaw()
Get the raw delay timer, useful for timing.