#ifndef __LUNAIX_CLOCK_H
#define __LUNAIX_CLOCK_H
-#include <lunaix/types.h>
+#include <lunaix/time.h>
-typedef u32_t time_t;
+#include <hal/hwrtc.h>
+#include <hal/hwtimer.h>
-typedef struct
-{
- u32_t year; // use int32 as we need to store the 4-digit year
- u8_t month;
- u8_t day;
- u8_t weekday;
- u8_t hour;
- u8_t minute;
- u8_t second;
-} datetime_t;
-
-void
-clock_init();
+extern const struct hwrtc_potens* sysrtc;
+extern const struct hwtimer_pot* systimer;
void
clock_walltime(datetime_t* datetime);
-int
-clock_datatime_eq(datetime_t* a, datetime_t* b);
-
/**
* @brief 返回当前系统时间,即自从开机到当前时刻的毫秒时。
*
time_t
clock_unixtime();
-static inline time_t
-clock_tounixtime(datetime_t* dt)
-{
- return (dt->year - 1970) * 31556926u + (dt->month - 1) * 2629743u +
- (dt->day - 1) * 86400u + (dt->hour - 1) * 3600u +
- (dt->minute - 1) * 60u + dt->second;
-}
-
-static inline time_t
-time_tounix(u32_t yyyy, u32_t mm, u32_t dd, u32_t hh, u32_t MM, u32_t ss)
+static inline void
+clock_init()
{
- return (yyyy - 1970) * 31556926u + (mm - 1) * 2629743u + (dd - 1) * 86400u +
- (hh - 1) * 3600u + (MM - 1) * 60u + ss;
+ hwrtc_init();
}
#endif /* __LUNAIX_CLOCK_H */