Skip to content

Commit c1380c2

Browse files
nordic-babunordicjm
authored andcommitted
tests: benchmarks: multicore: add comp tests.
Add tests for assesing s2ram with (lp)comp power consumption. Signed-off-by: Bartlomiej Buczek <[email protected]>
1 parent 3847769 commit c1380c2

File tree

13 files changed

+229
-0
lines changed

13 files changed

+229
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
if(NOT SYSBUILD)
11+
message(FATAL_ERROR
12+
" This is a multi-image application that should be built using sysbuild.\n"
13+
" Add --sysbuild argument to west build command to prepare all the images.")
14+
endif()
15+
16+
project(idle_comp)
17+
18+
target_sources(app PRIVATE src/main.c)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
source "${ZEPHYR_BASE}/share/sysbuild/Kconfig"
8+
9+
config REMOTE_BOARD
10+
string "The board used for remote target"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
&comp {
8+
main-mode = "SE";
9+
psel = "AIN2"; /* P1.02 */
10+
refsel = "INT_1V2";
11+
sp-mode = "HIGH";
12+
th-up = <63>;
13+
th-down = <59>;
14+
isource = "DISABLED";
15+
status = "okay";
16+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
&comp {
8+
compatible = "nordic,nrf-lpcomp";
9+
psel = "AIN2"; /* P1.02 */
10+
refsel = "VDD_4_8";
11+
status = "okay";
12+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/ {
8+
aliases {
9+
test-comp = &comp;
10+
};
11+
12+
zephyr,user {
13+
test-gpios = <&gpio1 3 GPIO_ACTIVE_HIGH>;
14+
};
15+
};
16+
17+
&gpio1 {
18+
status = "okay";
19+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CONFIG_COMPARATOR=y
2+
CONFIG_GPIO=y
3+
4+
CONFIG_PM=y
5+
CONFIG_PM_S2RAM=y
6+
CONFIG_PM_S2RAM_CUSTOM_MARKING=y
7+
CONFIG_PM_DEVICE=y
8+
CONFIG_PM_DEVICE_RUNTIME=y
9+
CONFIG_POWEROFF=y
10+
CONFIG_BOOT_BANNER=n
11+
CONFIG_SOC_NRF54H20_NO_MRAM_LATENCY=n
12+
CONFIG_ASSERT=y
13+
14+
# Enable for debugging purposes only
15+
CONFIG_PRINTK=n
16+
CONFIG_LOG=n
17+
CONFIG_CONSOLE=n
18+
CONFIG_UART_CONSOLE=n
19+
CONFIG_SERIAL=n
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(remote)
11+
12+
target_sources(app PRIVATE src/main.c)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CONFIG_PM=y
2+
CONFIG_POWEROFF=y
3+
CONFIG_CONSOLE=n
4+
CONFIG_UART_CONSOLE=n
5+
CONFIG_SERIAL=n
6+
CONFIG_GPIO=n
7+
CONFIG_BOOT_BANNER=n
8+
CONFIG_SOC_NRF54H20_NO_MRAM_LATENCY=n
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
9+
int main(void)
10+
{
11+
k_sleep(K_FOREVER);
12+
13+
return 0;
14+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <zephyr/drivers/comparator.h>
8+
#include <zephyr/drivers/gpio.h>
9+
#include <zephyr/kernel.h>
10+
11+
static const struct device *test_dev = DEVICE_DT_GET(DT_ALIAS(test_comp));
12+
static const struct gpio_dt_spec test_pin = GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), test_gpios);
13+
14+
volatile int counter;
15+
static void test_callback(const struct device *dev, void *user_data)
16+
{
17+
counter++;
18+
}
19+
20+
int main(void)
21+
{
22+
23+
int rc;
24+
25+
gpio_pin_configure_dt(&test_pin, GPIO_OUTPUT_INACTIVE);
26+
27+
rc = comparator_set_trigger_callback(test_dev, test_callback, NULL);
28+
__ASSERT_NO_MSG(rc == 0);
29+
30+
rc = comparator_set_trigger(test_dev, COMPARATOR_TRIGGER_BOTH_EDGES);
31+
__ASSERT_NO_MSG(rc == 0);
32+
k_msleep(1000);
33+
34+
while (1) {
35+
counter = 0;
36+
gpio_pin_set_dt(&test_pin, 1);
37+
k_msleep(1000);
38+
__ASSERT_NO_MSG(counter == 1);
39+
gpio_pin_set_dt(&test_pin, 0);
40+
k_msleep(1000);
41+
__ASSERT_NO_MSG(counter == 2);
42+
}
43+
return 0;
44+
}

0 commit comments

Comments
 (0)