Skip to content
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/direct_test_mode/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ CONFIG_LOG_BACKEND_RTT=y
CONFIG_NRFX_TIMER0=y
CONFIG_NRFX_TIMER1=y
CONFIG_NRFX_TIMER2=y
CONFIG_CLOCK_CONTROL=y

CONFIG_FEM_AL_LIB=y
1 change: 1 addition & 0 deletions samples/bluetooth/direct_test_mode/prj_hci.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ CONFIG_LOG_BACKEND_RTT=y
CONFIG_NRFX_TIMER0=y
CONFIG_NRFX_TIMER1=y
CONFIG_NRFX_TIMER2=y
CONFIG_CLOCK_CONTROL=y

CONFIG_FEM_AL_LIB=y

Expand Down
1 change: 1 addition & 0 deletions samples/bluetooth/direct_test_mode/prj_usb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ CONFIG_LOG_BACKEND_RTT=y
CONFIG_NRFX_TIMER0=y
CONFIG_NRFX_TIMER1=y
CONFIG_NRFX_TIMER2=y
CONFIG_CLOCK_CONTROL=y

CONFIG_FEM_AL_LIB=y

Expand Down
46 changes: 41 additions & 5 deletions samples/bluetooth/direct_test_mode/src/dtm.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
#endif /* CONFIG_FEM */

#include <zephyr/kernel.h>
#if defined(CONFIG_CLOCK_CONTROL_NRF)
#include <zephyr/drivers/clock_control.h>
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
#endif /* #if defined(CONFIG_CLOCK_CONTROL_NRF) */
#include <zephyr/sys/__assert.h>
#if !(defined(CONFIG_SOC_SERIES_NRF54HX) || defined(CONFIG_SOC_SERIES_NRF54LX))
#include <hal/nrf_nvmc.h>
Expand All @@ -28,6 +26,10 @@
#include <hal/nrf_egu.h>
#include <hal/nrf_radio.h>

#if defined(CONFIG_CLOCK_CONTROL_NRF2)
#include <hal/nrf_lrcconf.h>
#endif

#ifdef NRF53_SERIES
#include <hal/nrf_vreqctrl.h>
#endif /* NRF53_SERIES */
Expand Down Expand Up @@ -671,7 +673,43 @@ static int clock_init(void)

return err;
}
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */

#elif defined(CONFIG_CLOCK_CONTROL_NRF2)

int clock_init(void)
{
int err;
int res;
const struct device *radio_clk_dev =
DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_NODELABEL(radio)));
struct onoff_client radio_cli;

/** Keep radio domain powered all the time to reduce latency. */
nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_1, true);

sys_notify_init_spinwait(&radio_cli.notify);

err = nrf_clock_control_request(radio_clk_dev, NULL, &radio_cli);

do {
err = sys_notify_fetch_result(&radio_cli.notify, &res);
if (!err && res) {
printk("Clock could not be started: %d\n", res);
return res;
}
} while (err == -EAGAIN);

#if defined(NRF54L15_XXAA)
/* MLTPAN-20 */
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART);
#endif /* defined(NRF54L15_XXAA) */

return 0;
}

#else
BUILD_ASSERT(false, "No Clock Control driver");
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF2) */

static int timer_init(void)
{
Expand Down Expand Up @@ -1102,12 +1140,10 @@ int dtm_init(dtm_iq_report_callback_t callback)
{
int err;

#if defined(CONFIG_CLOCK_CONTROL_NRF)
err = clock_init();
if (err) {
return err;
}
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */

#if defined(CONFIG_SOC_SERIES_NRF54HX)
/* Apply HMPAN-102 workaround for nRF54H series */
Expand Down
1 change: 1 addition & 0 deletions samples/esb/esb_prx/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_ESB=y
CONFIG_DK_LIBRARY=y
CONFIG_CLOCK_CONTROL=y
47 changes: 42 additions & 5 deletions samples/esb/esb_prx/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
*/
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#if defined(CONFIG_CLOCK_CONTROL_NRF)
#include <zephyr/drivers/clock_control.h>
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */
#if defined(NRF54L15_XXAA)
#include <hal/nrf_clock.h>
#endif /* defined(NRF54L15_XXAA) */
Expand All @@ -20,6 +18,9 @@
#include <zephyr/kernel.h>
#include <zephyr/types.h>
#include <dk_buttons_and_leds.h>
#if defined(CONFIG_CLOCK_CONTROL_NRF2)
#include <hal/nrf_lrcconf.h>
#endif

LOG_MODULE_REGISTER(esb_prx, CONFIG_ESB_PRX_APP_LOG_LEVEL);

Expand Down Expand Up @@ -104,7 +105,45 @@ int clocks_start(void)
LOG_DBG("HF clock started");
return 0;
}
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */

#elif defined(CONFIG_CLOCK_CONTROL_NRF2)

int clocks_start(void)
{
int err;
int res;
const struct device *radio_clk_dev =
DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_NODELABEL(radio)));
struct onoff_client radio_cli;

/** Keep radio domain powered all the time to reduce latency. */
nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_1, true);

sys_notify_init_spinwait(&radio_cli.notify);

err = nrf_clock_control_request(radio_clk_dev, NULL, &radio_cli);

do {
err = sys_notify_fetch_result(&radio_cli.notify, &res);
if (!err && res) {
LOG_ERR("Clock could not be started: %d", res);
return res;
}
} while (err == -EAGAIN);

#if defined(NRF54L15_XXAA)
/* MLTPAN-20 */
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART);
#endif /* defined(NRF54L15_XXAA) */

LOG_DBG("HF clock started");

return 0;
}

#else
BUILD_ASSERT(false, "No Clock Control driver");
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF2) */

int esb_initialize(void)
{
Expand Down Expand Up @@ -156,12 +195,10 @@ int main(void)

LOG_INF("Enhanced ShockBurst prx sample");

#if defined(CONFIG_CLOCK_CONTROL_NRF)
err = clocks_start();
if (err) {
return 0;
}
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */

err = dk_leds_init();
if (err) {
Expand Down
1 change: 1 addition & 0 deletions samples/esb/esb_ptx/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_ESB=y
CONFIG_DK_LIBRARY=y
CONFIG_CLOCK_CONTROL=y
46 changes: 41 additions & 5 deletions samples/esb/esb_ptx/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#if defined(CONFIG_CLOCK_CONTROL_NRF)
#include <zephyr/drivers/clock_control.h>
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */
#if defined(NRF54L15_XXAA)
#include <hal/nrf_clock.h>
#endif /* defined(NRF54L15_XXAA) */
Expand All @@ -20,6 +18,9 @@
#include <zephyr/kernel.h>
#include <zephyr/types.h>
#include <dk_buttons_and_leds.h>
#if defined(CONFIG_CLOCK_CONTROL_NRF2)
#include <hal/nrf_lrcconf.h>
#endif

LOG_MODULE_REGISTER(esb_ptx, CONFIG_ESB_PTX_APP_LOG_LEVEL);

Expand Down Expand Up @@ -97,7 +98,44 @@ int clocks_start(void)
LOG_DBG("HF clock started");
return 0;
}
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */

#elif defined(CONFIG_CLOCK_CONTROL_NRF2)

int clocks_start(void)
{
int err;
int res;
const struct device *radio_clk_dev =
DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_NODELABEL(radio)));
struct onoff_client radio_cli;

/** Keep radio domain powered all the time to reduce latency. */
nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_1, true);

sys_notify_init_spinwait(&radio_cli.notify);

err = nrf_clock_control_request(radio_clk_dev, NULL, &radio_cli);

do {
err = sys_notify_fetch_result(&radio_cli.notify, &res);
if (!err && res) {
LOG_ERR("Clock could not be started: %d", res);
return res;
}
} while (err == -EAGAIN);

#if defined(NRF54L15_XXAA)
Copy link
Contributor

@grochu grochu Nov 7, 2024

Choose a reason for hiding this comment

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

This section is repeated from the other branch of the #if directive. How is the selection between CONFIG_CLOCK_CONTROL_NRF and CONFIG_CLOCK_CONTROL_NRF2 determined for nRF54L15? Can it use both clock control implementations, or can we avoid the duplicate?

Copy link
Contributor

Choose a reason for hiding this comment

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

For CONFIG_CLOCK_CONTROL_NRF2 it is not needed.

/* MLTPAN-20 */
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART);
#endif /* defined(NRF54L15_XXAA) */

LOG_DBG("HF clock started");
return 0;
}

#else
BUILD_ASSERT(false, "No Clock Control driver");
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF2) */

int esb_initialize(void)
{
Expand Down Expand Up @@ -162,12 +200,10 @@ int main(void)

LOG_INF("Enhanced ShockBurst ptx sample");

#if defined(CONFIG_CLOCK_CONTROL_NRF)
err = clocks_start();
if (err) {
return 0;
}
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */

err = dk_leds_init();
if (err) {
Expand Down
1 change: 1 addition & 0 deletions samples/peripheral/radio_test/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_SHELL=y
CONFIG_DYNAMIC_INTERRUPTS=y

CONFIG_NRFX_TIMER0=y
CONFIG_CLOCK_CONTROL=y

CONFIG_ENTROPY_GENERATOR=y
CONFIG_NRF_SECURITY=y
Expand Down
1 change: 1 addition & 0 deletions samples/peripheral/radio_test/prj_usb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_SHELL=y
CONFIG_DYNAMIC_INTERRUPTS=y

CONFIG_NRFX_TIMER0=y
CONFIG_CLOCK_CONTROL=y

CONFIG_ENTROPY_GENERATOR=y
CONFIG_NRF_SECURITY=y
Expand Down
43 changes: 39 additions & 4 deletions samples/peripheral/radio_test/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
*/

#include <zephyr/sys/printk.h>
#if defined(CONFIG_CLOCK_CONTROL_NRF)
#include <zephyr/drivers/clock_control.h>
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */
#if defined(NRF54L15_XXAA)
#include <hal/nrf_clock.h>
#endif /* defined(NRF54L15_XXAA) */
#if defined(CONFIG_CLOCK_CONTROL_NRF2)
#include <hal/nrf_lrcconf.h>
#endif

#if defined(CONFIG_CLOCK_CONTROL_NRF)
static void clock_init(void)
Expand Down Expand Up @@ -50,15 +51,49 @@ static void clock_init(void)

printk("Clock has started\n");
}

#elif defined(CONFIG_CLOCK_CONTROL_NRF2)

static void clock_init(void)
{
int err;
int res;
const struct device *radio_clk_dev =
DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_NODELABEL(radio)));
struct onoff_client radio_cli;

/** Keep radio domain powered all the time to reduce latency. */
nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_1, true);

sys_notify_init_spinwait(&radio_cli.notify);

err = nrf_clock_control_request(radio_clk_dev, NULL, &radio_cli);

do {
err = sys_notify_fetch_result(&radio_cli.notify, &res);
if (!err && res) {
printk("Clock could not be started: %d\n", res);
return;
}
} while (err == -EAGAIN);

#if defined(NRF54L15_XXAA)
/* MLTPAN-20 */
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART);
#endif /* defined(NRF54L15_XXAA) */

printk("Clock has started\n");
}

#else
BUILD_ASSERT(false, "No Clock Control driver");
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */

int main(void)
{
printk("Starting Radio Test example\n");

#if defined(CONFIG_CLOCK_CONTROL_NRF)
clock_init();
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */

#if defined(CONFIG_SOC_SERIES_NRF54HX)
/* Apply HMPAN-102 workaround for nRF54H series */
Expand Down
Loading