From ce0a5747908129d889697dea1e925543db6ceb65 Mon Sep 17 00:00:00 2001 From: Andrzej Kuros Date: Thu, 21 Nov 2024 13:38:25 +0100 Subject: [PATCH] fem_al: use nrfx_dppi_channel_alloc nrfx 3.8.0 The fem_deactivate_evt.event.generic.event for the DPPI version should be a number of a DPPI channel that given event publishes to. In the nrfx 3.8.0 the function `nrfx_gppi_channel_alloc` for nRF54L does not return a DPPI channel number but "virtual" gppi channel number. There is no more direct relationship between gppi channel number and underlying dppi channel number. Because of above the `nrfx_dppi_channel_alloc` function is used which guarantees to return DPPI channel number. The proper DPPIC controller must also be selected due to multiple instances of DPPIC on nRF54L devices. The instance within radio power domain is used. Signed-off-by: Andrzej Kuros --- lib/fem_al/fem_al.c | 50 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/lib/fem_al/fem_al.c b/lib/fem_al/fem_al.c index 64cde6c392fc..d87de7f9083a 100644 --- a/lib/fem_al/fem_al.c +++ b/lib/fem_al/fem_al.c @@ -9,7 +9,9 @@ #include #include -#include +#ifdef DPPI_PRESENT +#include +#endif #include #include @@ -21,6 +23,16 @@ #include "fem_interface.h" #include "radio_def.h" +#ifdef DPPI_PRESENT +#if defined(NRF53_SERIES) +#define RADIO_DOMAIN_NRFX_DPPI_INSTANCE NRFX_DPPI_INSTANCE(0) +#elif defined(NRF54L_SERIES) +#define RADIO_DOMAIN_NRFX_DPPI_INSTANCE NRFX_DPPI_INSTANCE(10) +#else +#error Unsupported SoC type. +#endif +#endif + static const struct fem_interface_api *fem_api; static mpsl_fem_event_t fem_activate_event = { @@ -283,6 +295,29 @@ int8_t fem_default_tx_output_power_get(void) return 0; } +#if defined(DPPI_PRESENT) +static nrfx_err_t radio_domain_nrfx_dppi_channel_alloc(uint8_t *channel) +{ + nrfx_err_t err; + nrfx_dppi_t radio_domain_nrfx_dppi = RADIO_DOMAIN_NRFX_DPPI_INSTANCE; + + err = nrfx_dppi_channel_alloc(&radio_domain_nrfx_dppi, channel); + + return err; +} + +static void radio_domain_nrfx_dppi_channel_enable(uint8_t channel) +{ + nrfx_err_t err; + nrfx_dppi_t radio_domain_nrfx_dppi = RADIO_DOMAIN_NRFX_DPPI_INSTANCE; + + err = nrfx_dppi_channel_enable(&radio_domain_nrfx_dppi, channel); + + __ASSERT_NO_MSG(err == NRFX_SUCCESS); + (void)err; +} +#endif + int fem_init(NRF_TIMER_Type *timer_instance, uint8_t compare_channel_mask) { if (!timer_instance || (compare_channel_mask == 0)) { @@ -294,19 +329,18 @@ int fem_init(NRF_TIMER_Type *timer_instance, uint8_t compare_channel_mask) #if defined(DPPI_PRESENT) nrfx_err_t err; - uint8_t fem_generic_dppi; + uint8_t fem_dppi_ch; - err = nrfx_gppi_channel_alloc(&fem_generic_dppi); + err = radio_domain_nrfx_dppi_channel_alloc(&fem_dppi_ch); if (err != NRFX_SUCCESS) { - printk("gppi_channel_alloc failed with: %d\n", err); + printk("radio_domain_nrfx_dppi_channel_alloc failed with: %d\n", err); return -ENODEV; } - fem_deactivate_evt.event.generic.event = fem_generic_dppi; + fem_deactivate_evt.event.generic.event = fem_dppi_ch; - nrfx_gppi_event_endpoint_setup(fem_generic_dppi, - nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_DISABLED)); - nrfx_gppi_channels_enable(BIT(fem_generic_dppi)); + nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_DISABLED, fem_dppi_ch); + radio_domain_nrfx_dppi_channel_enable(fem_dppi_ch); #elif defined(PPI_PRESENT) fem_deactivate_evt.event.generic.event = nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);