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

add:软件i2c添加强引用

Dozingfiretruck пре 9 месеци
родитељ
комит
42ab29a2a4
2 измењених фајлова са 3 додато и 0 уклоњено
  1. 2 0
      components/tp/luat_lib_tp.c
  2. 1 0
      luat/include/luat_i2c.h

+ 2 - 0
components/tp/luat_lib_tp.c

@@ -157,6 +157,8 @@ static int l_tp_init(lua_State* L){
         luat_tp_config->i2c_id = luaL_checkinteger(L, -1);
     }else if(LUA_TUSERDATA == port){
         luat_tp_config->soft_i2c = (luat_ei2c_t*)lua_touserdata(L, -1);
+        lua_pushvalue(L, -1);
+        luat_tp_config->soft_i2c->ei2c_ref = luaL_ref(L, LUA_REGISTRYINDEX);
     }else{
         LLOGE("port type error!!!");
         return 0;

+ 1 - 0
luat/include/luat_i2c.h

@@ -152,6 +152,7 @@ typedef struct luat_ei2c {
     int8_t sda;
     int8_t scl;
     int16_t udelay;
+    int ei2c_ref;
 } luat_ei2c_t;//软件i2c
 
 int i2c_soft_setup(luat_ei2c_t *ei2c);