Skip to content

Commit f304e7a

Browse files
committed
Clock test
1 parent 2b9c51b commit f304e7a

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

modules/hal_nordic/nrf_802154/sl_opensource/platform/nrf_802154_clock_zephyr.c

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,31 @@
1313
#include <zephyr/kernel.h>
1414
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
1515
#include <nrf_sys_event.h>
16+
#include <hal/nrf_egu.h>
17+
18+
#define NTF_INT NRFX_CONCAT_2(NRF_EGU_INT_TRIGGERED, NRF_802154_SL_EGU_CLOCK_CHANNEL_NO)
19+
#define NTF_TASK NRFX_CONCAT_2(NRF_EGU_TASK_TRIGGER, NRF_802154_SL_EGU_CLOCK_CHANNEL_NO)
20+
#define NTF_EVENT NRFX_CONCAT_2(NRF_EGU_EVENT_TRIGGERED, NRF_802154_SL_EGU_CLOCK_CHANNEL_NO)
1621

1722
static bool hfclk_is_running;
1823

24+
/* Forward declaration. */
25+
static void hfclk_stop(void);
26+
1927
void nrf_802154_clock_init(void)
2028
{
2129
#ifdef NRF54L_SERIES
2230
uint32_t clock_latency_us = z_nrf_clock_bt_ctlr_hf_get_startup_time_us();
2331

2432
nrf_802154_clock_hfclk_latency_set(clock_latency_us);
2533
#endif
34+
35+
nrf_egu_int_enable(NRF_802154_EGU_INSTANCE, NTF_INT);
2636
}
2737

2838
void nrf_802154_clock_deinit(void)
2939
{
30-
/* Intentionally empty. */
40+
nrf_egu_int_disable(NRF_802154_EGU_INSTANCE, NTF_INT);
3141
}
3242

3343
bool nrf_802154_clock_hfclk_is_running(void)
@@ -47,6 +57,21 @@ static void hfclk_on_callback(struct onoff_manager *mgr,
4757
nrf_802154_clock_hfclk_ready();
4858
}
4959

60+
void nrf_802154_sl_clock_swi_irq_handler(void)
61+
{
62+
if (nrf_egu_event_check(NRF_802154_EGU_INSTANCE, NTF_EVENT))
63+
{
64+
nrf_egu_event_clear(NRF_802154_EGU_INSTANCE, NTF_EVENT);
65+
66+
hfclk_stop();
67+
}
68+
}
69+
70+
void nrf_802154_clock_hfclk_stop(void)
71+
{
72+
nrf_egu_task_trigger(NRF_802154_EGU_INSTANCE, NTF_TASK);
73+
}
74+
5075
#if defined(CONFIG_CLOCK_CONTROL_NRF)
5176
void nrf_802154_clock_hfclk_start(void)
5277
{
@@ -70,13 +95,15 @@ void nrf_802154_clock_hfclk_start(void)
7095
(void)ret;
7196
}
7297

73-
void nrf_802154_clock_hfclk_stop(void)
98+
static void hfclk_stop(void)
7499
{
75100
struct onoff_manager *mgr =
76-
z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
101+
z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
77102

78103
__ASSERT_NO_MSG(mgr != NULL);
79104

105+
unsigned int key = irq_lock();
106+
80107
int ret = onoff_cancel_or_release(mgr, &hfclk_cli);
81108
__ASSERT_NO_MSG(ret >= 0);
82109
(void)ret;
@@ -86,6 +113,8 @@ void nrf_802154_clock_hfclk_stop(void)
86113
}
87114

88115
hfclk_is_running = false;
116+
117+
irq_unlock(key);
89118
}
90119

91120
#elif DT_NODE_HAS_STATUS(DT_NODELABEL(hfxo), okay) && \
@@ -100,7 +129,7 @@ void nrf_802154_clock_hfclk_start(void)
100129
(void)ret;
101130
}
102131

103-
void nrf_802154_clock_hfclk_stop(void)
132+
static void hfclk_stop(void)
104133
{
105134
int ret = nrf_clock_control_cancel_or_release(DEVICE_DT_GET(DT_NODELABEL(hfxo)),
106135
NULL, &hfclk_cli);

0 commit comments

Comments
 (0)