Skip to content

Commit f659198

Browse files
nordic-pikrnordicjm
authored andcommitted
tests: benchmarks: multicore: idle_gpio: Rapidly changing wakeup signal
Add tests where the wakeup signals change rapidly. To achieve this, the SPI MOSI pin is used to generate a signal that is used as the wakeup source. By transferring byte 0x5, we get two very narrow pulses. Signed-off-by: Piotr Krzyzanowski <piotr.krzyzanowski@nordicsemi.no>
1 parent fb3e2be commit f659198

7 files changed

Lines changed: 186 additions & 0 deletions

File tree

tests/benchmarks/multicore/idle_gpio/Kconfig.sysbuild

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,22 @@ choice NETCORE
1010
config NETCORE_REMOTE
1111
bool "Remote image"
1212

13+
config NETCORE_WAKEUP_TRIGGER
14+
bool "Wakeup trigger image"
15+
1316
config NETCORE_REMOTE_SLEEP_FOREVER
1417
bool "Remote sleep forever image"
1518

1619
endchoice
1720

1821
config NETCORE_IMAGE_NAME
1922
default "remote" if NETCORE_REMOTE
23+
default "wakeup_trigger" if NETCORE_WAKEUP_TRIGGER
2024
default "remote_sleep_forever" if NETCORE_REMOTE_SLEEP_FOREVER
2125

2226
config NETCORE_IMAGE_PATH
2327
default "${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/multicore/idle_gpio/remote" if NETCORE_REMOTE
28+
default "${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/multicore/idle_gpio/wakeup_trigger" if NETCORE_WAKEUP_TRIGGER
2429
default "${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/power_consumption/common/remote_sleep_forever" if NETCORE_REMOTE_SLEEP_FOREVER
2530

2631
choice PPRCORE

tests/benchmarks/multicore/idle_gpio/testcase.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,23 @@ tests:
7676
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_simple"
7777
tags: ppk_power_measure
7878

79+
benchmarks.multicore.idle_gpio.nrf54h20dk_cpuapp_cpurad.s2ram.wakeup_from_spi_mosi:
80+
platform_allow:
81+
- nrf54h20dk/nrf54h20/cpuapp
82+
integration_platforms:
83+
- nrf54h20dk/nrf54h20/cpuapp
84+
extra_args:
85+
- FILE_SUFFIX=s2ram
86+
- EXTRA_DTC_OVERLAY_FILE="wakeup_from_spi_mosi_pin.overlay"
87+
- SB_CONFIG_NETCORE_WAKEUP_TRIGGER=y
88+
harness: pytest
89+
harness_config:
90+
fixture: gpio_loopback
91+
pytest_root:
92+
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_consumption_with_spi_wakeups"
93+
timeout: 120
94+
tags: ppk_power_measure
95+
7996
benchmarks.multicore.idle_gpio.nrf54h20dk_cpuapp_cpurad.s2ram.wakeup_from_uart_pins:
8097
platform_allow:
8198
- nrf54h20dk/nrf54h20/cpuapp
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/ {
8+
/*
9+
* Redefine sw0/button0 to use SPI MOSI - P0.06
10+
* Thus, when "remote" starts SPI transfer, there will be gpio interrupt,
11+
* the same as originally triggered by sw0 button.
12+
* P0.06 - P0.07 loopback is needed.
13+
*/
14+
buttons {
15+
compatible = "gpio-keys";
16+
17+
button0: button_0 {
18+
gpios = <&gpio0 6 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
19+
label = "Push button 0";
20+
zephyr,code = <INPUT_KEY_0>;
21+
};
22+
};
23+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) 2026 Nordic Semiconductor ASA
3+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
4+
#
5+
6+
cmake_minimum_required(VERSION 3.20.0)
7+
8+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
9+
10+
project(wakeup_trigger)
11+
12+
target_sources(app PRIVATE src/main.c)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/ {
8+
aliases {
9+
led = &led1;
10+
};
11+
12+
leds {
13+
compatible = "gpio-leds";
14+
15+
led1: led_1 {
16+
gpios = <&gpio9 1 GPIO_ACTIVE_HIGH>;
17+
label = "Green LED 1";
18+
};
19+
};
20+
};
21+
22+
&gpio0 {
23+
status = "okay";
24+
};
25+
26+
&gpio9 {
27+
status = "okay";
28+
};
29+
30+
&gpiote130 {
31+
status = "okay";
32+
owned-channels = <1>;
33+
};
34+
35+
&pinctrl {
36+
spi131_default_alt: spi131_default_alt {
37+
group1 {
38+
psels = <NRF_PSEL(SPIM_MOSI, 0, 7)>;
39+
};
40+
};
41+
42+
spi131_sleep_alt: spi131_sleep_alt {
43+
group1 {
44+
psels = <NRF_PSEL(SPIM_MOSI, 0, 7)>;
45+
low-power-enable;
46+
};
47+
};
48+
};
49+
50+
&spi131 {
51+
compatible = "nordic,nrf-spim";
52+
status = "okay";
53+
memory-regions = <&cpurad_dma_region>;
54+
pinctrl-0 = <&spi131_default_alt>;
55+
pinctrl-1 = <&spi131_sleep_alt>;
56+
pinctrl-names = "default", "sleep";
57+
overrun-character = <0x00>;
58+
59+
spim_dt: spi-device@0 {
60+
compatible = "vnd,spi-device";
61+
reg = <0>;
62+
spi-max-frequency = <DT_FREQ_M(8)>;
63+
};
64+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CONFIG_SPI=y
2+
CONFIG_PM=y
3+
CONFIG_POWEROFF=y
4+
CONFIG_CONSOLE=n
5+
CONFIG_UART_CONSOLE=n
6+
CONFIG_SERIAL=n
7+
CONFIG_GPIO=y
8+
CONFIG_BOOT_BANNER=n
9+
CONFIG_NCS_BOOT_BANNER=n
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/drivers/gpio.h>
9+
#include <zephyr/drivers/spi.h>
10+
#include <zephyr/logging/log.h>
11+
12+
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led), gpios);
13+
14+
#define SPI_MODE (SPI_OP_MODE_MASTER | SPI_WORD_SET(8))
15+
static const struct spi_dt_spec spim = SPI_DT_SPEC_GET(DT_NODELABEL(spim_dt), SPI_MODE);
16+
17+
LOG_MODULE_REGISTER(wakeup_trigger);
18+
19+
int main(void)
20+
{
21+
static char tx_buffer[] = {0x5};
22+
struct spi_buf tx_spi_bufs = {.buf = tx_buffer, .len = sizeof(tx_buffer)};
23+
struct spi_buf_set tx_spi_buf_set = {.buffers = &tx_spi_bufs, .count = 1};
24+
int rc;
25+
26+
rc = gpio_is_ready_dt(&led);
27+
if (rc < 0) {
28+
LOG_ERR("GPIO Device not ready (%d)", rc);
29+
return 0;
30+
}
31+
32+
rc = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
33+
if (rc < 0) {
34+
LOG_ERR("Could not configure led GPIO (%d)", rc);
35+
return 0;
36+
}
37+
38+
rc = spi_is_ready_dt(&spim);
39+
if (rc < 0) {
40+
LOG_ERR("SPI device is not ready (%d)", rc);
41+
return 0;
42+
}
43+
44+
while (1) {
45+
LOG_INF("SPIM: going to sleep for 1.5s...");
46+
gpio_pin_set_dt(&led, 0);
47+
k_msleep(1500);
48+
gpio_pin_set_dt(&led, 1);
49+
LOG_INF("SPIM: will be active for 500ms before transfer");
50+
k_busy_wait(500000);
51+
LOG_INF("SPIM: transferring one byte: '%#02x'", tx_buffer[0]);
52+
spi_write_dt(&spim, &tx_spi_buf_set);
53+
}
54+
55+
return 0;
56+
}

0 commit comments

Comments
 (0)