Преглед изворни кода

Merge branch 'master' of https://gitee.com/openLuat/LuatOS

alienwalker пре 2 година
родитељ
комит
94e94ab41b
3 измењених фајлова са 49 додато и 3 уклоњено
  1. 2 2
      components/iotauth/luat_lib_iotauth.c
  2. 42 0
      demo/max30102/main.lua
  3. 5 1
      luat/modules/luat_lib_gpio.c

+ 2 - 2
components/iotauth/luat_lib_iotauth.c

@@ -260,8 +260,8 @@ static int l_iotauth_onenet(lua_State *L) {
 }
 
 static void iotda_token(const char* device_id,const char* device_secret,long long cur_timestamp,int ins_timestamp,char* client_id,const char* password){
-    char hmac[64] = {0};
-    char timestamp[12] = {0};
+    char hmac[65] = {0};
+    char timestamp[13] = {0};
     struct tm *timeinfo = localtime( &cur_timestamp );
     if(snprintf_(timestamp, 12, "%04d%02d%02d%02d", (timeinfo->tm_year)+1900,timeinfo->tm_mon+1,timeinfo->tm_mday,timeinfo->tm_hour)<0){
         return;

+ 42 - 0
demo/max30102/main.lua

@@ -0,0 +1,42 @@
+-- LuaTools需要PROJECT和VERSION这两个信息
+PROJECT = "max30102demo"
+VERSION = "1.0.0"
+
+-- log.info("main", PROJECT, VERSION)
+
+-- 引入必要的库文件(lua编写), 内部库不需要require
+local sys = require "sys"
+
+-- sys.timerLoopStart(function ()
+--     log.info("mem.lua", rtos.meminfo())
+--     log.info("mem.sys", rtos.meminfo("sys"))
+-- end, 3000)
+
+
+_G.sysplus = require("sysplus")
+
+local i2cid = 0
+local i2c_speed = i2c.FAST
+sys.taskInit(function()
+    i2c.setup(i2cid,i2c_speed)
+    max30102.init(i2cid,pin.PC05)
+    -- max30102.get().wait()
+    -- max30102.shutdown()
+    while 1 do
+        local ret,HR,SpO2 = max30102.get().wait()
+        if ret then
+            log.info("max30102", HR,SpO2)
+        else
+            log.info("max30102", "false")
+        end
+        sys.wait(5000)
+    end
+end)
+
+
+
+
+-- 用户代码已结束---------------------------------------------
+-- 结尾总是这一句
+sys.run()
+-- sys.run()之后后面不要加任何语句!!!!!

+ 5 - 1
luat/modules/luat_lib_gpio.c

@@ -177,12 +177,16 @@ gpio.setup(17, 1, gpio.PULLUP)
 gpio.setup(27, function(val) print("IRQ_27",val) end, gpio.PULLUP)
 -- 设置gpio27为中断
 gpio.setup(27, function(val) print("IRQ_27",val) end, gpio.PULLUP)
+
+-- alt_func 于2023.7.2新增
 -- 设置AIR780E的PIN33复用成gpio18,方向输出,且初始化电平为低,使用硬件默认上下拉配置
 gpio.setup(18, 0, nil, nil, 4)
 */
 static int l_gpio_setup(lua_State *L) {
     luat_gpio_t conf;
-    luat_gpio_cfg_t cfg = {0};
+    luat_gpio_cfg_t cfg = {
+        .alt_fun = -1
+    };
     conf.pin = luaL_checkinteger(L, 1);
     //conf->mode = luaL_checkinteger(L, 2);
     conf.lua_ref = 0;