diff --git a/samples/bluetooth/peripheral_power_profiling/boards/nrf54l15dk_nrf54l15_cpuapp.conf b/samples/bluetooth/peripheral_power_profiling/boards/nrf54l15dk_nrf54l15_cpuapp.conf new file mode 100644 index 000000000000..b5af8c1135e7 --- /dev/null +++ b/samples/bluetooth/peripheral_power_profiling/boards/nrf54l15dk_nrf54l15_cpuapp.conf @@ -0,0 +1,8 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_PM_DEVICE=y +CONFIG_PM_DEVICE_RUNTIME=y diff --git a/samples/bluetooth/peripheral_power_profiling/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/samples/bluetooth/peripheral_power_profiling/boards/nrf54l15dk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..163839989439 --- /dev/null +++ b/samples/bluetooth/peripheral_power_profiling/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + aliases { + /delete-property/ sw2; + /delete-property/ sw3; + }; +}; + +/delete-node/ &button2; +/delete-node/ &button3; + +&uart20 { + zephyr,pm-device-runtime-auto; +}; diff --git a/samples/bluetooth/peripheral_power_profiling/prj.conf b/samples/bluetooth/peripheral_power_profiling/prj.conf index 459e8c606840..7e3bce03328b 100644 --- a/samples/bluetooth/peripheral_power_profiling/prj.conf +++ b/samples/bluetooth/peripheral_power_profiling/prj.conf @@ -29,7 +29,6 @@ CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_FLASH_MAP=y CONFIG_POWEROFF=y -CONFIG_PM_DEVICE=y CONFIG_MAIN_STACK_SIZE=2048 diff --git a/samples/bluetooth/peripheral_power_profiling/src/main.c b/samples/bluetooth/peripheral_power_profiling/src/main.c index f334caba490f..b0b24030ee80 100644 --- a/samples/bluetooth/peripheral_power_profiling/src/main.c +++ b/samples/bluetooth/peripheral_power_profiling/src/main.c @@ -58,8 +58,6 @@ #define NFC_BUFFER_SIZE 1024 -const struct device *const cons = DEVICE_DT_GET(DT_CHOSEN(zephyr_console)); - static struct bt_le_oob oob_local; static uint8_t tk_local[NFC_NDEF_LE_OOB_REC_TK_LEN]; static uint8_t nfc_buffer[NFC_BUFFER_SIZE]; @@ -628,10 +626,16 @@ static void system_off(void) dk_set_led_off(RUN_STATUS_LED); - int rc = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND); + if (IS_ENABLED(CONFIG_PM_DEVICE) && IS_ENABLED(CONFIG_SERIAL)) { + static const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console)); + int err; + enum pm_device_state state; - if (rc < 0) { - printk("Could not suspend console (%d)\n", rc); + if (dev) { + do { + err = pm_device_state_get(dev, &state); + } while ((err == 0) && (state == PM_DEVICE_STATE_ACTIVE)); + } } sys_poweroff(); @@ -665,11 +669,6 @@ int main(void) printk("Starting Bluetooth Power Profiling example\n"); - if (!device_is_ready(cons)) { - printk("%s: device not ready.\n", cons->name); - return 0; - } - err = dk_buttons_init(button_handler); if (err) { printk("Failed to initialize buttons (err %d)\n", err);