From 0b7db1a4555da3f9a153d72f44bc2a5d070df51f Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Thu, 11 Jan 2018 18:03:58 +0100 Subject: fe310 platform introdiced --- code/core/fe310/time.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 code/core/fe310/time.c (limited to 'code/core/fe310/time.c') diff --git a/code/core/fe310/time.c b/code/core/fe310/time.c new file mode 100644 index 0000000..2ff98cb --- /dev/null +++ b/code/core/fe310/time.c @@ -0,0 +1,18 @@ +#include + +#include "encoding.h" +#include "platform.h" + +static ecp_cts_t t_abstime_ms(ecp_cts_t msec) { + volatile uint64_t *mtime = (uint64_t *) (CLINT_CTRL_ADDR + CLINT_MTIME); + + uint64_t now_ms = *mtime * 1000 / RTC_FREQ; + return now_ms + msec; +} + +int ecp_time_init(ECPTimeIface *t) { + t->init = 1; + t->abstime_ms = t_abstime_ms; + t->sleep_ms = NULL; + return 0; +} -- cgit v1.2.3