Skip to content

Commit

Permalink
modules: nrfxlib: nrf_802154: Use DPPI and PPIB allocators
Browse files Browse the repository at this point in the history
The GRTC LPTIMER platform implementation now uses the DPPI and PPIB
allocators provided by NRFX, which avoids conflicts with other modules.

Signed-off-by: Rafał Kuźnia <[email protected]>
  • Loading branch information
e-rk authored and jukkar committed Dec 5, 2024
1 parent f11550a commit 4505273
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ void nrf_802154_platform_sl_lptimer_hw_task_local_domain_connections_clear(void)

#elif defined(NRF54L_SERIES)

#include <nrfx_ppib.h>
#include <nrfx_dppi.h>

/* To trigger GRTC.TASKS_CAPTURE[#cc] with RADIO.EVENT_{?}, the following connection chain must be
* created:
* - starting from RADIO domain (_R_):
Expand All @@ -238,71 +241,81 @@ void nrf_802154_platform_sl_lptimer_hw_task_local_domain_connections_clear(void)
* {e} DPPIC_20 <-- GRTC.CC
*/

/* Peripherals used for timestamping - located in radio power domain (_R_) */
/* - DPPIC_L : DPPIC10 */
#define DPPIC_R_INST NRF_DPPIC10
#define PPIB_R_INST NRF_PPIB11
#define INVALID_CHANNEL UINT8_MAX

/* Peripherals used for timestamping - located in peripheral power domain (_P_) */
static nrfx_dppi_t dppi20 = NRFX_DPPI_INSTANCE(20);
static nrfx_ppib_interconnect_t ppib11_21 = NRFX_PPIB_INTERCONNECT_INSTANCE(11, 21);
static uint8_t peri_dppi_ch = INVALID_CHANNEL;
static uint8_t peri_ppib_ch = INVALID_CHANNEL;

/* - DPPIC_P : DPPIC20 */
#define DPPIC_P_INST NRF_DPPIC20
void nrf_802154_platform_sl_lptimer_hw_task_cross_domain_connections_setup(uint32_t cc_channel)
{
nrfx_err_t err;

/* - PPIB_P : PPIB21 */
#define PPIB_P_INST NRF_PPIB21
err = nrfx_dppi_channel_alloc(&dppi20, &peri_dppi_ch);
__ASSERT_NO_MSG(err == NRFX_SUCCESS);

static uint32_t m_dppi_ch = NRF_802154_SL_HW_TASK_PPI_INVALID;
err = nrfx_ppib_channel_alloc(&ppib11_21, &peri_ppib_ch);
__ASSERT_NO_MSG(err == NRFX_SUCCESS);

void nrf_802154_platform_sl_lptimer_hw_task_cross_domain_connections_setup(uint32_t cc_channel)
{
/* Intentionally empty. */
/* {c} PPIB_11 <-- PPIB_21
* One of HW-fixed connections, so nothing to do.
*/

/* {d} PPIB_21 <-- DPPIC_20 */
NRF_DPPI_ENDPOINT_SETUP(
nrfx_ppib_send_task_address_get(&ppib11_21.right, peri_ppib_ch), peri_dppi_ch);

/* {e} DPPIC_20 <-- GRTC.CC */
NRF_DPPI_ENDPOINT_SETUP(
z_nrf_grtc_timer_compare_evt_address_get(cc_channel), peri_dppi_ch);
}

void nrf_802154_platform_sl_lptimer_hw_task_cross_domain_connections_clear(void)
{
/* Intentionally empty. */
nrfx_err_t err;

err = nrfx_ppib_channel_free(&ppib11_21, peri_ppib_ch);
__ASSERT_NO_MSG(err == NRFX_SUCCESS);

err = nrfx_dppi_channel_free(&dppi20, peri_dppi_ch);
__ASSERT_NO_MSG(err == NRFX_SUCCESS);

peri_dppi_ch = INVALID_CHANNEL;
peri_ppib_ch = INVALID_CHANNEL;
}

void nrf_802154_platform_sl_lptimer_hw_task_local_domain_connections_setup(uint32_t dppi_ch,
uint32_t cc_channel)
{
nrfx_err_t err;

if (dppi_ch == NRF_802154_SL_HW_TASK_PPI_INVALID) {
return;
}

m_dppi_ch = dppi_ch;

/* {a} RADIO.TASKS_{?} <-- DPPIC_10[dppi_ch]
* It is the responsibility of the user of this platform to make the {a} connection
* and pass the DPPI channel number as a parameter here.
*/

/* {b} DPPIC_10 <-- PPIB_11 */
nrf_ppib_publish_set(PPIB_R_INST, nrf_ppib_receive_event_get(dppi_ch), dppi_ch);

/* {c} PPIB_11 <-- PPIB_21
* One of HW-fixed connections, so nothing to do.
*/

/* {d} PPIB_21 <-- DPPIC_20 */
nrf_ppib_subscribe_set(PPIB_P_INST, nrf_ppib_send_task_get(dppi_ch), dppi_ch);

/* {e} DPPIC_20 <-- GRTC.CC */
NRF_DPPI_ENDPOINT_SETUP(
z_nrf_grtc_timer_compare_evt_address_get(cc_channel), dppi_ch);
nrfx_ppib_receive_event_address_get(&ppib11_21.left, peri_ppib_ch), dppi_ch);

nrfy_dppi_channels_enable(DPPIC_P_INST, 1UL << dppi_ch);
err = nrfx_dppi_channel_enable(&dppi20, peri_dppi_ch);
__ASSERT_NO_MSG(err == NRFX_SUCCESS);
}

void nrf_802154_platform_sl_lptimer_hw_task_local_domain_connections_clear(void)
{
uint32_t dppi_ch = m_dppi_ch;
nrfx_err_t err;

if (dppi_ch != NRF_802154_SL_HW_TASK_PPI_INVALID) {
nrf_ppib_subscribe_clear(PPIB_R_INST, nrf_ppib_send_task_get(dppi_ch));
nrf_ppib_publish_clear(PPIB_P_INST, nrf_ppib_receive_event_get(dppi_ch));
nrfy_dppi_channels_disable(DPPIC_P_INST, 1UL << dppi_ch);
}
NRF_DPPI_ENDPOINT_CLEAR(
nrfx_ppib_receive_event_address_get(&ppib11_21.left, peri_ppib_ch));

err = nrfx_dppi_channel_disable(&dppi20, peri_dppi_ch);
__ASSERT_NO_MSG(err == NRFX_SUCCESS);
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,37 @@ void nrf_802154_platform_timestamper_local_domain_connections_setup(uint32_t dpp
* {e} DPPIC_20 --> GRTC.CC
*/

/* Peripherals used for timestamping - located in radio power domain (_R_) */
/* - DPPIC_L : DPPIC10 */
#define DPPIC_R_INST NRF_DPPIC10
#define PPIB_R_INST NRF_PPIB11
#include <nrfx_ppib.h>
#include <nrfx_dppi.h>

/* Peripherals used for timestamping - located in peripheral power domain (_P_) */
#define INVALID_CHANNEL UINT8_MAX

/* - DPPIC_P : DPPIC20 */
#define DPPIC_P_INST NRF_DPPIC20

/* - PPIB_P : PPIB21 */
#define PPIB_P_INST NRF_PPIB21
static nrfx_dppi_t dppi20 = NRFX_DPPI_INSTANCE(20);
static nrfx_ppib_interconnect_t ppib11_21 = NRFX_PPIB_INTERCONNECT_INSTANCE(11, 21);
static uint8_t peri_dppi_ch = INVALID_CHANNEL;
static uint8_t peri_ppib_ch = INVALID_CHANNEL;

void nrf_802154_platform_timestamper_cross_domain_connections_setup(void)
{
/* Intentionally empty. */
nrfx_err_t err;

err = nrfx_dppi_channel_alloc(&dppi20, &peri_dppi_ch);
__ASSERT_NO_MSG(err == NRFX_SUCCESS);

err = nrfx_ppib_channel_alloc(&ppib11_21, &peri_ppib_ch);
__ASSERT_NO_MSG(err == NRFX_SUCCESS);

/* {d} PPIB_21 --> DPPIC_20 */
NRF_DPPI_ENDPOINT_SETUP(
nrfx_ppib_receive_event_address_get(&ppib11_21.right, peri_ppib_ch), peri_dppi_ch);

/* {e} DPPIC_20[dppi_ch] --> GRTC.CC[cc_channel] */
nrf_grtc_task_t capture_task =
nrfy_grtc_sys_counter_capture_task_get(m_timestamp_cc_channel);
NRF_DPPI_ENDPOINT_SETUP(nrfy_grtc_task_address_get(NRF_GRTC, capture_task), peri_dppi_ch);

err = nrfx_dppi_channel_enable(&dppi20, peri_dppi_ch);
__ASSERT_NO_MSG(err == NRFX_SUCCESS);
}

void nrf_802154_platform_timestamper_local_domain_connections_setup(uint32_t dppi_ch)
Expand All @@ -255,21 +270,8 @@ void nrf_802154_platform_timestamper_local_domain_connections_setup(uint32_t dpp
*/

/* {b} DPPIC_10 --> PPIB_11 */
nrf_ppib_subscribe_set(PPIB_R_INST, nrf_ppib_send_task_get(dppi_ch), dppi_ch);

/* {c} PPIB_11 --> PPIB_21
* One of HW-fixed connections, so nothing to do.
*/

/* {d} PPIB_21 --> DPPIC_20 */
nrf_ppib_publish_set(PPIB_P_INST, nrf_ppib_receive_event_get(dppi_ch), dppi_ch);

/* {e} DPPIC_20[dppi_ch] --> GRTC.CC[cc_channel] */
nrf_grtc_task_t capture_task =
nrfy_grtc_sys_counter_capture_task_get(m_timestamp_cc_channel);
NRF_DPPI_ENDPOINT_SETUP(nrfy_grtc_task_address_get(NRF_GRTC, capture_task), dppi_ch);

nrfy_dppi_channels_enable(DPPIC_P_INST, 1UL << dppi_ch);
NRF_DPPI_ENDPOINT_SETUP(
nrfx_ppib_send_task_address_get(&ppib11_21.left, peri_ppib_ch), dppi_ch);
}

#endif
Expand Down

0 comments on commit 4505273

Please sign in to comment.