Parcourir la source

add: 添加对mcu库的tick64支持

Wendal Chen il y a 3 ans
Parent
commit
e79e6c6c7f
2 fichiers modifiés avec 43 ajouts et 0 suppressions
  1. 3 0
      app/main.c
  2. 40 0
      app/port/luat_mcu_air101.c

+ 3 - 0
app/main.c

@@ -139,6 +139,9 @@ void UserMain(void){
 #endif
 
 #ifdef __LUATOS__
+	extern void luat_mcu_tick64_init(void);
+	luat_mcu_tick64_init();
+	
 	tls_fls_read_unique_id(unique_id);
 	if (unique_id[1] == 0x10){
 		printf("I/main auth ok %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X %s\n",

+ 40 - 0
app/port/luat_mcu_air101.c

@@ -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");
+}