Skip to content

Commit 3253436

Browse files
adamkondraciukanangl
authored andcommitted
tests: benchmarks: power_consumption: lpcomp: Fix test
Use device_pm API to get correct current measurement results. Signed-off-by: Adam Kondraciuk <[email protected]> (cherry picked from commit 9548019)
1 parent 7b10aa8 commit 3253436

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tests/benchmarks/power_consumption/lpcomp/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
psel = "AIN2"; /* P1.02 */
2828
refsel = "VDD_4_8";
2929
status = "okay";
30+
zephyr,pm-device-runtime-auto;
3031
};

tests/benchmarks/power_consumption/lpcomp/src/driver_test.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <zephyr/drivers/comparator.h>
88
#include <zephyr/drivers/gpio.h>
99
#include <zephyr/kernel.h>
10+
#include <zephyr/pm/device_runtime.h>
1011

1112
static const struct device *test_dev = DEVICE_DT_GET(DT_ALIAS(test_comp));
1213
static const struct gpio_dt_spec test_pin = GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), test_gpios);
@@ -15,6 +16,10 @@ volatile int counter;
1516

1617
static void test_callback(const struct device *dev, void *user_data)
1718
{
19+
int rc;
20+
21+
rc = pm_device_runtime_put(dev);
22+
__ASSERT_NO_MSG(rc == 0);
1823
counter++;
1924
}
2025

@@ -32,10 +37,17 @@ void thread_definition(void)
3237
k_msleep(10);
3338

3439
while (1) {
40+
rc = pm_device_runtime_get(test_dev);
41+
__ASSERT_NO_MSG(rc == 0);
42+
k_busy_wait(100);
3543
counter = 0;
3644
gpio_pin_set_dt(&test_pin, 1);
3745
k_msleep(10);
3846
__ASSERT_NO_MSG(counter == 1);
47+
48+
rc = pm_device_runtime_get(test_dev);
49+
__ASSERT_NO_MSG(rc == 0);
50+
k_busy_wait(100);
3951
gpio_pin_set_dt(&test_pin, 0);
4052
k_msleep(10);
4153
__ASSERT_NO_MSG(counter == 2);

0 commit comments

Comments
 (0)