summaryrefslogtreecommitdiff
path: root/code/ecp/fe310
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2020-03-11 16:28:27 +0100
committerUros Majstorovic <majstor@majstor.org>2020-03-11 16:28:27 +0100
commitab1006d27417cc831150877ec46fbc13ffeddb53 (patch)
tree21a45e41483b84443f57a68360dae78e7fcabecc /code/ecp/fe310
parentc4dfa25d8d30f2812ae48dea1ffb0f326d46ae9f (diff)
timer fix
Diffstat (limited to 'code/ecp/fe310')
-rw-r--r--code/ecp/fe310/time.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/code/ecp/fe310/time.c b/code/ecp/fe310/time.c
index 8458a2d..3c74933 100644
--- a/code/ecp/fe310/time.c
+++ b/code/ecp/fe310/time.c
@@ -6,15 +6,12 @@
#include <eos/event.h>
#include <eos/timer.h>
-#include "encoding.h"
-#include "platform.h"
-
extern ECPSocket *_ecp_tr_sock;
static void timer_handler(unsigned char type) {
ecp_cts_t next = ecp_timer_exe(_ecp_tr_sock);
if (next) {
- eos_timer_set(next, EOS_TIMER_ETYPE_ECP, 0);
+ eos_timer_set(next, EOS_TIMER_ETYPE_ECP);
}
}
@@ -25,16 +22,14 @@ int ecp_tm_init(ECPContext *ctx) {
}
ecp_cts_t ecp_tm_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;
+ return eos_time_get_tick() * 1000 / EOS_TIMER_RTC_FREQ + msec;
}
void ecp_tm_sleep_ms(ecp_cts_t msec) {
- eos_timer_sleep(msec);
+ eos_time_sleep(msec);
}
void ecp_tm_timer_set(ecp_cts_t next) {
- eos_timer_set(next, EOS_TIMER_ETYPE_ECP, 1);
+ uint32_t _next = eos_timer_get(EOS_TIMER_ETYPE_ECP);
+ if ((_next == EOS_TIMER_NONE) || (next < _next)) eos_timer_set(next, EOS_TIMER_ETYPE_ECP);
}