2014-05-02 17:54:01 -04:00
|
|
|
#include "HAL/Utilities.hpp"
|
|
|
|
|
#include <time.h>
|
2013-12-15 18:30:16 -05:00
|
|
|
|
|
|
|
|
const int32_t HAL_NO_WAIT = 0;
|
|
|
|
|
const int32_t HAL_WAIT_FOREVER = -1;
|
|
|
|
|
|
2014-05-02 17:54:01 -04:00
|
|
|
void delayTicks(int32_t ticks)
|
|
|
|
|
{
|
|
|
|
|
struct timespec test, remaining;
|
|
|
|
|
test.tv_sec = 0;
|
|
|
|
|
test.tv_nsec = ticks * 3;
|
|
|
|
|
nanosleep(&test, &remaining);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2014-05-02 17:54:01 -04:00
|
|
|
void delayMillis(double ms)
|
|
|
|
|
{
|
|
|
|
|
struct timespec test, remaining;
|
|
|
|
|
test.tv_sec = ms / 1000;
|
|
|
|
|
test.tv_nsec = 1000 * (((uint64_t)ms) % 1000000);
|
|
|
|
|
nanosleep(&test, &remaining);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2014-05-02 17:54:01 -04:00
|
|
|
void delaySeconds(double s)
|
|
|
|
|
{
|
|
|
|
|
struct timespec test, remaining;
|
|
|
|
|
test.tv_sec = (int)s;
|
|
|
|
|
test.tv_nsec = (s - (int)s) * 1000000000.0;
|
|
|
|
|
nanosleep(&test, &remaining);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|