From 8c6c68e92d6b4c8aa5e2fcc784ed52da40845acc Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 13 Oct 2019 02:05:03 +0200 Subject: net refactor; rename cmd -> type --- code/ecp/fe310/time.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'code/ecp/fe310/time.c') diff --git a/code/ecp/fe310/time.c b/code/ecp/fe310/time.c index fedd23a..995b4f2 100644 --- a/code/ecp/fe310/time.c +++ b/code/ecp/fe310/time.c @@ -13,7 +13,12 @@ ecp_cts_t ecp_tm_abstime_ms(ecp_cts_t msec) { return now_ms + msec; } -void ecp_tm_sleep_ms(ecp_cts_t msec) {} +void ecp_tm_sleep_ms(ecp_cts_t msec) { + volatile uint64_t *mtime = (uint64_t *) (CLINT_CTRL_ADDR + CLINT_MTIME); + + uint64_t now_ms = *mtime * 1000 / RTC_FREQ; + while (*mtime * 1000 / RTC_FREQ < now_ms + msec); +} void ecp_tm_timer_set(ecp_cts_t next) { uint32_t tick = next * (uint64_t)RTC_FREQ / 1000; -- cgit v1.2.3