Skip to content

Commit 63c0abe

Browse files
committed
bricks/ev3dev/mphal: implement mp_hal_time_ns
Follows the unix port from: micropython/micropython@ee50a6e micropython/micropython@905a18a
1 parent f7887bf commit 63c0abe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bricks/ev3dev/ev3dev_mphal.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ mp_uint_t mp_hal_ticks_us(void) {
133133
return clock_usecs();
134134
}
135135

136+
uint64_t mp_hal_time_ns(void) {
137+
struct timeval tv;
138+
gettimeofday(&tv, NULL);
139+
return (uint64_t)tv.tv_sec * 1000000000ULL + (uint64_t)tv.tv_usec * 1000ULL;
140+
}
141+
136142
void mp_hal_delay_ms(mp_uint_t ms) {
137143
struct timespec ts = {
138144
.tv_sec = ms / 1000,

0 commit comments

Comments
 (0)