diff options
Diffstat (limited to 'windows/windows_mphal.c')
-rw-r--r-- | windows/windows_mphal.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/windows/windows_mphal.c b/windows/windows_mphal.c index 6cc4f65428..3ad6939059 100644 --- a/windows/windows_mphal.c +++ b/windows/windows_mphal.c @@ -28,6 +28,7 @@ #include "py/mpstate.h" #include "py/mphal.h" +#include <sys/time.h> #include <windows.h> #include <unistd.h> @@ -204,3 +205,25 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) { void mp_hal_stdout_tx_str(const char *str) { mp_hal_stdout_tx_strn(str, strlen(str)); } + +mp_uint_t mp_hal_ticks_ms(void) { + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec * 1000 + tv.tv_usec / 1000; +} + +mp_uint_t mp_hal_ticks_us(void) { + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec * 1000000 + tv.tv_usec; +} + +mp_uint_t mp_hal_ticks_cpu(void) { + LARGE_INTEGER value; + QueryPerformanceCounter(&value); +#ifdef _WIN64 + return value.QuadPart; +#else + return value.LowPart; +#endif +} |