Skip to content

Commit 9754ef0

Browse files
Kamil Gawordoki-nordic
authored andcommitted
samples: dtm: Add clock control for nRF54h20
This adds clock control driver for nRF54h20 target in Direct Test Mode sample. Jira: NCSDK-28468 Signed-off-by: Kamil Gawor <[email protected]> Co-authored-by: Dominik Kilian <[email protected]>
1 parent 9fd6b4e commit 9754ef0

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

samples/bluetooth/direct_test_mode/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ CONFIG_LOG_BACKEND_RTT=y
2323
CONFIG_NRFX_TIMER0=y
2424
CONFIG_NRFX_TIMER1=y
2525
CONFIG_NRFX_TIMER2=y
26+
CONFIG_CLOCK_CONTROL=y
2627

2728
CONFIG_FEM_AL_LIB=y

samples/bluetooth/direct_test_mode/src/dtm.c

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
#endif /* CONFIG_FEM */
1717

1818
#include <zephyr/kernel.h>
19-
#if defined(CONFIG_CLOCK_CONTROL_NRF)
2019
#include <zephyr/drivers/clock_control.h>
2120
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
22-
#endif /* #if defined(CONFIG_CLOCK_CONTROL_NRF) */
2321
#include <zephyr/sys/__assert.h>
2422
#if !(defined(CONFIG_SOC_SERIES_NRF54HX) || defined(CONFIG_SOC_SERIES_NRF54LX))
2523
#include <hal/nrf_nvmc.h>
@@ -28,6 +26,10 @@
2826
#include <hal/nrf_egu.h>
2927
#include <hal/nrf_radio.h>
3028

29+
#if defined(CONFIG_CLOCK_CONTROL_NRF2)
30+
#include <hal/nrf_lrcconf.h>
31+
#endif
32+
3133
#ifdef NRF53_SERIES
3234
#include <hal/nrf_vreqctrl.h>
3335
#endif /* NRF53_SERIES */
@@ -671,7 +673,43 @@ static int clock_init(void)
671673

672674
return err;
673675
}
674-
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */
676+
677+
#elif defined(CONFIG_CLOCK_CONTROL_NRF2)
678+
679+
int clock_init(void)
680+
{
681+
int err;
682+
int res;
683+
const struct device *radio_clk_dev =
684+
DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_NODELABEL(radio)));
685+
struct onoff_client radio_cli;
686+
687+
/** Keep radio domain powered all the time to reduce latency. */
688+
nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_1, true);
689+
690+
sys_notify_init_spinwait(&radio_cli.notify);
691+
692+
err = nrf_clock_control_request(radio_clk_dev, NULL, &radio_cli);
693+
694+
do {
695+
err = sys_notify_fetch_result(&radio_cli.notify, &res);
696+
if (!err && res) {
697+
printk("Clock could not be started: %d\n", res);
698+
return res;
699+
}
700+
} while (err == -EAGAIN);
701+
702+
#if defined(NRF54L15_XXAA)
703+
/* MLTPAN-20 */
704+
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART);
705+
#endif /* defined(NRF54L15_XXAA) */
706+
707+
return 0;
708+
}
709+
710+
#else
711+
BUILD_ASSERT(false, "No Clock Control driver");
712+
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF2) */
675713

676714
static int timer_init(void)
677715
{
@@ -1102,12 +1140,10 @@ int dtm_init(dtm_iq_report_callback_t callback)
11021140
{
11031141
int err;
11041142

1105-
#if defined(CONFIG_CLOCK_CONTROL_NRF)
11061143
err = clock_init();
11071144
if (err) {
11081145
return err;
11091146
}
1110-
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */
11111147

11121148
#if defined(CONFIG_SOC_SERIES_NRF54HX)
11131149
/* Apply HMPAN-102 workaround for nRF54H series */

0 commit comments

Comments
 (0)