-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <jakub.zymelka@nordicsemi.no>
- Loading branch information
1 parent
67df3c9
commit e070b94
Showing
9 changed files
with
651 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GPIO_1 output 7 connected to GPIO_2 input 3 | ||
FATAL output pin not wired to input pin? (out high => in low) | ||
|
||
No special build options are required to make use of the overlay. |
21 changes: 21 additions & 0 deletions
21
tests/drivers/gpio/egpio_basic_api/boards/nrf54l15dk_nrf54l15_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
}; |
28 changes: 28 additions & 0 deletions
28
tests/drivers/gpio/egpio_basic_api/dts/bindings/test-egpio.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# 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 a eGPIO that will be configured as an output. | ||
This must be on the 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 on the same instance as out-gpios, and physically | ||
connected to out-gpios. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CONFIG_GPIO=y | ||
CONFIG_ZTEST=y | ||
CONFIG_ENTROPY_GENERATOR=y | ||
CONFIG_TEST_RANDOM_GENERATOR=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__ */ |
Oops, something went wrong.