Skip to content

Commit e4a6c44

Browse files
nordic-krchcarlescufi
authored andcommitted
modules: nrfxlib: nrf_802154: Fix control of PPI channels
Rework implementation of local domain and cross domain connections setup. Local domain connections happens frequent from an interrupt context so need to be fast. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 362313a commit e4a6c44

File tree

2 files changed

+47
-32
lines changed

2 files changed

+47
-32
lines changed

modules/nrfxlib/nrf_802154/sl/platform/nrf_802154_platform_sl_lptimer_grtc_hw_task.c

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -244,47 +244,55 @@ void nrf_802154_platform_sl_lptimer_hw_task_local_domain_connections_clear(void)
244244
#define INVALID_CHANNEL UINT8_MAX
245245

246246
static nrfx_gppi_handle_t peri_rad_handle;
247+
static uint32_t ppib_chan;
247248

248249
void nrf_802154_platform_sl_lptimer_hw_task_cross_domain_connections_setup(uint32_t cc_channel)
249-
{
250-
ARG_UNUSED(cc_channel);
251-
}
252-
253-
void nrf_802154_platform_sl_lptimer_hw_task_cross_domain_connections_clear(void)
254-
{
255-
nrfx_gppi_domain_conn_free(peri_rad_handle);
256-
}
257-
258-
void nrf_802154_platform_sl_lptimer_hw_task_local_domain_connections_setup(uint32_t dppi_ch,
259-
uint32_t cc_channel)
260250
{
261251
nrfx_gppi_resource_t resource = {
262252
.domain_id = NRFX_GPPI_DOMAIN_RAD,
263-
.channel = dppi_ch
253+
.channel = 0
264254
};
265255
uint32_t eep = z_nrf_grtc_timer_compare_evt_address_get(cc_channel);
266256
int err;
267257

268-
if (dppi_ch == NRF_802154_SL_HW_TASK_PPI_INVALID) {
269-
return;
270-
}
271-
272-
/* Setup a connection between Peri and Rad domain. For Rad domain use provided channel.
273-
* Remaining resources (bridge and dppi channel in PERI) allocate dynamically.
274-
*/
275258
err = nrfx_gppi_ext_conn_alloc(NRFX_GPPI_DOMAIN_PERI, NRFX_GPPI_DOMAIN_RAD,
276259
&peri_rad_handle, &resource);
277260
__ASSERT_NO_MSG(err == 0);
278261

262+
/* Add event endpoint (GRTC compare) to the previously configured connection. */
279263
err = nrfx_gppi_ep_attach(eep, peri_rad_handle);
280264
__ASSERT_NO_MSG(err == 0);
281265

266+
/* Get PPIB channel used in the connection. */
267+
ppib_chan = nrfx_gppi_domain_channel_get(peri_rad_handle, NRFX_GPPI_NODE_PPIB11_21);
268+
__ASSERT_NO_MSG(ppib_chan >= 0);
269+
270+
/* Disable PPIB for now until exact channel from RADIO domain is known. */
271+
nrf_ppib_publish_clear(NRF_PPIB11, nrf_ppib_receive_event_get(ppib_chan));
272+
282273
nrfx_gppi_conn_enable(peri_rad_handle);
283274
}
284275

285-
void nrf_802154_platform_sl_lptimer_hw_task_local_domain_connections_clear(void)
276+
void nrf_802154_platform_sl_lptimer_hw_task_cross_domain_connections_clear(void)
286277
{
287278
nrfx_gppi_conn_disable(peri_rad_handle);
279+
nrfx_gppi_domain_conn_free(peri_rad_handle);
280+
}
281+
282+
void nrf_802154_platform_sl_lptimer_hw_task_local_domain_connections_setup(uint32_t dppi_ch,
283+
uint32_t cc_channel)
284+
{
285+
if (dppi_ch == NRF_802154_SL_HW_TASK_PPI_INVALID) {
286+
return;
287+
}
288+
289+
/* Configure PPIB to forward GRTC event to the DPPI channel from the Radio domain. */
290+
nrf_ppib_publish_set(NRF_PPIB11, nrf_ppib_receive_event_get(ppib_chan), dppi_ch);
291+
}
292+
293+
void nrf_802154_platform_sl_lptimer_hw_task_local_domain_connections_clear(void)
294+
{
295+
nrf_ppib_publish_clear(NRF_PPIB11, nrf_ppib_receive_event_get(ppib_chan));
288296
}
289297

290298
#endif

modules/nrfxlib/nrf_802154/sl/platform/nrf_802154_platform_timestamper.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,37 +231,44 @@ void nrf_802154_platform_timestamper_local_domain_connections_setup(uint32_t dpp
231231
#include <soc/interconnect/nrfx_gppi_lumos.h>
232232

233233
static nrfx_gppi_handle_t rad_peri_handle;
234+
static uint32_t ppib_chan;
234235

235236
void nrf_802154_platform_timestamper_cross_domain_connections_setup(void)
236237
{
237-
__ASSERT_NO_MSG(rad_peri_handle != 0);
238+
nrfx_gppi_resource_t resource = {
239+
.domain_id = NRFX_GPPI_DOMAIN_RAD,
240+
.channel = 0
241+
};
238242
nrf_grtc_task_t capture_task =
239243
nrfy_grtc_sys_counter_capture_task_get(m_timestamp_cc_channel);
240244
uint32_t tep = nrfy_grtc_task_address_get(NRF_GRTC, capture_task);
241245
int err;
242246

247+
err = nrfx_gppi_ext_conn_alloc(NRFX_GPPI_DOMAIN_RAD, NRFX_GPPI_DOMAIN_PERI,
248+
&rad_peri_handle, &resource);
249+
__ASSERT_NO_MSG(err == 0);
250+
243251
/* Add task endpoint (GRTC capture) to the previously configured connection. */
244252
err = nrfx_gppi_ep_attach(tep, rad_peri_handle);
245253
__ASSERT_NO_MSG(err == 0);
246254

255+
/* Get PPIB channel used in the connection. */
256+
ppib_chan = nrfx_gppi_domain_channel_get(rad_peri_handle, NRFX_GPPI_NODE_PPIB11_21);
257+
__ASSERT_NO_MSG(ppib_chan >= 0);
258+
259+
/* Disable PPIB for now until exact channel from RADIO domain is known. */
260+
nrf_ppib_subscribe_clear(NRF_PPIB11, nrf_ppib_send_task_get(ppib_chan));
261+
247262
nrfx_gppi_conn_enable(rad_peri_handle);
248263
}
249264

250265
void nrf_802154_platform_timestamper_local_domain_connections_setup(uint32_t dppi_ch)
251266
{
252-
nrfx_gppi_resource_t resource = {
253-
.domain_id = NRFX_GPPI_DOMAIN_RAD,
254-
.channel = dppi_ch
255-
};
256-
int err;
257-
258267
z_nrf_grtc_timer_capture_prepare(m_timestamp_cc_channel);
259-
/* Setup a connection between Rad and Peri domain. For Rad domain use provided channel.
260-
* Remaining resources (bridge and dppi channel in PERI) allocate dynamically.
268+
/* Configure PPIB to forward provided DPPI channel from Radio domain and enable
269+
* the connection.
261270
*/
262-
err = nrfx_gppi_ext_conn_alloc(NRFX_GPPI_DOMAIN_RAD, NRFX_GPPI_DOMAIN_PERI,
263-
&rad_peri_handle, &resource);
264-
__ASSERT_NO_MSG(err == 0);
271+
nrf_ppib_subscribe_set(NRF_PPIB11, nrf_ppib_send_task_get(ppib_chan), dppi_ch);
265272
}
266273

267274
#endif

0 commit comments

Comments
 (0)