diff --git a/src/utils.c b/src/utils.c index a4459b5..b20efcb 100644 --- a/src/utils.c +++ b/src/utils.c @@ -184,6 +184,22 @@ int add_iso8601_utc_datetime(char* buf, size_t size) { #endif +#ifdef ARDUINO + +int64_t usec_now() +{ + return micros(); +} + +void get_time(uint32_t *seconds, uint32_t *micro_seconds) +{ + *micro_seconds = micros(); + *seconds = *micro_seconds / 1000000; + *micro_seconds %= 1000000; +} + +#else + int64_t usec_now() { int64_t usec; @@ -204,6 +220,8 @@ void get_time(uint32_t *seconds, uint32_t *micro_seconds) *micro_seconds = tv.tv_usec; } +#endif + int64_t usec_since(int64_t last) { return usec_now() - last;