diff options
author | Uros Majstorovic <majstor@majstor.org> | 2018-01-11 21:28:22 +0100 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2018-01-11 21:28:22 +0100 |
commit | 0d0e9facfcea3cf96da3b63285865182fdd5477e (patch) | |
tree | cca42e7aab184cad981c794073a4376aa2616193 /code/ecp/fe310/time.c | |
parent | 05e11f491b84a110b9ca08612df370b91e9bdcbc (diff) |
refatoring dirs
Diffstat (limited to 'code/ecp/fe310/time.c')
-rw-r--r-- | code/ecp/fe310/time.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/code/ecp/fe310/time.c b/code/ecp/fe310/time.c new file mode 100644 index 0000000..2ff98cb --- /dev/null +++ b/code/ecp/fe310/time.c @@ -0,0 +1,18 @@ +#include <core.h> + +#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; +} |