diff --git a/src/system/arduino/esp32/system.c b/src/system/arduino/esp32/system.c index a9eab813c..8f0773751 100644 --- a/src/system/arduino/esp32/system.c +++ b/src/system/arduino/esp32/system.c @@ -135,13 +135,13 @@ int z_sleep_s(size_t time) { return sleep(time); } /*------------------ Instant ------------------*/ z_clock_t z_clock_now(void) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); return now; } unsigned long z_clock_elapsed_us(z_clock_t *instant) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); unsigned long elapsed = (1000000 * (now.tv_sec - instant->tv_sec) + (now.tv_nsec - instant->tv_nsec) / 1000); return elapsed; @@ -149,7 +149,7 @@ unsigned long z_clock_elapsed_us(z_clock_t *instant) { unsigned long z_clock_elapsed_ms(z_clock_t *instant) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); unsigned long elapsed = (1000 * (now.tv_sec - instant->tv_sec) + (now.tv_nsec - instant->tv_nsec) / 1000000); return elapsed; @@ -157,7 +157,7 @@ unsigned long z_clock_elapsed_ms(z_clock_t *instant) { unsigned long z_clock_elapsed_s(z_clock_t *instant) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); unsigned long elapsed = now.tv_sec - instant->tv_sec; return elapsed; diff --git a/src/system/espidf/system.c b/src/system/espidf/system.c index 8a655cf0d..a93c5b0e5 100644 --- a/src/system/espidf/system.c +++ b/src/system/espidf/system.c @@ -136,13 +136,13 @@ int z_sleep_s(size_t time) { return sleep(time); } /*------------------ Instant ------------------*/ z_clock_t z_clock_now(void) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); return now; } unsigned long z_clock_elapsed_us(z_clock_t *instant) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); unsigned long elapsed = (1000000 * (now.tv_sec - instant->tv_sec) + (now.tv_nsec - instant->tv_nsec) / 1000); return elapsed; @@ -150,7 +150,7 @@ unsigned long z_clock_elapsed_us(z_clock_t *instant) { unsigned long z_clock_elapsed_ms(z_clock_t *instant) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); unsigned long elapsed = (1000 * (now.tv_sec - instant->tv_sec) + (now.tv_nsec - instant->tv_nsec) / 1000000); return elapsed; @@ -158,7 +158,7 @@ unsigned long z_clock_elapsed_ms(z_clock_t *instant) { unsigned long z_clock_elapsed_s(z_clock_t *instant) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); unsigned long elapsed = now.tv_sec - instant->tv_sec; return elapsed; diff --git a/src/system/unix/system.c b/src/system/unix/system.c index 875bc5f2b..990619dac 100644 --- a/src/system/unix/system.c +++ b/src/system/unix/system.c @@ -156,13 +156,13 @@ int z_sleep_s(size_t time) { return sleep(time); } /*------------------ Instant ------------------*/ z_clock_t z_clock_now(void) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); return now; } unsigned long z_clock_elapsed_us(z_clock_t *instant) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); unsigned long elapsed = (1000000 * (now.tv_sec - instant->tv_sec) + (now.tv_nsec - instant->tv_nsec) / 1000); return elapsed; @@ -170,7 +170,7 @@ unsigned long z_clock_elapsed_us(z_clock_t *instant) { unsigned long z_clock_elapsed_ms(z_clock_t *instant) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); unsigned long elapsed = (1000 * (now.tv_sec - instant->tv_sec) + (now.tv_nsec - instant->tv_nsec) / 1000000); return elapsed; @@ -178,7 +178,7 @@ unsigned long z_clock_elapsed_ms(z_clock_t *instant) { unsigned long z_clock_elapsed_s(z_clock_t *instant) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); unsigned long elapsed = now.tv_sec - instant->tv_sec; return elapsed; diff --git a/src/system/zephyr/system.c b/src/system/zephyr/system.c index 28ce1d303..20e54d146 100644 --- a/src/system/zephyr/system.c +++ b/src/system/zephyr/system.c @@ -150,13 +150,13 @@ int z_sleep_s(size_t time) { /*------------------ Instant ------------------*/ z_clock_t z_clock_now(void) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); return now; } unsigned long z_clock_elapsed_us(z_clock_t *instant) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); unsigned long elapsed = (1000000 * (now.tv_sec - instant->tv_sec) + (now.tv_nsec - instant->tv_nsec) / 1000); return elapsed; @@ -164,7 +164,7 @@ unsigned long z_clock_elapsed_us(z_clock_t *instant) { unsigned long z_clock_elapsed_ms(z_clock_t *instant) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); unsigned long elapsed = (1000 * (now.tv_sec - instant->tv_sec) + (now.tv_nsec - instant->tv_nsec) / 1000000); return elapsed; @@ -172,7 +172,7 @@ unsigned long z_clock_elapsed_ms(z_clock_t *instant) { unsigned long z_clock_elapsed_s(z_clock_t *instant) { z_clock_t now; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); unsigned long elapsed = now.tv_sec - instant->tv_sec; return elapsed;