Skip to content

Commit 66ee3a6

Browse files
maje-embrlubos
authored andcommitted
samples: Prevent UART PM suspend/resume in interrupt context
Use pm_device_runtime_get() to keep the UART powered on the nRF54H20 in the Radio Test and DTM samples. Ref: NCSDK-35635 Ref: NCSDK-35636 Signed-off-by: Marcin Jelinski <[email protected]>
1 parent d403ffa commit 66ee3a6

File tree

2 files changed

+35
-0
lines changed
  • samples
    • bluetooth/direct_test_mode/src
    • peripheral/radio_test/src

2 files changed

+35
-0
lines changed

samples/bluetooth/direct_test_mode/src/main.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <zephyr/device.h>
88
#include <zephyr/sys/printk.h>
9+
#include <zephyr/pm/device_runtime.h>
910

1011
#include "transport/dtm_transport.h"
1112

@@ -16,6 +17,18 @@ int main(void)
1617

1718
printk("Starting Direct Test Mode sample\n");
1819

20+
#if defined(CONFIG_SOC_SERIES_NRF54HX)
21+
const struct device *dtm_uart = DEVICE_DT_GET_OR_NULL(DT_CHOSEN(ncs_dtm_uart));
22+
23+
if (dtm_uart != NULL) {
24+
int ret = pm_device_runtime_get(dtm_uart);
25+
26+
if (ret < 0) {
27+
printk("Failed to get DTM UART runtime PM: %d\n", ret);
28+
}
29+
}
30+
#endif /* defined(CONFIG_SOC_SERIES_NRF54HX) */
31+
1932
err = dtm_tr_init();
2033
if (err) {
2134
printk("Error initializing DTM transport: %d\n", err);

samples/peripheral/radio_test/src/main.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <zephyr/sys/printk.h>
88
#include <zephyr/drivers/clock_control.h>
99
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
10+
#include <zephyr/pm/device_runtime.h>
1011
#if defined(NRF54L15_XXAA)
1112
#include <hal/nrf_clock.h>
1213
#endif /* defined(NRF54L15_XXAA) */
@@ -165,6 +166,27 @@ int main(void)
165166
{
166167
printk("Starting Radio Test sample\n");
167168

169+
#if defined(CONFIG_SOC_SERIES_NRF54HX)
170+
const struct device *console_uart = DEVICE_DT_GET_OR_NULL(DT_CHOSEN(zephyr_console));
171+
const struct device *shell_uart = DEVICE_DT_GET_OR_NULL(DT_CHOSEN(zephyr_shell_uart));
172+
173+
if (console_uart != NULL) {
174+
int ret = pm_device_runtime_get(console_uart);
175+
176+
if (ret < 0) {
177+
printk("Failed to get console UART runtime PM: %d\n", ret);
178+
}
179+
}
180+
181+
if (shell_uart != NULL && shell_uart != console_uart) {
182+
int ret = pm_device_runtime_get(shell_uart);
183+
184+
if (ret < 0) {
185+
printk("Failed to get shell UART runtime PM: %d\n", ret);
186+
}
187+
}
188+
#endif /* defined(CONFIG_SOC_SERIES_NRF54HX) */
189+
168190
clock_init();
169191

170192
#if defined(CONFIG_SOC_SERIES_NRF54HX)

0 commit comments

Comments
 (0)