Skip to content

Commit e5fc6da

Browse files
Kamil Gawormaje-emb
authored andcommitted
samples: radio_test: Add clock control for nRF54h20
This adds support for clock control driver for nRF54h20 targets in Radio Test sample. Jira: NCSDK-28468 Signed-off-by: Kamil Gawor <[email protected]>
1 parent 9754ef0 commit e5fc6da

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

samples/peripheral/radio_test/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CONFIG_SHELL=y
1010
CONFIG_DYNAMIC_INTERRUPTS=y
1111

1212
CONFIG_NRFX_TIMER0=y
13+
CONFIG_CLOCK_CONTROL=y
1314

1415
CONFIG_ENTROPY_GENERATOR=y
1516
CONFIG_NRF_SECURITY=y

samples/peripheral/radio_test/src/main.c

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
*/
66

77
#include <zephyr/sys/printk.h>
8-
#if defined(CONFIG_CLOCK_CONTROL_NRF)
98
#include <zephyr/drivers/clock_control.h>
109
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
11-
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */
1210
#if defined(NRF54L15_XXAA)
1311
#include <hal/nrf_clock.h>
1412
#endif /* defined(NRF54L15_XXAA) */
13+
#if defined(CONFIG_CLOCK_CONTROL_NRF2)
14+
#include <hal/nrf_lrcconf.h>
15+
#endif
1516

1617
#if defined(CONFIG_CLOCK_CONTROL_NRF)
1718
static void clock_init(void)
@@ -50,15 +51,49 @@ static void clock_init(void)
5051

5152
printk("Clock has started\n");
5253
}
54+
55+
#elif defined(CONFIG_CLOCK_CONTROL_NRF2)
56+
57+
static void clock_init(void)
58+
{
59+
int err;
60+
int res;
61+
const struct device *radio_clk_dev =
62+
DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_NODELABEL(radio)));
63+
struct onoff_client radio_cli;
64+
65+
/** Keep radio domain powered all the time to reduce latency. */
66+
nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_1, true);
67+
68+
sys_notify_init_spinwait(&radio_cli.notify);
69+
70+
err = nrf_clock_control_request(radio_clk_dev, NULL, &radio_cli);
71+
72+
do {
73+
err = sys_notify_fetch_result(&radio_cli.notify, &res);
74+
if (!err && res) {
75+
printk("Clock could not be started: %d\n", res);
76+
return;
77+
}
78+
} while (err == -EAGAIN);
79+
80+
#if defined(NRF54L15_XXAA)
81+
/* MLTPAN-20 */
82+
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART);
83+
#endif /* defined(NRF54L15_XXAA) */
84+
85+
printk("Clock has started\n");
86+
}
87+
88+
#else
89+
BUILD_ASSERT(false, "No Clock Control driver");
5390
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */
5491

5592
int main(void)
5693
{
5794
printk("Starting Radio Test example\n");
5895

59-
#if defined(CONFIG_CLOCK_CONTROL_NRF)
6096
clock_init();
61-
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */
6297

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

0 commit comments

Comments
 (0)