-#include <hal/hwrtc.h>
-#include <hal/hwtimer.h>
#include <lunaix/clock.h>
+#include <lunaix/device.h>
#include <lunaix/fs/twifs.h>
#include <lunaix/spike.h>
clock_walltime(&dt);
twimap_printf(map,
"%.4d-%.2d-%.2d %.2d:%.2d:%.2d",
- dt.year,
- dt.month,
- dt.day,
- dt.hour,
- dt.minute,
- dt.second);
+ dt.year, dt.month, dt.day,
+ dt.hour, dt.minute, dt.second);
}
void
}
EXPORT_TWIFS_PLUGIN(sys_clock, clock_build_mapping);
-void
-clock_init()
-{
- hwrtc_init();
-}
-
time_t
clock_unixtime()
{
time_t
clock_systime()
{
+ if (!systimer) {
+ return 0;
+ }
+
ticks_t t = hwtimer_current_systicks();
- return t / current_timer->running_freq;
+ ticks_t tu = systimer->running_freq / 1000;
+
+ if (unlikely(!tu)) {
+ return t;
+ }
+
+ return t / (tu);
}
void
clock_walltime(datetime_t* datetime)
{
- current_rtc->get_walltime(current_rtc, datetime);
+ sysrtc->ops->get_walltime(sysrtc, datetime);
}
\ No newline at end of file