Skip to content

Commit 537b50b

Browse files
nordic-bamirlubos
authored andcommitted
tests: benchmarks: Use GPIO gated current measurements
Switch multicore idle tests to use GPIO garted current measurement Signed-off-by: Bartosz Miller <[email protected]>
1 parent d7214db commit 537b50b

File tree

32 files changed

+243
-186
lines changed

32 files changed

+243
-186
lines changed

tests/benchmarks/multicore/idle_adc/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
8+
/* Required GPIO loopback: P1.02 - P1.03 */
19
/ {
210
aliases {
311
adc0 = &adc;
412
sw = &loopback;
13+
led = &led0;
14+
/delete-property/ led1;
515
};
616
buttons {
717
compatible = "gpio-keys";
@@ -11,6 +21,8 @@
1121
};
1222
};
1323

24+
/delete-node/ &led1;
25+
1426
&adc {
1527
#address-cells = <1>;
1628
#size-cells = <0>;

tests/benchmarks/multicore/idle_adc/remote/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/benchmarks/multicore/idle_adc/remote/prj.conf

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/benchmarks/multicore/idle_adc/remote/src/main.c

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/benchmarks/multicore/idle_adc/src/main.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77
#include <zephyr/kernel.h>
88
#include <zephyr/drivers/adc.h>
99
#include <zephyr/drivers/gpio.h>
10-
#define ADC_NODE DT_ALIAS(adc0)
11-
#define ADC_LOW_LEVEL 0
10+
#define ADC_NODE DT_ALIAS(adc0)
11+
#define ADC_LOW_LEVEL 0
1212
#define ADC_HIGH_LEVEL 4092
1313

1414
static const struct device *adc = DEVICE_DT_GET(ADC_NODE);
1515
static const struct gpio_dt_spec gpio = GPIO_DT_SPEC_GET(DT_ALIAS(sw), gpios);
16+
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led), gpios);
1617

1718
int adc_setup(void)
1819
{
1920
int ret;
2021
/* Get the number of channels defined on the DTS. */
2122
static const struct adc_channel_cfg channel_cfgs[] = {
22-
DT_FOREACH_CHILD_SEP(ADC_NODE, ADC_CHANNEL_CFG_DT, (,))};
23+
DT_FOREACH_CHILD_SEP(ADC_NODE, ADC_CHANNEL_CFG_DT, (,))};
2324

2425
ret = adc_channel_setup(adc, &channel_cfgs[0]);
2526
return ret;
@@ -32,6 +33,12 @@ int main(void)
3233
int16_t sample_value;
3334
int test_repetitions = 3;
3435

36+
err = gpio_is_ready_dt(&led);
37+
__ASSERT(err, "Error: GPIO Device not ready");
38+
39+
err = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
40+
__ASSERT(err == 0, "Could not configure led GPIO");
41+
3542
/* Options for the sequence sampling. */
3643
const struct adc_sequence_options options = {
3744
.extra_samplings = 1,
@@ -61,14 +68,20 @@ int main(void)
6168
{
6269
gpio_pin_set_dt(&gpio, 1);
6370
err = adc_read(adc, &sequence);
71+
k_busy_wait(1000);
6472
sample_value = channel_reading[0];
6573
__ASSERT_NO_MSG(sample_value == ADC_HIGH_LEVEL);
74+
gpio_pin_set_dt(&led, 0);
6675
k_sleep(K_SECONDS(1));
76+
gpio_pin_set_dt(&led, 1);
6777
gpio_pin_set_dt(&gpio, 0);
6878
err = adc_read(adc, &sequence);
79+
k_busy_wait(1000);
6980
sample_value = channel_reading[0];
7081
__ASSERT_NO_MSG(sample_value == ADC_LOW_LEVEL);
82+
gpio_pin_set_dt(&led, 0);
7183
k_sleep(K_SECONDS(1));
84+
gpio_pin_set_dt(&led, 1);
7285
}
7386
#if defined(CONFIG_COVERAGE)
7487
printk("Coverage analysis start\n");

tests/benchmarks/multicore/idle_adc/sysbuild.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ endif()
1111
# Add remote project
1212
ExternalZephyrProject_Add(
1313
APPLICATION remote
14-
SOURCE_DIR ${APP_DIR}/remote
14+
SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/power_consumption/common/remote_sleep_forever
1515
BOARD ${SB_CONFIG_REMOTE_BOARD}
1616
BOARD_REVISION ${BOARD_REVISION}
1717
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/ {
8+
aliases {
9+
led = &led0;
10+
/delete-property/ led1;
11+
};
12+
};
13+
14+
/delete-node/ &led1;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
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+
led1: led_1 {
15+
gpios = <&gpio9 1 GPIO_ACTIVE_HIGH>;
16+
label = "Green LED 1";
17+
};
18+
};
19+
};
20+
21+
&gpio9 {
22+
status = "okay";
23+
};
24+
25+
&gpiote130 {
26+
status = "okay";
27+
};

tests/benchmarks/multicore/idle_clock_control/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CONFIG_PM_DEVICE=y
55
CONFIG_PM_DEVICE_RUNTIME=y
66
CONFIG_POWEROFF=y
77

8-
CONFIG_GPIO=n
8+
CONFIG_GPIO=y
99
CONFIG_BOOT_BANNER=n
1010

1111
CONFIG_NRFS=y

tests/benchmarks/multicore/idle_clock_control/remote/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)