소스 검색

fix:pwm新API运行异常

alienwalker 3 달 전
부모
커밋
655e87cc8a
1개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 6 3
      luat/modules/luat_lib_pwm.c

+ 6 - 3
luat/modules/luat_lib_pwm.c

@@ -173,7 +173,8 @@ static int l_pwm_start(lua_State *L) {
     if (channel < 0) {
         return 0;
     }
-    int ret = luat_pwm_setup(confs[channel]);
+    luat_pwm_conf_t conf = *confs[channel];
+    int ret = luat_pwm_setup(&conf);
     lua_pushboolean(L, ret == 0 ? 1 : 0);
     return 1;
 }
@@ -215,7 +216,8 @@ static int l_pwm_set_duty(lua_State *L) {
         return 0;
     }
     confs[channel]->pulse = luaL_checkinteger(L, 2);
-    int ret = luat_pwm_setup(confs[channel]);
+    luat_pwm_conf_t conf = *confs[channel];
+    int ret = luat_pwm_setup(&conf);
     lua_pushboolean(L, ret == 0 ? 1 : 0);
     return 1;
 }
@@ -236,7 +238,8 @@ static int l_pwm_set_freq(lua_State *L) {
         return 0;
     }
     confs[channel]->period = luaL_checkinteger(L, 2);
-    int ret = luat_pwm_setup(confs[channel]);
+    luat_pwm_conf_t conf = *confs[channel];
+    int ret = luat_pwm_setup(&conf);
     lua_pushboolean(L, ret == 0 ? 1 : 0);
     return 1;
 }