From 3b883c24da327036a049a0430bd00ebfdffd5c8f Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Mon, 21 Feb 2022 21:56:01 -0700 Subject: Added wait --- src/util/time.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/util') diff --git a/src/util/time.c b/src/util/time.c index 0ae3ccf..abb9c8d 100644 --- a/src/util/time.c +++ b/src/util/time.c @@ -67,3 +67,10 @@ unsigned long long get_time(void) t.tvalb.high = *(unsigned long*)SYS_TIMER_CHI; return t.tval; } + +void wait_msec(unsigned int n) +{ + unsigned long start = *(volatile unsigned long*)SYS_TIMER_CHI; + while (*(volatile unsigned long*)SYS_TIMER_CHI - start < n) + asm volatile("nop"); +} -- cgit v1.2.1