Просмотр исходного кода

update: luavm加载完内部库之后,打印一下内存占用
update: sensor库变成平台无关
update: 抽象luat_timer_us_delay方法

Wendal Chen 5 лет назад
Родитель
Сommit
78262e4b11
4 измененных файлов с 20 добавлено и 13 удалено
  1. 2 0
      luat/include/luat_base.h
  2. 1 6
      luat/modules/luat_lib_sensor.c
  3. 6 0
      luat/modules/luat_main.c
  4. 11 7
      luat/rtt/luat_rtt_base.c

+ 2 - 0
luat/include/luat_base.h

@@ -104,4 +104,6 @@ const char* luat_os_bsp(void);
 /** 停止启动,当前仅rt-thread实现有这个设置*/
 void stopboot(void);
 
+void luat_timer_us_delay(size_t us);
+
 #endif

+ 1 - 6
luat/rtt/luat_lib_sensor.c → luat/modules/luat_lib_sensor.c

@@ -9,9 +9,6 @@
 #include "luat_log.h"
 #include "luat_timer.h"
 #include "luat_malloc.h"
-#include "rtthread.h"
-#include "rthw.h"
-#include <rtdevice.h>
 #include "luat_gpio.h"
 
 #define CONNECT_SUCCESS  0
@@ -19,9 +16,7 @@
 
 #define W1_INPUT_MODE PIN_MODE_INPUT_PULLUP
 
-RT_WEAK void luat_timer_us_delay(size_t us) {
-    rt_hw_us_delay(us);
-}
+
 
 static void w1_reset(int pin)
 {

+ 6 - 0
luat/modules/luat_main.c

@@ -36,6 +36,12 @@ static int pmain(lua_State *L) {
     luat_openlibs(L);
     //print_list_mem("begin> luat_openlibs");
 
+    size_t total; size_t used; size_t max_used;
+    luat_meminfo_luavm(&total, &used, &max_used);
+    LLOGD("luavm %ld %ld %ld", total, used, max_used);
+    luat_meminfo_sys(&total, &used, &max_used);
+    LLOGD("sys   %ld %ld %ld", total, used, max_used);
+
     lua_gc(L, LUA_GCSETPAUSE, 90); // 设置`垃圾收集器间歇率`要低于100%
     
     // 加载main.lua

+ 11 - 7
luat/rtt/luat_rtt_base.c

@@ -22,14 +22,18 @@
 //     return n;
 // }
 
-// 打印内存状态
-void print_list_mem(const char* name) {
-    #if (DBG_LVL <= DBG_DEBUG)
-    LOG_I("check memory status, key=%s", name);
-    list_mem();
-    #endif
+RT_WEAK void luat_timer_us_delay(size_t us) {
+    rt_hw_us_delay(us);
 }
 
+// 打印内存状态
+// void print_list_mem(const char* name) {
+//     #if (DBG_LVL <= DBG_DEBUG)
+//     LOG_I("check memory status, key=%s", name);
+//     list_mem();
+//     #endif
+// }
+
 // fix for mled加密库
 // rtt的方法名称变了. rt_hwcrypto_dev_dufault --> rt_hwcrypto_dev_default
 #ifdef RT_USING_HWCRYPTO
@@ -95,7 +99,7 @@ static const luaL_Reg loadedlibs[] = {
 void luat_openlibs(lua_State *L) {
     // 初始化队列服务
     luat_msgbus_init();
-    print_list_mem("done>luat_msgbus_init");
+    //print_list_mem("done>luat_msgbus_init");
     // 加载系统库
     const luaL_Reg *lib;
     /* "require" functions from 'loadedlibs' and set results to global table */