summaryrefslogtreecommitdiff
path: root/code/ecp/fe310/time.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2019-10-13 02:05:03 +0200
committerUros Majstorovic <majstor@majstor.org>2019-10-13 02:05:03 +0200
commit8c6c68e92d6b4c8aa5e2fcc784ed52da40845acc (patch)
tree0251bea9be01701c488f9d8719b52eeb2a64855d /code/ecp/fe310/time.c
parent2a39fdf6d943f5738ba174368053a86304b0d8fa (diff)
net refactor; rename cmd -> type
Diffstat (limited to 'code/ecp/fe310/time.c')
-rw-r--r--code/ecp/fe310/time.c7
1 files changed, 6 insertions, 1 deletions
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;