|
|
@@ -7,6 +7,9 @@
|
|
|
#include "FreeRTOS.h"
|
|
|
#include "task.h"
|
|
|
|
|
|
+#define LUAT_LOG_TAG "mcu"
|
|
|
+#include "luat_log.h"
|
|
|
+
|
|
|
/*
|
|
|
enum CPU_CLK{
|
|
|
CPU_CLK_240M = 2,
|
|
|
@@ -61,3 +64,40 @@ long luat_mcu_ticks(void) {
|
|
|
uint32_t luat_mcu_hz(void) {
|
|
|
return configTICK_RATE_HZ;
|
|
|
}
|
|
|
+
|
|
|
+#include "wm_include.h"
|
|
|
+#include "wm_timer.h"
|
|
|
+#include "wm_regs.h"
|
|
|
+uint32_t us_timer_ticks = 0;
|
|
|
+u8 u64_tick_timer_id = 0;
|
|
|
+
|
|
|
+static void utimer_cb(void* arg) {
|
|
|
+ us_timer_ticks ++;
|
|
|
+}
|
|
|
+
|
|
|
+void luat_mcu_tick64_init(void) {
|
|
|
+ struct tls_timer_cfg cfg = {0};
|
|
|
+ cfg.unit = TLS_TIMER_UNIT_US;
|
|
|
+ cfg.timeout = (u32)(-1);
|
|
|
+ cfg.is_repeat = 1;
|
|
|
+ cfg.callback = utimer_cb;
|
|
|
+ cfg.arg = NULL;
|
|
|
+ u64_tick_timer_id = tls_timer_create(&cfg);
|
|
|
+}
|
|
|
+
|
|
|
+uint64_t luat_mcu_tick64(void) {
|
|
|
+ uint64_t ret = ((uint64_t) us_timer_ticks) << 32;
|
|
|
+ ret += M32(HR_TIMER0_CNT + 4*u64_tick_timer_id);
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+int luat_mcu_us_period(void) {
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
+uint64_t luat_mcu_tick64_ms(void) {
|
|
|
+ return ((uint64_t) us_timer_ticks);
|
|
|
+}
|
|
|
+void luat_mcu_set_clk_source(uint8_t source_main, uint8_t source_32k, uint32_t delay) {
|
|
|
+ LLOGE("not support setXTAL");
|
|
|
+}
|