Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: drivers: gpio: Add loopback test for eGPIO SDP #17173

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/test-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*"

Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions scripts/ci/tags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
12 changes: 12 additions & 0 deletions tests/drivers/gpio/egpio_basic_api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
18 changes: 18 additions & 0 deletions tests/drivers/gpio/egpio_basic_api/README.txt
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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";
};
27 changes: 27 additions & 0 deletions tests/drivers/gpio/egpio_basic_api/dts/bindings/test-egpio.yaml
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions tests/drivers/gpio/egpio_basic_api/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_GPIO=y
CONFIG_ZTEST=y
56 changes: 56 additions & 0 deletions tests/drivers/gpio/egpio_basic_api/src/test_egpio.h
Original file line number Diff line number Diff line change
@@ -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 <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/sys/util.h>
#include <zephyr/ztest.h>

#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__ */
Loading
Loading