Skip to content

Commit

Permalink
bricks/ev3dev/mphal: implement mp_hal_time_ns
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Feb 19, 2021
1 parent f7887bf commit 63c0abe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bricks/ev3dev/ev3dev_mphal.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ mp_uint_t mp_hal_ticks_us(void) {
return clock_usecs();
}

uint64_t mp_hal_time_ns(void) {
struct timeval tv;
gettimeofday(&tv, NULL);
return (uint64_t)tv.tv_sec * 1000000000ULL + (uint64_t)tv.tv_usec * 1000ULL;
}

void mp_hal_delay_ms(mp_uint_t ms) {
struct timespec ts = {
.tv_sec = ms / 1000,
Expand Down

0 comments on commit 63c0abe

Please sign in to comment.