Ver código fonte

fix: pwm传入频率/周期为0会死机

https://gitee.com/openLuat/luatos-soc-air101/issues/I8ZNT5
Wendal Chen 2 anos atrás
pai
commit
b26de8acfb
1 arquivos alterados com 4 adições e 1 exclusões
  1. 4 1
      app/port/luat_pwm_air101.c

+ 4 - 1
app/port/luat_pwm_air101.c

@@ -69,7 +69,10 @@ int luat_pwm_setup(luat_pwm_conf_t* conf) {
 	size_t precision = conf->precision;
 
 	tls_sys_clk sysclk;
-
+	if (period == 0) {
+		LLOGW("period can't be 0");
+		return -1;
+	}
 	if (precision != 100 && precision != 256) {
 		LLOGW("only 100 or 256 PWM precision supported");
 		return -1;