Browse Source

fix:air780e直接设置GPIO14和GPIO15会死机

alienwalker 2 years ago
parent
commit
602abd3403
1 changed files with 5 additions and 3 deletions
  1. 5 3
      luat/modules/luat_lib_gpio.c

+ 5 - 3
luat/modules/luat_lib_gpio.c

@@ -184,9 +184,6 @@ gpio.setup(18, 0, nil, nil, 4)
 */
 static int l_gpio_setup(lua_State *L) {
     luat_gpio_t conf;
-    luat_gpio_cfg_t cfg = {
-        .alt_fun = -1
-    };
     conf.pin = luaL_checkinteger(L, 1);
     //conf->mode = luaL_checkinteger(L, 2);
     conf.lua_ref = 0;
@@ -209,6 +206,10 @@ static int l_gpio_setup(lua_State *L) {
     if (lua_isinteger(L, 5)) {
         conf.alt_func = luaL_checkinteger(L, 5);
     }
+    else
+    {
+    	conf.alt_func = -1;
+    }
     int re = luat_gpio_setup(&conf);
     if (re != 0) {
         LLOGW("gpio setup fail pin=%d", conf.pin);
@@ -509,6 +510,7 @@ void luat_gpio_mode(int pin, int mode, int pull, int initOutput) {
     conf.irq = initOutput;
     conf.lua_ref = 0;
     conf.irq_cb = 0;
+    conf.alt_func = -1;
     luat_gpio_setup(&conf);
     if (conf.mode == Luat_GPIO_OUTPUT)
         luat_gpio_set(pin, initOutput);