File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
tests/benchmarks/power_consumption/lpcomp Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 27
27
psel = "AIN2"; /* P1.02 */
28
28
refsel = "VDD_4_8";
29
29
status = "okay";
30
+ zephyr,pm-device-runtime-auto;
30
31
};
Original file line number Diff line number Diff line change 7
7
#include <zephyr/drivers/comparator.h>
8
8
#include <zephyr/drivers/gpio.h>
9
9
#include <zephyr/kernel.h>
10
+ #include <zephyr/pm/device_runtime.h>
10
11
11
12
static const struct device * test_dev = DEVICE_DT_GET (DT_ALIAS (test_comp ));
12
13
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;
15
16
16
17
static void test_callback (const struct device * dev , void * user_data )
17
18
{
19
+ int rc ;
20
+
21
+ rc = pm_device_runtime_put (dev );
22
+ __ASSERT_NO_MSG (rc == 0 );
18
23
counter ++ ;
19
24
}
20
25
@@ -32,10 +37,17 @@ void thread_definition(void)
32
37
k_msleep (10 );
33
38
34
39
while (1 ) {
40
+ rc = pm_device_runtime_get (test_dev );
41
+ __ASSERT_NO_MSG (rc == 0 );
42
+ k_busy_wait (100 );
35
43
counter = 0 ;
36
44
gpio_pin_set_dt (& test_pin , 1 );
37
45
k_msleep (10 );
38
46
__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 );
39
51
gpio_pin_set_dt (& test_pin , 0 );
40
52
k_msleep (10 );
41
53
__ASSERT_NO_MSG (counter == 2 );
You can’t perform that action at this time.
0 commit comments