summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-10-29 14:32:15 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-10-29 14:32:15 +0300
commit6a2c6098f487f1faab2010d00950ce2258fdac53 (patch)
treedc133b7a9679f8d436c5e0e8a3dd6ca44b62aee6
parent3cc87b1e2af22aeb79d8dfc6415fd08f650860a1 (diff)
windows: Enable utime_mphal following unix, define mp_hal_ticks_*.
mp_hal_ticks_ms, mp_hal_ticks_us taken from unix port, mp_hal_ticks_cpu dummy.
-rw-r--r--windows/mpconfigport.h1
-rw-r--r--windows/windows_mphal.c13
-rw-r--r--windows/windows_mphal.h3
3 files changed, 17 insertions, 0 deletions
diff --git a/windows/mpconfigport.h b/windows/mpconfigport.h
index da49bc0dc..88596977c 100644
--- a/windows/mpconfigport.h
+++ b/windows/mpconfigport.h
@@ -92,6 +92,7 @@
#define MICROPY_PY_UBINASCII (1)
#define MICROPY_PY_URANDOM (1)
#define MICROPY_PY_UTIME (1)
+#define MICROPY_PY_UTIME_MP_HAL (1)
#define MICROPY_PY_MACHINE (1)
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED)
diff --git a/windows/windows_mphal.c b/windows/windows_mphal.c
index 6cc4f6542..0f00597af 100644
--- a/windows/windows_mphal.c
+++ b/windows/windows_mphal.c
@@ -30,6 +30,7 @@
#include <windows.h>
#include <unistd.h>
+#include <sys/time.h>
HANDLE std_in = NULL;
HANDLE con_out = NULL;
@@ -204,3 +205,15 @@ 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;
+}
diff --git a/windows/windows_mphal.h b/windows/windows_mphal.h
index dce248455..a17f17021 100644
--- a/windows/windows_mphal.h
+++ b/windows/windows_mphal.h
@@ -31,3 +31,6 @@
void mp_hal_move_cursor_back(unsigned int pos);
void mp_hal_erase_line_from_cursor(unsigned int n_chars_to_erase);
+
+// TODO: Implement.
+#define mp_hal_ticks_cpu() 0