summaryrefslogtreecommitdiff
path: root/code/ecp/fe310/time.c
diff options
context:
space:
mode:
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;