Skip to content

samples: peripheral_power_profiling: Add support for nRF54LV10DK #22818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions samples/bluetooth/peripheral_power_profiling/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ config BT_POWER_PROFILING_LED_DISABLED

config BT_POWER_PROFILING_NFC_DISABLED
bool "Disable NFC"
default y if !HAS_HW_NRF_NFCT
help
Disables the NFC to reduce power consumption.

Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use the CONFIG_BT_POWER_PROFILING_NFC_DISABLED option to control the Kconfig dependencies related to NFC? E.g. to make it enabled by default for nRF54LV10 make the NFC modules depend on this definition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, it is possible.
Updated implementations.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright (c) 2025 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_NFC_T2T_NRFXLIB=n

CONFIG_NFC_NDEF=n
CONFIG_NFC_NDEF_MSG=n
CONFIG_NFC_NDEF_RECORD=n
CONFIG_NFC_NDEF_LE_OOB_REC=n
CONFIG_NFC_NDEF_CH_MSG=n

CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/ {
aliases {
/delete-property/ sw2;
/delete-property/ sw3;
};
};

/delete-node/ &button2;
/delete-node/ &button3;

&uart30 {
zephyr,pm-device-runtime-auto;
};
2 changes: 2 additions & 0 deletions samples/bluetooth/peripheral_power_profiling/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tests:
- nrf54l15dk/nrf54l10/cpuapp
- nrf54l15dk/nrf54l15/cpuapp
- nrf54lm20pdk/nrf54lm20a/cpuapp
- nrf54lv10dk/nrf54lv10a/cpuapp
platform_allow:
- nrf52dk/nrf52832
- nrf52833dk/nrf52833
Expand All @@ -25,6 +26,7 @@ tests:
- nrf54l15dk/nrf54l10/cpuapp
- nrf54l15dk/nrf54l15/cpuapp
- nrf54lm20pdk/nrf54lm20a/cpuapp
- nrf54lv10dk/nrf54lv10a/cpuapp
tags:
- bluetooth
- ci_build
Expand Down
30 changes: 23 additions & 7 deletions samples/bluetooth/peripheral_power_profiling/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/hci.h>

#if !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED)
#include <nfc_t2t_lib.h>

#endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */
#include <nfc/ndef/msg.h>
#include <nfc/ndef/record.h>
#include <nfc/ndef/ch.h>
Expand Down Expand Up @@ -58,21 +59,24 @@

#define NFC_BUFFER_SIZE 1024


static struct bt_le_oob oob_local;
static uint8_t tk_local[NFC_NDEF_LE_OOB_REC_TK_LEN];
#if !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED)
static uint8_t nfc_buffer[NFC_BUFFER_SIZE];
static void adv_work_handler(struct k_work *work);
static K_WORK_DEFINE(adv_work, adv_work_handler);
#endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */

static struct bt_le_ext_adv *adv_set;

static void system_off_work_handler(struct k_work *work);
static void key_generation_work_handler(struct k_work *work);
static void adv_work_handler(struct k_work *work);
static void notify_work_handler(struct k_work *work);
static void notify_timeout_handler(struct k_work *work);

static K_WORK_DELAYABLE_DEFINE(system_off_work, system_off_work_handler);
static K_WORK_DEFINE(key_generate_work, key_generation_work_handler);
static K_WORK_DEFINE(adv_work, adv_work_handler);
static K_WORK_DELAYABLE_DEFINE(notify_work, notify_work_handler);
static K_WORK_DELAYABLE_DEFINE(notify_timeout, notify_timeout_handler);

Expand Down Expand Up @@ -149,6 +153,7 @@ static int set_led_off(uint8_t led_idx)
}
}

#if !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED)
static void nfc_callback(void *context, nfc_t2t_event_t event, const uint8_t *data,
size_t data_length)
{
Expand Down Expand Up @@ -184,6 +189,7 @@ static void nfc_callback(void *context, nfc_t2t_event_t event, const uint8_t *da
break;
}
}
#endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */

static void connected(struct bt_conn *conn, uint8_t conn_err)
{
Expand Down Expand Up @@ -486,6 +492,7 @@ static void key_generation_work_handler(struct k_work *work)
pairing_key_generate();
}

#if !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED)
static void adv_work_handler(struct k_work *work)
{
int err;
Expand Down Expand Up @@ -518,6 +525,7 @@ static void adv_work_handler(struct k_work *work)
printk("Connectable advertising started\n");
}
}
#endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */

static void notify_work_handler(struct k_work *work)
{
Expand Down Expand Up @@ -559,6 +567,7 @@ static void notify_timeout_handler(struct k_work *work)
}
}

#if !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED)
static int nfc_oob_data_setup(size_t *size)
{
static const uint8_t ndef_record_count = 2;
Expand Down Expand Up @@ -599,9 +608,11 @@ static int nfc_oob_data_setup(size_t *size)

return nfc_ndef_msg_encode(&NFC_NDEF_MSG(ndef_msg), nfc_buffer, size);
}
#endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */

static int nfc_init(void)
{
#if !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED)
int err;
size_t nfc_buffer_size = sizeof(nfc_buffer);

Expand Down Expand Up @@ -629,6 +640,9 @@ static int nfc_init(void)
}

return err;
#else
return 0;
#endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */
}

static void reset_reason_print(void)
Expand All @@ -637,10 +651,12 @@ static void reset_reason_print(void)

reason = nrfx_reset_reason_get();

if (reason & NRFX_RESET_REASON_NFC_MASK) {
printk("Wake up by NFC field detected\n");
} else if (reason & NRFX_RESET_REASON_OFF_MASK) {
if (reason & NRFX_RESET_REASON_OFF_MASK) {
printk("Wake up by the advertising start buttons\n");
#if !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED)
} else if (reason & NRFX_RESET_REASON_NFC_MASK) {
printk("Wake up by NFC field detected\n");
#endif /* !IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED) */
#if defined(NRF_RESETINFO)
} else if (reason & NRFX_RESET_REASON_LOCAL_SREQ_MASK) {
printk("Application soft reset detected\n");
Expand Down Expand Up @@ -774,7 +790,7 @@ int main(void)
return 0;
}

if (!IS_ENABLED(BT_POWER_PROFILING_NFC_DISABLED)) {
if (!IS_ENABLED(CONFIG_BT_POWER_PROFILING_NFC_DISABLED)) {
err = nfc_init();
if (err) {
printk("Failed to initialize NFC (err %d)\n", err);
Expand Down