summaryrefslogtreecommitdiff
path: root/shared-bindings/time
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2020-02-07 10:02:50 -0500
committerDan Halbert <halbert@halwitz.org>2020-02-07 10:02:50 -0500
commit857d8ab40a6e4ef7d0cc78f481511070c1af15e3 (patch)
treeec60bdcc4df1cfdb3fb854a1c3854b60b0c07dc0 /shared-bindings/time
parenta63f49cb83ac95328bdedb543d844df378fbf207 (diff)
improve time.monotonic_ns() accuracy from ms to us
Diffstat (limited to 'shared-bindings/time')
-rw-r--r--shared-bindings/time/__init__.c2
-rw-r--r--shared-bindings/time/__init__.h1
2 files changed, 2 insertions, 1 deletions
diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c
index b3e4604b5..2c1aebc2e 100644
--- a/shared-bindings/time/__init__.c
+++ b/shared-bindings/time/__init__.c
@@ -216,7 +216,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time);
//| :rtype: int
//|
STATIC mp_obj_t time_monotonic_ns(void) {
- uint64_t time64 = common_hal_time_monotonic() * 1000000llu;
+ uint64_t time64 = common_hal_time_monotonic_ns();
return mp_obj_new_int_from_ll((long long) time64);
}
MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_ns_obj, time_monotonic_ns);
diff --git a/shared-bindings/time/__init__.h b/shared-bindings/time/__init__.h
index c5a0b47fc..ec96aea24 100644
--- a/shared-bindings/time/__init__.h
+++ b/shared-bindings/time/__init__.h
@@ -36,6 +36,7 @@ extern mp_obj_t struct_time_from_tm(timeutils_struct_time_t *tm);
extern void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm);
extern uint64_t common_hal_time_monotonic(void);
+extern uint64_t common_hal_time_monotonic_ns(void);
extern void common_hal_time_delay_ms(uint32_t);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_TIME___INIT___H