This is an automated email from the ASF dual-hosted git repository.
janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new c88e6d05a test/mtest: Add LED GPIO loopback test application
c88e6d05a is described below
commit c88e6d05a2eb511c93cdd284d8d258bb8358683c
Author: Wiktor Kwiatkowski <[email protected]>
AuthorDate: Tue Mar 17 17:58:55 2026 +0100
test/mtest: Add LED GPIO loopback test application
This test verifies GPIO functionality by writing to LED_BLINK_PIN
and checking the state on LED_READ_PIN.
Test requires a physical loopback connection between
LED_BLINK_PIN and LED_READ_PIN.
---
.../include/mtest_blinky/mtest_blinky.h | 36 ++++++++++++
test/mtest/mtest_blinky/pkg.yml | 32 +++++++++++
test/mtest/mtest_blinky/src/blinky_test_cases.c | 67 ++++++++++++++++++++++
test/mtest/mtest_blinky/src/main.c | 67 ++++++++++++++++++++++
test/mtest/mtest_blinky/syscfg.yml | 22 +++++++
5 files changed, 224 insertions(+)
diff --git a/test/mtest/mtest_blinky/include/mtest_blinky/mtest_blinky.h
b/test/mtest/mtest_blinky/include/mtest_blinky/mtest_blinky.h
new file mode 100644
index 000000000..a4ddd1142
--- /dev/null
+++ b/test/mtest/mtest_blinky/include/mtest_blinky/mtest_blinky.h
@@ -0,0 +1,36 @@
+/**
+ * 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.
+ */
+
+#ifndef MTEST_BLINKY_H
+#define MTEST_BLINKY_H
+#include "mtest/mtest.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+MTEST_CASE_DECL(blinky_test_case_1);
+MTEST_CASE_DECL(blinky_test_case_2);
+MTEST_CASE_DECL(blinky_test_case_3);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/test/mtest/mtest_blinky/pkg.yml b/test/mtest/mtest_blinky/pkg.yml
new file mode 100644
index 000000000..4fce22743
--- /dev/null
+++ b/test/mtest/mtest_blinky/pkg.yml
@@ -0,0 +1,32 @@
+#
+# 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.
+#
+
+pkg.name: test/mtest/mtest_blinky
+pkg.type: app
+pkg.description: GPIO loopback test using LED output and input pin.
+pkg.author: "Apache Mynewt <[email protected]>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+
+pkg.deps:
+ - "@apache-mynewt-core/kernel/os"
+ - "@apache-mynewt-core/hw/hal"
+ - "@apache-mynewt-core/sys/console"
+ - "@apache-mynewt-core/sys/log"
+ - "@apache-mynewt-core/test/mtest/mtest"
diff --git a/test/mtest/mtest_blinky/src/blinky_test_cases.c
b/test/mtest/mtest_blinky/src/blinky_test_cases.c
new file mode 100644
index 000000000..2714337b1
--- /dev/null
+++ b/test/mtest/mtest_blinky/src/blinky_test_cases.c
@@ -0,0 +1,67 @@
+/**
+ * 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 "bsp/bsp.h"
+#include "hal/hal_gpio.h"
+#include "mtest_blinky/mtest_blinky.h"
+
+MTEST_CASE(blinky_test_case_1)
+{
+ int state;
+
+ hal_gpio_write(LED_BLINK_PIN, 1);
+
+ os_time_delay(OS_TICKS_PER_SEC / 10);
+
+ state = hal_gpio_read(MYNEWT_VAL(LED_READ_PIN));
+
+ MTEST_CASE_ASSERT(state == 1, "GPIO loopback HIGH failed");
+}
+
+MTEST_CASE(blinky_test_case_2)
+{
+ int state;
+
+ hal_gpio_write(LED_BLINK_PIN, 0);
+
+ os_time_delay(OS_TICKS_PER_SEC / 10);
+
+ state = hal_gpio_read(MYNEWT_VAL(LED_READ_PIN));
+
+ MTEST_CASE_ASSERT(state == 0, "GPIO loopback LOW failed");
+}
+
+MTEST_CASE(blinky_test_case_3)
+{
+ int out = 0;
+
+ for (int i = 0; i < 10; i++) {
+
+ int in;
+ out = !out;
+
+ hal_gpio_write(LED_BLINK_PIN, out);
+
+ os_time_delay(OS_TICKS_PER_SEC / 10);
+
+ in = hal_gpio_read(MYNEWT_VAL(LED_READ_PIN));
+
+ MTEST_CASE_ASSERT(in == out, "GPIO loopback toggle failed");
+ }
+}
diff --git a/test/mtest/mtest_blinky/src/main.c
b/test/mtest/mtest_blinky/src/main.c
new file mode 100644
index 000000000..5275e5fc2
--- /dev/null
+++ b/test/mtest/mtest_blinky/src/main.c
@@ -0,0 +1,67 @@
+/**
+ * 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 "os/os.h"
+#include "bsp/bsp.h"
+#include "hal/hal_gpio.h"
+#include "mtest_blinky/mtest_blinky.h"
+
+MTEST_INIT(blinky_test)
+{
+ int rc;
+
+ rc = hal_gpio_init_out(LED_BLINK_PIN, 0);
+ MTEST_INIT_ASSERT(rc == 0, "GPIO output init failed");
+
+ rc = hal_gpio_init_in(MYNEWT_VAL(LED_READ_PIN), HAL_GPIO_PULL_DOWN);
+ MTEST_INIT_ASSERT(rc == 0, "GPIO input init failed");
+}
+
+MTEST_CLEANUP(blinky_test)
+{
+ int rc;
+
+ rc = hal_gpio_deinit(LED_BLINK_PIN);
+ MTEST_CLEANUP_ASSERT(rc == 0, "GPIO output deinit failed");
+
+ rc = hal_gpio_deinit(MYNEWT_VAL(LED_READ_PIN));
+ MTEST_CLEANUP_ASSERT(rc == 0, "GPIO input deinit failed");
+}
+
+MTEST_SUITE(blinky_test)
+{
+ MTEST_RUN_INIT(blinky_test);
+ blinky_test_case_1();
+ blinky_test_case_2();
+ blinky_test_case_3();
+ MTEST_RUN_CLEANUP(blinky_test);
+}
+
+int
+mynewt_main(int argc, char **argv)
+{
+ sysinit();
+
+ blinky_test();
+
+ while (1) {
+ os_time_delay(OS_TICKS_PER_SEC);
+ }
+}
diff --git a/test/mtest/mtest_blinky/syscfg.yml
b/test/mtest/mtest_blinky/syscfg.yml
new file mode 100644
index 000000000..150d20c3d
--- /dev/null
+++ b/test/mtest/mtest_blinky/syscfg.yml
@@ -0,0 +1,22 @@
+#
+# 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.
+#
+syscfg.defs:
+ LED_READ_PIN:
+ description: Number of pin reading LED state.
+ value: ARDUINO_PIN_D7