Skip to content

Commit

Permalink
fem_al: use nrfx_dppi_channel_alloc nrfx 3.8.0
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ankuns authored and rlubos committed Dec 3, 2024
1 parent f354363 commit ce0a574
Showing 1 changed file with 42 additions and 8 deletions.
50 changes: 42 additions & 8 deletions lib/fem_al/fem_al.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

#include <hal/nrf_radio.h>
#include <hal/nrf_timer.h>
#include <helpers/nrfx_gppi.h>
#ifdef DPPI_PRESENT
#include <nrfx_dppi.h>
#endif
#include <nrf_erratas.h>

#include <zephyr/sys/printk.h>
Expand All @@ -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 = {
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down

0 comments on commit ce0a574

Please sign in to comment.