You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@mynewt.apache.org by "wiktorkwiatkowski (via GitHub)" <gi...@apache.org> on 2026/02/02 10:08:16 UTC
[PR] test/automated: PWM duty cycle verification test using GPIO loopback [mynewt-core]
wiktorkwiatkowski opened a new pull request, #3568:
URL: https://github.com/apache/mynewt-core/pull/3568
Add test that verifies PWM duty cycle accuracy by sampling the
output pin via GPIO reads. The test uses a timer to sample GPIO state
and calculates measured duty cycle from high versus total samples.
Each test configures PWM duty, collects samples via timer callback,
and validates measured duty falls within tolerance.
Test **requires physical loopback** between PWM output and GPIO input pin.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test/automated: PWM duty cycle verification test using GPIO loopback [mynewt-core]
Posted by "sjanc (via GitHub)" <gi...@apache.org>.
sjanc commented on code in PR #3568:
URL: https://github.com/apache/mynewt-core/pull/3568#discussion_r3032976908
##########
test/mtest/mtest_pwm/src/main.c:
##########
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "bsp/bsp.h"
+#include "pwm/pwm.h"
+#include "hal/hal_gpio.h"
+#include "mtest_pwm/mtest_pwm.h"
+
+pwm_test_ctx test_ctx;
+
+void
+pwm_init()
+{
+ struct pwm_chan_cfg chan_conf = { .pin = PWM_TEST_CH_CFG_PIN,
+ .inverted = PWM_TEST_CH_CFG_INV,
+ .data = NULL };
+
+ test_ctx.pwm =
+ (struct pwm_dev *)os_dev_open(PWM_TEST_DEV, OS_TIMEOUT_NEVER, NULL);
+ MTEST_INIT_ASSERT(test_ctx.pwm != NULL, "device %s not available\n", PWM_TEST_DEV);
+ int rc = pwm_set_frequency(test_ctx.pwm, PWM_FREQ_HZ);
+ MTEST_INIT_ASSERT(rc > 0, "set frequency for pwm clock failed");
+
+ rc = pwm_configure_channel(test_ctx.pwm, PWM_TEST_CH_NUM, &chan_conf);
+ MTEST_INIT_ASSERT(rc == 0, "channel configuration failed");
+
+ rc = pwm_enable(test_ctx.pwm);
+ MTEST_INIT_ASSERT(rc == 0, "PWM enable");
+}
+
+void
+timer_cb()
Review Comment:
ditto
##########
test/mtest/mtest_pwm/src/main.c:
##########
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "sysinit/sysinit.h"
+#include "bsp/bsp.h"
+#include "pwm/pwm.h"
+#include "hal/hal_gpio.h"
+#include "mtest_pwm/mtest_pwm.h"
+
+pwm_test_ctx test_ctx;
+
+void
+pwm_init()
Review Comment:
should be pwm_init(void)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test/automated: PWM duty cycle verification test using GPIO loopback [mynewt-core]
Posted by "sjanc (via GitHub)" <gi...@apache.org>.
sjanc merged PR #3568:
URL: https://github.com/apache/mynewt-core/pull/3568
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org