aboutsummaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorPaul Sokolovsky2016-10-14 20:13:02 +0300
committerPaul Sokolovsky2016-10-14 20:14:01 +0300
commita97284423eba9470c16c5f02fadea14bd8263751 (patch)
tree6497aa2d4cfd2694568d3bc37ab0d3e2676fe37b /py
parent824f5c5a32d740acad50d23b7ab1d69660dcf3ad (diff)
extmod/utime_mphal: Factor out implementations in terms of mp_hal_* for reuse.
As long as a port implement mp_hal_sleep_ms(), mp_hal_ticks_ms(), etc. functions, it can just use standard implementations of utime.sleel_ms(), utime.ticks_ms(), etc. Python-level functions.
Diffstat (limited to 'py')
-rw-r--r--py/mpconfig.h6
-rw-r--r--py/mphal.h4
-rw-r--r--py/py.mk1
3 files changed, 11 insertions, 0 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index e33a41f7a..dcdaffe0f 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -860,6 +860,12 @@ typedef double mp_float_t;
#define MICROPY_PY_UERRNO (0)
#endif
+// Whether to provide "utime" module functions implementation
+// in terms of mp_hal_* functions.
+#ifndef MICROPY_PY_UTIME_MP_HAL
+#define MICROPY_PY_UTIME_MP_HAL (0)
+#endif
+
// Whether to provide "_thread" module
#ifndef MICROPY_PY_THREAD
#define MICROPY_PY_THREAD (0)
diff --git a/py/mphal.h b/py/mphal.h
index 54a45b024..8d5654f9e 100644
--- a/py/mphal.h
+++ b/py/mphal.h
@@ -66,6 +66,10 @@ mp_uint_t mp_hal_ticks_ms(void);
mp_uint_t mp_hal_ticks_us(void);
#endif
+#ifndef mp_hal_ticks_cpu
+mp_uint_t mp_hal_ticks_cpu(void);
+#endif
+
// If port HAL didn't define its own pin API, use generic
// "virtual pin" API from the core.
#ifndef mp_hal_pin_obj_t
diff --git a/py/py.mk b/py/py.mk
index 741ad52f9..8caa37f8a 100644
--- a/py/py.mk
+++ b/py/py.mk
@@ -229,6 +229,7 @@ PY_O_BASENAME = \
../extmod/vfs_fat_file.o \
../extmod/vfs_fat_lexer.o \
../extmod/vfs_fat_misc.o \
+ ../extmod/utime_mphal.o \
../extmod/moduos_dupterm.o \
../lib/embed/abort_.o \
../lib/utils/printf.o \