Skip to content

Commit 2749918

Browse files
maje-embrlubos
authored andcommitted
samples: peripheral_power_profiling: Fix the use of PM_DEVICE
Fixed the use of Device Power Management and enabled Runtime Device Power Management. Ref: NCSDK-30068 Signed-off-by: Marcin Jelinski <[email protected]> (cherry picked from commit c7dc2fb)
1 parent fb9267c commit 2749918

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
CONFIG_PM_DEVICE=y
8+
CONFIG_PM_DEVICE_RUNTIME=y
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+
/delete-property/ sw2;
10+
/delete-property/ sw3;
11+
};
12+
};
13+
14+
/delete-node/ &button2;
15+
/delete-node/ &button3;
16+
17+
&uart20 {
18+
zephyr,pm-device-runtime-auto;
19+
};

samples/bluetooth/peripheral_power_profiling/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ CONFIG_FLASH_PAGE_LAYOUT=y
2929
CONFIG_FLASH_MAP=y
3030

3131
CONFIG_POWEROFF=y
32-
CONFIG_PM_DEVICE=y
3332

3433
CONFIG_MAIN_STACK_SIZE=2048
3534

samples/bluetooth/peripheral_power_profiling/src/main.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858

5959
#define NFC_BUFFER_SIZE 1024
6060

61-
const struct device *const cons = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
62-
6361
static struct bt_le_oob oob_local;
6462
static uint8_t tk_local[NFC_NDEF_LE_OOB_REC_TK_LEN];
6563
static uint8_t nfc_buffer[NFC_BUFFER_SIZE];
@@ -628,10 +626,16 @@ static void system_off(void)
628626

629627
dk_set_led_off(RUN_STATUS_LED);
630628

631-
int rc = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);
629+
if (IS_ENABLED(CONFIG_PM_DEVICE) && IS_ENABLED(CONFIG_SERIAL)) {
630+
static const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
631+
int err;
632+
enum pm_device_state state;
632633

633-
if (rc < 0) {
634-
printk("Could not suspend console (%d)\n", rc);
634+
if (dev) {
635+
do {
636+
err = pm_device_state_get(dev, &state);
637+
} while ((err == 0) && (state == PM_DEVICE_STATE_ACTIVE));
638+
}
635639
}
636640

637641
sys_poweroff();
@@ -665,11 +669,6 @@ int main(void)
665669

666670
printk("Starting Bluetooth Power Profiling example\n");
667671

668-
if (!device_is_ready(cons)) {
669-
printk("%s: device not ready.\n", cons->name);
670-
return 0;
671-
}
672-
673672
err = dk_buttons_init(button_handler);
674673
if (err) {
675674
printk("Failed to initialize buttons (err %d)\n", err);

0 commit comments

Comments
 (0)