From c6a414bed016430dc932db8cd576f2a326689cb0 Mon Sep 17 00:00:00 2001 From: Jakub Zymelka Date: Tue, 15 Oct 2024 15:30:24 +0200 Subject: [PATCH] tests: drivers: gpio: Add loopback test for eGPIO SDP Added a loopback test for the software-defined eGPIO peripheral. The test verifies proper operation of the eGPIO output by using a different processor hardware GPIO input pin. Signed-off-by: Jakub Zymelka --- .github/test-spec.yml | 1 + CODEOWNERS | 1 + scripts/ci/tags.yaml | 9 + .../gpio/egpio_basic_api/CMakeLists.txt | 12 + tests/drivers/gpio/egpio_basic_api/README.txt | 18 + .../boards/nrf54l15dk_nrf54l15_cpuapp.overlay | 21 + .../dts/bindings/test-egpio.yaml | 27 + tests/drivers/gpio/egpio_basic_api/prj.conf | 2 + .../gpio/egpio_basic_api/src/test_egpio.h | 56 ++ .../egpio_basic_api/src/test_egpio_port.c | 482 ++++++++++++++++++ .../gpio/egpio_basic_api/sysbuild.conf | 3 + .../gpio/egpio_basic_api/testcase.yaml | 28 + 12 files changed, 660 insertions(+) create mode 100644 tests/drivers/gpio/egpio_basic_api/CMakeLists.txt create mode 100644 tests/drivers/gpio/egpio_basic_api/README.txt create mode 100644 tests/drivers/gpio/egpio_basic_api/boards/nrf54l15dk_nrf54l15_cpuapp.overlay create mode 100644 tests/drivers/gpio/egpio_basic_api/dts/bindings/test-egpio.yaml create mode 100644 tests/drivers/gpio/egpio_basic_api/prj.conf create mode 100644 tests/drivers/gpio/egpio_basic_api/src/test_egpio.h create mode 100644 tests/drivers/gpio/egpio_basic_api/src/test_egpio_port.c create mode 100644 tests/drivers/gpio/egpio_basic_api/sysbuild.conf create mode 100644 tests/drivers/gpio/egpio_basic_api/testcase.yaml diff --git a/.github/test-spec.yml b/.github/test-spec.yml index 7267583c3db0..defe5414dff7 100644 --- a/.github/test-spec.yml +++ b/.github/test-spec.yml @@ -592,6 +592,7 @@ - "snippets/emulated-*/**/*" - "tests/subsys/event_manager_proxy/**/*" - "tests/benchmarks/multicore/idle/**/*" + - "tests/drivers/gpio/egpio_basic_api/**/*" - "tests/drivers/pwm/**/*" - "tests/drivers/sensor/**/*" diff --git a/CODEOWNERS b/CODEOWNERS index 5c3612177014..92de503941cd 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -383,6 +383,7 @@ /tests/bluetooth/iso/ @nrfconnect/ncs-audio @Frodevan /tests/bluetooth/tester/ @carlescufi @nrfconnect/ncs-paladin /tests/crypto/ @stephen-nordic @magnev +/tests/drivers/gpio/egpio_basic_api/ @nrfconnect/ncs-ll-ursus /tests/drivers/flash/flash_rpc/ @nrfconnect/ncs-pluto /tests/drivers/flash_patch/ @nrfconnect/ncs-pluto /tests/drivers/fprotect/ @nrfconnect/ncs-pluto diff --git a/scripts/ci/tags.yaml b/scripts/ci/tags.yaml index e7f9503b0508..cef5362d9885 100644 --- a/scripts/ci/tags.yaml +++ b/scripts/ci/tags.yaml @@ -1261,6 +1261,15 @@ ci_tests_benchmarks_current_consumption: - zephyr/drivers/counter/ - zephyr/soc/nordic/ +ci_tests_drivers_egpio: + files: + - nrf/applications/sdp/gpio/ + - nrf/drivers/gpio/ + - nrf/snippets/emulated-gpio/ + - nrf/tests/drivers/gpio/egpio_basic_api/ + - zephyr/drivers/mbox/ + - zephyr/subsys/ipc/ipc_service/ + ci_tests_drivers_fprotect: files: - nrf/lib/fprotect/ diff --git a/tests/drivers/gpio/egpio_basic_api/CMakeLists.txt b/tests/drivers/gpio/egpio_basic_api/CMakeLists.txt new file mode 100644 index 000000000000..a89186ec9ca3 --- /dev/null +++ b/tests/drivers/gpio/egpio_basic_api/CMakeLists.txt @@ -0,0 +1,12 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(egpio_basic_api) + +FILE(GLOB app_sources src/test*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/drivers/gpio/egpio_basic_api/README.txt b/tests/drivers/gpio/egpio_basic_api/README.txt new file mode 100644 index 000000000000..ca7a86d0c003 --- /dev/null +++ b/tests/drivers/gpio/egpio_basic_api/README.txt @@ -0,0 +1,18 @@ +eGPIO 2-Pin Test +############### + +This application tests the eGPIO subsystem using a hardware configuration +where two GPIOs are directly wired together. The test pins are +identified through a test-specific devicetree binding in the `dts/` +subdirectory, implemented for specific boards by overlay files in the +`boards/` directory. + +Only boards for which an overlay is present can pass this test. Boards +without an overlay, or for which the required wiring is not provided, +will fail with an error like this: + + Validate device GPIO_0 + Check egpio output 10 connected to GPIO_1 input 14 + FATAL output pin not wired to input pin? (out high => in low) + +No special build options are required to make use of the overlay. diff --git a/tests/drivers/gpio/egpio_basic_api/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/tests/drivers/gpio/egpio_basic_api/boards/nrf54l15dk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..539bbadfd637 --- /dev/null +++ b/tests/drivers/gpio/egpio_basic_api/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + resources { + compatible = "test-egpio"; + out-gpios = <&egpio 10 0>; + in-gpios = <&gpio1 14 0>; + }; +}; + +&gpiote20 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; diff --git a/tests/drivers/gpio/egpio_basic_api/dts/bindings/test-egpio.yaml b/tests/drivers/gpio/egpio_basic_api/dts/bindings/test-egpio.yaml new file mode 100644 index 000000000000..98e50baffdef --- /dev/null +++ b/tests/drivers/gpio/egpio_basic_api/dts/bindings/test-egpio.yaml @@ -0,0 +1,27 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +description: | + This binding provides resources required to build and run the + tests/drivers/gpio/egpio_basic_api test in Zephyr. + +compatible: "test-egpio" + +properties: + out-gpios: + type: phandle-array + required: true + description: | + Identity of an eGPIO that will be configured as an output. + This must be on the GPIO instance to which FLPR has access, + and physically connected to in-gpios. + + in-gpios: + type: phandle-array + required: true + description: | + Identity of a hardware GPIO that will be configured as an input. + This must be physically connected to out-gpios. diff --git a/tests/drivers/gpio/egpio_basic_api/prj.conf b/tests/drivers/gpio/egpio_basic_api/prj.conf new file mode 100644 index 000000000000..19b08c690ec6 --- /dev/null +++ b/tests/drivers/gpio/egpio_basic_api/prj.conf @@ -0,0 +1,2 @@ +CONFIG_GPIO=y +CONFIG_ZTEST=y diff --git a/tests/drivers/gpio/egpio_basic_api/src/test_egpio.h b/tests/drivers/gpio/egpio_basic_api/src/test_egpio.h new file mode 100644 index 000000000000..c35700bd6c50 --- /dev/null +++ b/tests/drivers/gpio/egpio_basic_api/src/test_egpio.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#ifndef __TEST_EGPIO_H__ +#define __TEST_EGPIO_H__ + +#include +#include +#include +#include + +#if DT_NODE_HAS_STATUS(DT_INST(0, test_egpio), okay) + +/* Execution of the test requires hardware configuration described in + * devicetree. See the test, egpio_basic_api binding local to this test + * for details. + */ +#define DEV_OUT DT_GPIO_CTLR(DT_INST(0, test_egpio), out_gpios) +#define DEV_IN DT_GPIO_CTLR(DT_INST(0, test_egpio), in_gpios) +#define DEV DEV_OUT +#define PIN_OUT DT_GPIO_PIN(DT_INST(0, test_egpio), out_gpios) +#define PIN_OUT_FLAGS DT_GPIO_FLAGS(DT_INST(0, test_egpio), out_gpios) +#define PIN_IN DT_GPIO_PIN(DT_INST(0, test_egpio), in_gpios) +#define PIN_IN_FLAGS DT_GPIO_FLAGS(DT_INST(0, test_egpio), in_gpios) +#else +#error Unsupported board +#endif + +#ifndef PIN_OUT +/* For build-only testing use fixed pins. */ +#define PIN_OUT 10 +#define PIN_IN 14 +#endif + +#define MAX_INT_CNT 3 +struct drv_data { + struct gpio_callback gpio_cb; + gpio_flags_t mode; + int index; + int aux; +}; + +void test_egpio_pin_read_write(void); +void test_egpio_callback_add_remove(void); +void test_egpio_callback_self_remove(void); +void test_egpio_callback_enable_disable(void); +void test_egpio_callback_variants(void); + +void test_egpio_port(void); + +void test_egpio_deprecated(void); + +#endif /* __TEST_EGPIO_H__ */ diff --git a/tests/drivers/gpio/egpio_basic_api/src/test_egpio_port.c b/tests/drivers/gpio/egpio_basic_api/src/test_egpio_port.c new file mode 100644 index 000000000000..28f8015058b5 --- /dev/null +++ b/tests/drivers/gpio/egpio_basic_api/src/test_egpio_port.c @@ -0,0 +1,482 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + + +#include "test_egpio.h" + +#define ALL_BITS ((gpio_port_value_t)-1) + +static const struct device *const dev_out = DEVICE_DT_GET(DEV_OUT); +static const struct device *const dev_in = DEVICE_DT_GET(DEV_IN); + +/* Delay after pull input config to allow signal to settle. The value + * selected is conservative (higher than may be necessary). + */ +#define PULL_DELAY_US 1000U + +/* Short-hand for a checked read of PIN_IN raw state */ +static bool raw_in(void) +{ + k_busy_wait(PULL_DELAY_US); + gpio_port_value_t v; + int rc = gpio_port_get_raw(dev_in, &v); + + zassert_equal(rc, 0, + "raw_in failed"); + return (v & BIT(PIN_IN)) ? true : false; +} + +/* Short-hand for a checked write of PIN_OUT raw state */ +static void raw_out(bool set) +{ + int rc; + + if (set) { + rc = gpio_port_set_bits_raw(dev_out, BIT(PIN_OUT)); + } else { + rc = gpio_port_clear_bits_raw(dev_out, BIT(PIN_OUT)); + } + zassert_equal(rc, 0, + "raw_out failed"); + k_busy_wait(PULL_DELAY_US); +} + +/* Short-hand for a checked write of PIN_OUT logic state */ +static void logic_out(bool set) +{ + int rc; + + if (set) { + rc = gpio_port_set_bits(dev_out, BIT(PIN_OUT)); + } else { + rc = gpio_port_clear_bits(dev_out, BIT(PIN_OUT)); + } + zassert_equal(rc, 0, + "raw_out failed"); + k_busy_wait(PULL_DELAY_US); +} + +/* Verify device, configure for physical in and out, verify + * connection, verify raw_in(). + */ +static int setup(void) +{ + int rc; + gpio_port_value_t v1; + + TC_PRINT("Validate device %s\n", dev_out->name); + zassert_true(device_is_ready(dev_out), "GPIO dev_out is not ready"); + + TC_PRINT("Validate device %s\n", dev_in->name); + zassert_true(device_is_ready(dev_in), "GPIO dev_out is not ready"); + + TC_PRINT("Check e%s output %d connected to %s input %d\n", dev_out->name, + PIN_OUT, dev_in->name, PIN_IN); + + rc = gpio_pin_configure(dev_in, PIN_IN, GPIO_INPUT); + zassert_equal(rc, 0, + "pin config input failed"); + + /* Test output low */ + rc = gpio_pin_configure(dev_out, PIN_OUT, GPIO_OUTPUT_LOW); + zassert_equal(rc, 0, + "pin config output low failed"); + + k_busy_wait(PULL_DELAY_US); + + rc = gpio_port_get_raw(dev_in, &v1); + zassert_equal(rc, 0, + "get raw low failed"); + if (raw_in() != false) { + TC_PRINT("FATAL output pin not wired to input pin? (out low => in high)\n"); + while (true) { + k_sleep(K_FOREVER); + } + } + + zassert_equal(v1 & BIT(PIN_IN), 0, + "out low does not read low"); + + /* Disconnect output */ + rc = gpio_pin_configure(dev_out, PIN_OUT, GPIO_DISCONNECTED); + if (rc == -ENOTSUP) { + TC_PRINT("NOTE: cannot configure pin as disconnected; trying as input\n"); + rc = gpio_pin_configure(dev_out, PIN_OUT, GPIO_INPUT); + } + zassert_equal(rc, 0, + "output disconnect failed"); + + /* Test output high */ + rc = gpio_pin_configure(dev_out, PIN_OUT, GPIO_OUTPUT_HIGH); + zassert_equal(rc, 0, + "pin config output high failed"); + + k_busy_wait(PULL_DELAY_US); + + rc = gpio_port_get_raw(dev_in, &v1); + zassert_equal(rc, 0, + "get raw high failed"); + if (raw_in() != true) { + TC_PRINT("FATAL output pin not wired to input pin? (out high => in low)\n"); + while (true) { + k_sleep(K_FOREVER); + } + } + zassert_not_equal(v1 & BIT(PIN_IN), 0, + "out high does not read low"); + + TC_PRINT("OUT %d to IN %d linkage works\n", PIN_OUT, PIN_IN); + return TC_PASS; +} + +/* gpio_port_set_bits_raw() + * gpio_port_clear_bits_raw() + * gpio_port_set_masked_raw() + * gpio_port_toggle_bits() + */ +static int bits_physical(void) +{ + int rc; + + TC_PRINT("- %s\n", __func__); + + /* port_set_bits_raw */ + rc = gpio_port_set_bits_raw(dev_out, BIT(PIN_OUT)); + zassert_equal(rc, 0, + "port set raw out failed"); + zassert_equal(raw_in(), true, + "raw set mismatch"); + + /* port_clear_bits_raw */ + rc = gpio_port_clear_bits_raw(dev_out, BIT(PIN_OUT)); + zassert_equal(rc, 0, + "port clear raw out failed"); + zassert_equal(raw_in(), false, + "raw clear mismatch"); + + /* set after clear changes */ + rc = gpio_port_set_bits_raw(dev_out, BIT(PIN_OUT)); + zassert_equal(rc, 0, + "port set raw out failed"); + zassert_equal(raw_in(), true, + "raw set mismatch"); + + /* raw_out() after set works */ + raw_out(false); + zassert_equal(raw_in(), false, + "raw_out() false mismatch"); + + /* raw_out() set after raw_out() clear works */ + raw_out(true); + zassert_equal(raw_in(), true, + "raw_out() true mismatch"); + + rc = gpio_port_set_masked_raw(dev_out, BIT(PIN_OUT), 0); + zassert_equal(rc, 0, + "set_masked_raw low failed"); + zassert_equal(raw_in(), false, + "set_masked_raw low mismatch"); + + rc = gpio_port_set_masked_raw(dev_out, BIT(PIN_OUT), ALL_BITS); + zassert_equal(rc, 0, + "set_masked_raw high failed"); + zassert_equal(raw_in(), true, + "set_masked_raw high mismatch"); + + rc = gpio_port_set_clr_bits_raw(dev_out, 0, BIT(PIN_OUT)); + zassert_equal(rc, 0, + "clear out failed"); + zassert_equal(raw_in(), false, + "clear out mismatch"); + + rc = gpio_port_set_clr_bits_raw(dev_out, BIT(PIN_OUT), 0); + zassert_equal(rc, 0, + "set out failed"); + zassert_equal(raw_in(), true, + "set out mismatch"); + + /* Conditionally verify that behavior with __ASSERT disabled + * is to set the bit. + */ + if (false) { + /* preserve set */ + rc = gpio_port_set_clr_bits_raw(dev_out, BIT(PIN_OUT), BIT(PIN_OUT)); + zassert_equal(rc, 0, + "s/c dup set failed"); + zassert_equal(raw_in(), true, + "s/c dup set mismatch"); + + /* do set */ + raw_out(false); + rc = gpio_port_set_clr_bits_raw(dev_out, BIT(PIN_OUT), BIT(PIN_OUT)); + zassert_equal(rc, 0, + "s/c dup2 set failed"); + zassert_equal(raw_in(), true, + "s/c dup2 set mismatch"); + } + + rc = gpio_port_toggle_bits(dev_out, BIT(PIN_OUT)); + zassert_equal(rc, 0, + "toggle_bits high-to-low failed"); + zassert_equal(raw_in(), false, + "toggle_bits high-to-low mismatch"); + + rc = gpio_port_toggle_bits(dev_out, BIT(PIN_OUT)); + zassert_equal(rc, 0, + "toggle_bits low-to-high failed"); + zassert_equal(raw_in(), true, + "toggle_bits low-to-high mismatch"); + + return TC_PASS; +} + +/* gpio_pin_get_raw() + * gpio_pin_set_raw() + */ +static int pin_physical(void) +{ + int rc; + + TC_PRINT("- %s\n", __func__); + + raw_out(true); + zassert_equal(gpio_pin_get_raw(dev_in, PIN_IN), raw_in(), + "pin_get_raw high failed"); + + raw_out(false); + zassert_equal(gpio_pin_get_raw(dev_in, PIN_IN), raw_in(), + "pin_get_raw low failed"); + + rc = gpio_pin_set_raw(dev_out, PIN_OUT, 32); + zassert_equal(rc, 0, + "pin_set_raw high failed"); + zassert_equal(raw_in(), true, + "pin_set_raw high failed"); + + rc = gpio_pin_set_raw(dev_out, PIN_OUT, 0); + zassert_equal(rc, 0, + "pin_set_raw low failed"); + zassert_equal(raw_in(), false, + "pin_set_raw low failed"); + + rc = gpio_pin_toggle(dev_out, PIN_OUT); + zassert_equal(rc, 0, + "pin_toggle low-to-high failed"); + zassert_equal(raw_in(), true, + "pin_toggle low-to-high mismatch"); + + rc = gpio_pin_toggle(dev_out, PIN_OUT); + zassert_equal(rc, 0, + "pin_toggle high-to-low failed"); + zassert_equal(raw_in(), false, + "pin_toggle high-to-low mismatch"); + + return TC_PASS; +} + +/* Verify configure output level is independent of active level, and + * raw output is independent of active level. + */ +static int check_raw_output_levels(void) +{ + int rc; + + TC_PRINT("- %s\n", __func__); + + rc = gpio_pin_configure(dev_out, PIN_OUT, + GPIO_ACTIVE_HIGH | GPIO_OUTPUT_LOW); + zassert_equal(rc, 0, + "active high output low failed"); + zassert_equal(raw_in(), false, + "active high output low raw mismatch"); + raw_out(true); + zassert_equal(raw_in(), true, + "set high mismatch"); + + rc = gpio_pin_configure(dev_out, PIN_OUT, + GPIO_ACTIVE_HIGH | GPIO_OUTPUT_HIGH); + zassert_equal(rc, 0, + "active high output high failed"); + zassert_equal(raw_in(), true, + "active high output high raw mismatch"); + raw_out(false); + zassert_equal(raw_in(), false, + "set low mismatch"); + + rc = gpio_pin_configure(dev_out, PIN_OUT, + GPIO_ACTIVE_LOW | GPIO_OUTPUT_LOW); + zassert_equal(rc, 0, + "active low output low failed"); + zassert_equal(raw_in(), false, + "active low output low raw mismatch"); + raw_out(true); + zassert_equal(raw_in(), true, + "set high mismatch"); + + rc = gpio_pin_configure(dev_out, PIN_OUT, + GPIO_ACTIVE_LOW | GPIO_OUTPUT_HIGH); + zassert_equal(rc, 0, + "active low output high failed"); + zassert_equal(raw_in(), true, + "active low output high raw mismatch"); + raw_out(false); + zassert_equal(raw_in(), false, + "set low mismatch"); + + return TC_PASS; +} + +/* Verify configure output level is dependent on active level, and + * logic output is dependent on active level. + */ +static int check_logic_output_levels(void) +{ + int rc; + + TC_PRINT("- %s\n", __func__); + + rc = gpio_pin_configure(dev_out, PIN_OUT, + GPIO_ACTIVE_HIGH | GPIO_OUTPUT_INACTIVE); + zassert_equal(rc, 0, + "active true output false failed: %d", rc); + zassert_equal(raw_in(), false, + "active true output false logic mismatch"); + logic_out(true); + zassert_equal(raw_in(), true, + "set true mismatch"); + + rc = gpio_pin_configure(dev_out, PIN_OUT, + GPIO_ACTIVE_HIGH | GPIO_OUTPUT_ACTIVE); + zassert_equal(rc, 0, + "active true output true failed"); + zassert_equal(raw_in(), true, + "active true output true logic mismatch"); + logic_out(false); + zassert_equal(raw_in(), false, + "set false mismatch"); + + rc = gpio_pin_configure(dev_out, PIN_OUT, + GPIO_ACTIVE_LOW | GPIO_OUTPUT_ACTIVE); + zassert_equal(rc, 0, + "active low output true failed"); + + zassert_equal(raw_in(), false, + "active low output true raw mismatch"); + logic_out(false); + zassert_equal(raw_in(), true, + "set false mismatch"); + + rc = gpio_pin_configure(dev_out, PIN_OUT, + GPIO_ACTIVE_LOW | GPIO_OUTPUT_INACTIVE); + zassert_equal(rc, 0, + "active low output false failed"); + zassert_equal(raw_in(), true, + "active low output false logic mismatch"); + logic_out(true); + zassert_equal(raw_in(), false, + "set true mismatch"); + + return TC_PASS; +} + +/* gpio_port_set_bits() + * gpio_port_clear_bits() + * gpio_port_set_masked() + * gpio_port_toggle_bits() + */ +static int bits_logical(void) +{ + int rc; + + TC_PRINT("- %s\n", __func__); + + rc = gpio_pin_configure(dev_out, PIN_OUT, + GPIO_OUTPUT_HIGH | GPIO_ACTIVE_LOW); + zassert_equal(rc, 0, + "output configure failed"); + zassert_equal(raw_in(), true, + "raw out high mismatch"); + + /* port_set_bits */ + rc = gpio_port_set_bits(dev_out, BIT(PIN_OUT)); + zassert_equal(rc, 0, + "port set raw out failed"); + zassert_equal(raw_in(), false, + "raw low set mismatch"); + + /* port_clear_bits */ + rc = gpio_port_clear_bits(dev_out, BIT(PIN_OUT)); + zassert_equal(rc, 0, + "port clear raw out failed"); + zassert_equal(raw_in(), true, + "raw low clear mismatch"); + + /* set after clear changes */ + rc = gpio_port_set_bits_raw(dev_out, BIT(PIN_OUT)); + zassert_equal(rc, 0, + "port set raw out failed"); + zassert_equal(raw_in(), true, + "raw set mismatch"); + + /* Conditionally verify that behavior with __ASSERT disabled + * is to set the bit. + */ + if (false) { + /* preserve set */ + rc = gpio_port_set_clr_bits(dev_out, BIT(PIN_OUT), BIT(PIN_OUT)); + zassert_equal(rc, 0, + "s/c set toggle failed"); + zassert_equal(raw_in(), false, + "s/c set toggle mismatch"); + + /* force set */ + raw_out(true); + rc = gpio_port_set_clr_bits(dev_out, BIT(PIN_OUT), BIT(PIN_OUT)); + zassert_equal(rc, 0, + "s/c dup set failed"); + zassert_equal(raw_in(), false, + "s/c dup set mismatch"); + } + + rc = gpio_port_toggle_bits(dev_out, BIT(PIN_OUT)); + zassert_equal(rc, 0, + "toggle_bits active-to-inactive failed"); + zassert_equal(raw_in(), false, + "toggle_bits active-to-inactive mismatch"); + + rc = gpio_port_toggle_bits(dev_out, BIT(PIN_OUT)); + zassert_equal(rc, 0, + "toggle_bits inactive-to-active failed"); + zassert_equal(raw_in(), true, + "toggle_bits inactive-to-active mismatch"); + + rc = gpio_pin_toggle(dev_out, PIN_OUT); + zassert_equal(rc, 0, + "pin_toggle low-to-high failed"); + zassert_equal(raw_in(), false, + "pin_toggle low-to-high mismatch"); + + return TC_PASS; +} + +ZTEST(egpio_port, test_egpio_port) +{ + zassert_equal(setup(), TC_PASS, + "device setup failed"); + zassert_equal(bits_physical(), TC_PASS, + "bits_physical failed"); + zassert_equal(pin_physical(), TC_PASS, + "pin_physical failed"); + zassert_equal(check_raw_output_levels(), TC_PASS, + "check_raw_output_levels failed"); + zassert_equal(check_logic_output_levels(), TC_PASS, + "check_logic_output_levels failed"); + zassert_equal(bits_logical(), TC_PASS, + "bits_logical failed"); +} + +/* Test GPIO port configuration */ +ZTEST_SUITE(egpio_port, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/drivers/gpio/egpio_basic_api/sysbuild.conf b/tests/drivers/gpio/egpio_basic_api/sysbuild.conf new file mode 100644 index 000000000000..e580c9c26c79 --- /dev/null +++ b/tests/drivers/gpio/egpio_basic_api/sysbuild.conf @@ -0,0 +1,3 @@ +SB_CONFIG_PARTITION_MANAGER=n +SB_CONFIG_SDP=y +SB_CONFIG_EGPIO_FLPR_APPLICATION=y diff --git a/tests/drivers/gpio/egpio_basic_api/testcase.yaml b/tests/drivers/gpio/egpio_basic_api/testcase.yaml new file mode 100644 index 000000000000..5fd4c7ae7ec3 --- /dev/null +++ b/tests/drivers/gpio/egpio_basic_api/testcase.yaml @@ -0,0 +1,28 @@ +common: + tags: + - drivers + - gpio + - ci_tests_drivers_egpio + depends_on: gpio + harness: ztest + harness_config: + fixture: gpio_loopback + +tests: + drivers.egpio.loopback_icmsg: + min_flash: 64 + platform_allow: + - nrf54l15dk/nrf54l15/cpuapp + integration_platforms: + - nrf54l15dk/nrf54l15/cpuapp + sysbuild: true + extra_args: SB_CONFIG_EGPIO_BACKEND_ICMSG=y + + drivers.egpio.loopback_mbox: + min_flash: 64 + platform_allow: + - nrf54l15dk/nrf54l15/cpuapp + integration_platforms: + - nrf54l15dk/nrf54l15/cpuapp + sysbuild: true + extra_args: SB_CONFIG_EGPIO_BACKEND_MBOX=y