summaryrefslogtreecommitdiff
path: root/ports/unix/unix_mphal.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2020-08-01 23:50:23 +1000
committerDamien George <damien@micropython.org>2020-08-22 16:13:44 +1000
commitee50a6effebf315c38d4a129dc9f65ee722eb5b6 (patch)
tree16cfee569848d9d75fbb8eeacf39466f5b2b7319 /ports/unix/unix_mphal.c
parentbadd351150df70bea6644db98f48fbc3a1e5ffea (diff)
py/mphal.h: Introduce mp_hal_time_ns and implement on various ports.
This should return a 64-bit value being the number of nanoseconds since 1970/1/1. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'ports/unix/unix_mphal.c')
-rw-r--r--ports/unix/unix_mphal.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/ports/unix/unix_mphal.c b/ports/unix/unix_mphal.c
index 42c22f7b5..f43067f64 100644
--- a/ports/unix/unix_mphal.c
+++ b/ports/unix/unix_mphal.c
@@ -214,3 +214,8 @@ mp_uint_t mp_hal_ticks_us(void) {
return tv.tv_sec * 1000000 + tv.tv_usec;
#endif
}
+
+uint64_t mp_hal_time_ns(void) {
+ time_t now = time(NULL);
+ return (uint64_t)now * 1000000000ULL;
+}