drivers: nrf_802154: Update the IEEE 802.15.4 component

This commit updates the nRF 802.15.4 radio driver to feature
the latest changes.

sdk-nrf-802154 commit: b60ce8affe251110a8228caea9c8ba45f578b4a3

Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
This commit is contained in:
Artur Hadasz 2022-06-30 09:49:04 +02:00 committed by Robert Lubos
parent 2e1c828cf4
commit 249199ec5a
24 changed files with 104 additions and 308 deletions

View File

@ -44,10 +44,7 @@
#include "nrf_802154_frame_parser.h"
#include <stdlib.h>
#include "nrf_802154_const.h"
#include "nrf_802154_utils.h"
#include "nrf_802154_utils_byteorder.h"
/***************************************************************************************************

View File

@ -159,6 +159,7 @@ bool nrf_802154_security_writer_tx_setup(
nrf_802154_key_id_t key_id;
bool result = false;
key_id.p_key_id = NULL;
m_frame_counter_injected = false;
if (p_params->frame_props.dynamic_data_is_set)

View File

@ -59,7 +59,6 @@
#include "nrf_802154_request.h"
#include "nrf_802154_rx_buffer.h"
#include "nrf_802154_tx_power.h"
#include "nrf_802154_rssi.h"
#include "nrf_802154_stats.h"
#include "hal/nrf_radio.h"
#include "platform/nrf_802154_clock.h"

View File

@ -53,7 +53,6 @@
#include "nrf_802154_critical_section.h"
#include "nrf_802154_debug.h"
#include "nrf_802154_notification.h"
#include "nrf_802154_nrfx_addons.h"
#include "nrf_802154_pib.h"
#include "nrf_802154_procedures_duration.h"
#include "nrf_802154_rssi.h"

View File

@ -51,25 +51,12 @@
extern "C" {
#endif
#ifdef NRF52811_XXAA
#define PIN_DBG_RADIO_EVT_END 13
#define PIN_DBG_RADIO_EVT_DISABLED 14
#define PIN_DBG_RADIO_EVT_READY 17
#define PIN_DBG_RADIO_EVT_FRAMESTART 18
#define PIN_DBG_RADIO_EVT_EDEND 25
#define PIN_DBG_RADIO_EVT_PHYEND 24
#else
#define PIN_DBG_RADIO_EVT_END 11
#define PIN_DBG_RADIO_EVT_DISABLED 12
#define PIN_DBG_RADIO_EVT_READY 13
#define PIN_DBG_RADIO_EVT_FRAMESTART 14
#define PIN_DBG_RADIO_EVT_EDEND 25
#define PIN_DBG_RADIO_EVT_PHYEND 24
#endif
#define PIN_DBG_RADIO_EVT_END 11
#define PIN_DBG_RADIO_EVT_DISABLED 12
#define PIN_DBG_RADIO_EVT_READY 13
#define PIN_DBG_RADIO_EVT_FRAMESTART 14
#define PIN_DBG_RADIO_EVT_EDEND 25
#define PIN_DBG_RADIO_EVT_PHYEND 24
#define PPI_DBG_RADIO_EVT_END 0
#define PPI_DBG_RADIO_EVT_DISABLED 1

View File

@ -50,7 +50,6 @@
#include "nrf_802154.h"
#include "nrf_802154_config.h"
#include "nrf_802154_debug.h"
#include "nrf_802154_peripherals.h"
#include "nrf_802154_queue.h"
#include "nrf_802154_swi.h"
#include "nrf_802154_tx_work_buffer.h"

View File

@ -44,10 +44,10 @@
that the maximum value in EDSAMPLE which can be reported in compliance with the 802.15.4 specification is
255/ED_RSSISCALE. */
#if defined (NRF52840_XXAA) || defined(NRF52811_XXAA)
#if defined (NRF52840_XXAA)
#define ED_RSSIOFFS (-92) ///< dBm value corresponding to value 0 in the EDSAMPLE register.
#define ED_RSSISCALE 4 ///< Factor needed to calculate the ED result based on the data from the RADIO peripheral.
#elif defined (NRF52833_XXAA) || defined(NRF52820_XXAA) || defined(NRF5340_XXAA)
#elif defined (NRF52833_XXAA) || defined(NRF5340_XXAA)
#define ED_RSSIOFFS (-93) ///< dBm value corresponding to value 0 in the EDSAMPLE register.
#define ED_RSSISCALE 5 ///< Factor needed to calculate the ED result based on the data from the RADIO peripheral.
#else

View File

@ -65,7 +65,7 @@ extern "C" {
*
*/
#ifndef NRF_802154_HIGH_PRECISION_TIMER_INSTANCE_NO
#define NRF_802154_HIGH_PRECISION_TIMER_INSTANCE_NO 0
#define NRF_802154_HIGH_PRECISION_TIMER_INSTANCE_NO 1
#endif
/**
@ -84,7 +84,7 @@ extern "C" {
*
*/
#ifndef NRF_802154_TIMER_INSTANCE_NO
#define NRF_802154_TIMER_INSTANCE_NO 1
#define NRF_802154_TIMER_INSTANCE_NO 0
#endif
/**

View File

@ -59,11 +59,7 @@ extern "C" {
*/
#ifndef NRF_802154_EGU_INSTANCE_NO
#if defined(NRF52811_XXAA)
#define NRF_802154_EGU_INSTANCE_NO 0
#else
#define NRF_802154_EGU_INSTANCE_NO 3
#endif
#endif // NRF_802154_EGU_INSTANCE_NO
@ -112,11 +108,7 @@ extern "C" {
*/
#ifndef NRF_802154_RTC_INSTANCE_NO
#if defined(NRF52811_XXAA) || defined(NRF52820_XXAA)
#define NRF_802154_RTC_INSTANCE_NO 0
#else
#define NRF_802154_RTC_INSTANCE_NO 2
#endif
#endif // NRF_802154_RTC_INSTANCE_NO

View File

@ -48,7 +48,6 @@
#include "nrf_802154_core.h"
#include "nrf_802154_critical_section.h"
#include "nrf_802154_debug.h"
#include "nrf_802154_peripherals.h"
#include "nrf_802154_queue.h"
#include "nrf_802154_rx_buffer.h"
#include "nrf_802154_swi.h"

View File

@ -56,8 +56,8 @@ int8_t nrf_802154_rssi_sample_temp_corr_value_get(uint8_t rssi_sample)
int8_t temp = nrf_802154_temperature_get();
int8_t result;
#if defined(NRF52840_XXAA) || defined(NRF52820_XXAA) || defined(NRF52833_XXAA)
/* Implementation based on Errata 153 for nRF52840 SoC and Errata 225 for nRF52820 nRF52833 SoCs.. */
#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA)
/* Implementation based on Errata 153 for nRF52840 SoC and Errata 225 for nRF52833 SoCs.. */
if (temp <= -30)
{
result = 3;

View File

@ -47,7 +47,6 @@
#include "compiler_abstraction.h"
#include "nrf_802154.h"
#include "nrf_802154_config.h"
#include "nrf_802154_peripherals.h"
#include "platform/nrf_802154_irq.h"
#if NRF_802154_INTERNAL_SWI_IRQ_HANDLING

View File

@ -65,9 +65,7 @@
#define EGU_SYNC_INTMASK NRF_EGU_INT_TRIGGERED3
#if defined(NRF52840_XXAA) || \
defined(NRF52833_XXAA) || \
defined(NRF52820_XXAA) || \
defined(NRF52811_XXAA)
defined(NRF52833_XXAA)
#define PPI_CCAIDLE_FEM NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE ///< PPI that connects RADIO CCAIDLE event with GPIOTE tasks used by FEM
#define PPI_CHGRP_ABORT NRF_802154_PPI_ABORT_GROUP ///< PPI group used to disable PPIs when async event aborting radio operation is propagated through the system
#define RADIO_BASE NRF_RADIO_BASE
@ -231,6 +229,7 @@ static void * volatile mp_receive_buffer;
/** Initialize TIMER peripheral used by the driver. */
void nrf_timer_init(void)
{
nrf_timer_task_trigger(NRF_802154_TIMER_INSTANCE, NRF_TIMER_TASK_SHUTDOWN);
nrf_timer_mode_set(NRF_802154_TIMER_INSTANCE, NRF_TIMER_MODE_TIMER);
nrf_timer_bit_width_set(NRF_802154_TIMER_INSTANCE, NRF_TIMER_BIT_WIDTH_32);
nrf_timer_frequency_set(NRF_802154_TIMER_INSTANCE, NRF_TIMER_FREQ_1MHz);
@ -404,9 +403,7 @@ static void fem_for_tx_reset(bool cca)
}
#if defined(NRF52840_XXAA) || \
defined(NRF52833_XXAA) || \
defined(NRF52820_XXAA) || \
defined(NRF52811_XXAA)
defined(NRF52833_XXAA)
/** @brief Applies DEVICE-CONFIG-254.
*
* Shall be called after every RADIO peripheral reset.
@ -476,7 +473,6 @@ void nrf_802154_trx_init(void)
nrf_802154_trx_module_reset();
nrf_timer_init();
#if defined(RADIO_INTENSET_SYNC_Msk)
nrf_802154_swi_init();
#endif
@ -490,12 +486,11 @@ void nrf_802154_trx_enable(void)
assert(m_trx_state == TRX_STATE_DISABLED);
nrf_timer_init();
nrf_radio_reset();
#if defined(NRF52840_XXAA) || \
defined(NRF52833_XXAA) || \
defined(NRF52820_XXAA) || \
defined(NRF52811_XXAA)
defined(NRF52833_XXAA)
// Apply DEVICE-CONFIG-254 if needed.
if (mpsl_fem_device_config_254_apply_get())
{
@ -542,9 +537,7 @@ void nrf_802154_trx_enable(void)
mpsl_fem_pa_is_configured(&m_fem_gain_in_disabled);
#if defined(NRF52840_XXAA) || \
defined(NRF52833_XXAA) || \
defined(NRF52820_XXAA) || \
defined(NRF52811_XXAA)
defined(NRF52833_XXAA)
mpsl_fem_abort_set(nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_DISABLED),
PPI_CHGRP_ABORT);
#elif defined(NRF53_SERIES)

View File

@ -37,66 +37,6 @@
#include "nrf_802154_utils.h"
#include "nrf_802154_fal.h"
/**
* Converts TX power integer values to RADIO TX power allowed values.
*
* @param[in] integer_tx_power TX power integer value.
*
* @retval RADIO TX power allowed value.
*/
static nrf_radio_txpower_t to_radio_tx_power_convert(int8_t integer_tx_power)
{
static const nrf_radio_txpower_t allowed_values[] =
{
#if defined(RADIO_TXPOWER_TXPOWER_Neg40dBm)
NRF_RADIO_TXPOWER_NEG40DBM, /**< -40 dBm. */
#endif
NRF_RADIO_TXPOWER_NEG20DBM, /**< -20 dBm. */
NRF_RADIO_TXPOWER_NEG16DBM, /**< -16 dBm. */
NRF_RADIO_TXPOWER_NEG12DBM, /**< -12 dBm. */
NRF_RADIO_TXPOWER_NEG8DBM, /**< -8 dBm. */
NRF_RADIO_TXPOWER_NEG4DBM, /**< -4 dBm. */
NRF_RADIO_TXPOWER_0DBM, /**< 0 dBm. */
#if defined(RADIO_TXPOWER_TXPOWER_Pos2dBm)
NRF_RADIO_TXPOWER_POS2DBM, /**< 2 dBm. */
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos3dBm)
NRF_RADIO_TXPOWER_POS3DBM, /**< 3 dBm. */
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos4dBm)
NRF_RADIO_TXPOWER_POS4DBM, /**< 4 dBm. */
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos5dBm)
NRF_RADIO_TXPOWER_POS5DBM, /**< 5 dBm. */
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos6dBm)
NRF_RADIO_TXPOWER_POS6DBM, /**< 6 dBm. */
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos7dBm)
NRF_RADIO_TXPOWER_POS7DBM, /**< 7 dBm. */
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos8dBm)
NRF_RADIO_TXPOWER_POS8DBM, /**< 8 dBm. */
#endif
};
nrf_radio_txpower_t radio_tx_power = allowed_values[NUMELTS(allowed_values) - 1];
if (integer_tx_power < (int8_t)radio_tx_power)
{
for (uint32_t i = 0; i < NUMELTS(allowed_values); i++)
{
if (integer_tx_power <= (int8_t)allowed_values[i])
{
radio_tx_power = allowed_values[i];
break;
}
}
}
return radio_tx_power;
}
/**
* Constrains the TX power by the maximum allowed TX power allowed for a specific channel, splits it into
* components to be applied on each stage of the transmit path and for the TX power applied to the RADIO peripheral
@ -124,7 +64,7 @@ static bool constrain_split_and_convert_tx_power(
ret = nrf_802154_fal_tx_power_split(channel, tx_power, &fal_split_power);
split_power->fem_gain = fal_split_power.fem_gain;
split_power->radio_tx_power = to_radio_tx_power_convert(fal_split_power.radio_tx_power);
split_power->radio_tx_power = fal_split_power.radio_tx_power;
return (0 == ret);
}

View File

@ -1,73 +0,0 @@
/*
* Copyright (c) 2017 - 2022, Nordic Semiconductor ASA
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
/**
* @file
* This file implements the pseudo-random number generator abstraction layer.
*
* This pseudo-random number abstraction layer uses newlib's rand_r() function.
*
*/
#define _POSIX_C_SOURCE 1 // Enable access to POSIX functions (rand_r is not from the std library)
#include "platform/nrf_802154_random.h"
#include <stdlib.h>
#include <stdint.h>
#include "nrf.h"
unsigned int m_seed;
void nrf_802154_random_init(void)
{
NRF_RNG->TASKS_START = 1;
while (!NRF_RNG->EVENTS_VALRDY);
NRF_RNG->EVENTS_VALRDY = 0;
NRF_RNG->TASKS_STOP = 1;
m_seed = NRF_RNG->VALUE;
}
void nrf_802154_random_deinit(void)
{
// Intentionally empty
}
uint32_t nrf_802154_random_get(void)
{
return (uint32_t)rand_r(&m_seed);
}

View File

@ -1,73 +0,0 @@
/*
* Copyright (c) 2017 - 2022, Nordic Semiconductor ASA
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
/**
* @file
* This file implements the pseudo-random number generator abstraction layer.
*
* This pseudo-random number abstraction layer uses standard library rand() function.
*
*/
#include "platform/nrf_802154_random.h"
#include <stdlib.h>
#include <stdint.h>
#include "nrf.h"
void nrf_802154_random_init(void)
{
uint32_t seed;
NRF_RNG->TASKS_START = 1;
while (!NRF_RNG->EVENTS_VALRDY);
NRF_RNG->EVENTS_VALRDY = 0;
NRF_RNG->TASKS_STOP = 1;
seed = NRF_RNG->VALUE;
srand((unsigned int)seed);
}
void nrf_802154_random_deinit(void)
{
// Intentionally empty
}
uint32_t nrf_802154_random_get(void)
{
return (uint32_t)rand();
}

View File

@ -44,10 +44,10 @@
that the maximum value in EDSAMPLE which can be reported in compliance with the 802.15.4 specification is
255/ED_RSSISCALE. */
#if defined (NRF52840_XXAA) || defined(NRF52811_XXAA)
#if defined (NRF52840_XXAA)
#define ED_RSSIOFFS (-92) ///< dBm value corresponding to value 0 in the EDSAMPLE register.
#define ED_RSSISCALE 4 ///< Factor needed to calculate the ED result based on the data from the RADIO peripheral.
#elif defined (NRF52833_XXAA) || defined(NRF52820_XXAA) || defined(NRF5340_XXAA)
#elif defined (NRF52833_XXAA) || defined(NRF5340_XXAA)
#define ED_RSSIOFFS (-93) ///< dBm value corresponding to value 0 in the EDSAMPLE register.
#define ED_RSSISCALE 5 ///< Factor needed to calculate the ED result based on the data from the RADIO peripheral.
#else

View File

@ -42,7 +42,6 @@
#include "nrf_802154_serialization_crit_sect.h"
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>

View File

@ -1592,12 +1592,18 @@ void nrf_802154_buffer_free_raw(uint8_t * p_data)
SERIALIZATION_ERROR_CHECK(res, error, bail);
bool removed = nrf_802154_buffer_mgr_dst_remove_by_local_pointer(
nrf_802154_spinel_dst_buffer_mgr_get(),
p_data);
SERIALIZATION_ERROR_IF(!removed,
NRF_802154_SERIALIZATION_ERROR_INVALID_BUFFER,
error,
bail);
res = status_ok_await(CONFIG_NRF_802154_SER_DEFAULT_RESPONSE_TIMEOUT);
SERIALIZATION_ERROR_CHECK(res, error, bail);
(void)nrf_802154_buffer_mgr_dst_remove_by_local_pointer(nrf_802154_spinel_dst_buffer_mgr_get(),
p_data);
bail:
SERIALIZATION_ERROR_RAISE_IF_FAILED(error);

View File

@ -52,7 +52,6 @@
#include "nrf_802154.h"
#include "nrf_802154_config.h"
#include "nrf_802154_const.h"
/**
* @brief Decode and dispatch SPINEL_PROP_VENDOR_NORDIC_NRF_802154_CCA_DONE.

View File

@ -55,18 +55,6 @@ typedef struct
int8_t fem_gain; // !< Gain of the Front-End Module in dB.
} nrf_802154_fal_tx_power_split_t;
/**
* @brief Returns 'power' value.
*
* @note This is a stub implementation used when MPSL is not linked.
*
* @param[in] channel Ignored.
* @param[in] power TX power in dbm.
*
* @returns Value of 'power' argument.
*/
int8_t nrf_802154_fal_tx_power_get(const uint8_t channel, const int8_t power);
/** @brief Splits transmit power value into components to be applied on each stage on the transmit path.
*
* @note This is a stub implementation used when MPSL is not linked.

View File

@ -83,11 +83,7 @@
*/
#ifndef NRF_802154_RTC_INSTANCE_NO
#if defined(NRF52811_XXAA) || defined(NRF52820_XXAA)
#define NRF_802154_RTC_INSTANCE_NO 0
#else
#define NRF_802154_RTC_INSTANCE_NO 2
#endif
#endif // NRF_802154_RTC_INSTANCE_NO
@ -131,7 +127,7 @@
*
*/
#ifndef NRF_802154_HIGH_PRECISION_TIMER_INSTANCE_NO
#define NRF_802154_HIGH_PRECISION_TIMER_INSTANCE_NO 0
#define NRF_802154_HIGH_PRECISION_TIMER_INSTANCE_NO 1
#endif
/**

View File

@ -308,21 +308,17 @@ void mpsl_fem_cleanup(void);
/** @brief Splits transmit power value into components to be applied on each stage on transmit path.
*
* @note If the exact value of @p power cannot be achieved, this function attempts to use less
* power to not exceed constraint. However, if @p power is lower than the minimum achievable power,
* or larger than the maximum achievable power, the function returns failure.
* power to not exceed constraint.
*
* @param[in] power TX power requested for transmission on air.
* @param[out] p_tx_power_split Components of tx_power to be applied for stages on transmit path.
*
* @retval 0 Calculation performed successfully.
* @retval - ::NRF_EINVAL Given @p power cannot be achieved. If requested value is too high
* the @p p_tx_power_split will be set to a value representing maximum
* achievable power. If the requested value is too low, the
* @p p_tx_power_split will be set to a value representing minimum
* achievable power.
* If requested @p power is too high, the split will be set to
* a value representing maximum achievable power. If the requested
* @p power is too low, the split will be set to a value representing
* minimum achievable power.
*/
int32_t mpsl_fem_tx_power_split(const mpsl_tx_power_t power,
mpsl_tx_power_split_t *const p_tx_power_split);
void mpsl_fem_tx_power_split(const mpsl_tx_power_t power,
mpsl_tx_power_split_t *const p_tx_power_split);
/** @brief Sets PA gain.
*

View File

@ -38,6 +38,7 @@
#include <stdint.h>
#include "nrf_802154_fal.h"
#include "nrf_802154_types.h"
#include "protocol/mpsl_fem_protocol_api.h"
@ -45,6 +46,66 @@
extern "C" {
#endif
/**@brief Macro to get the number of elements in an array.
*
* @param[in] X Array.
*/
#define NUMELTS(X) (sizeof((X)) / sizeof(X[0]))
/**
* Converts TX power integer values to RADIO TX power allowed values.
*
* @param[in] integer_tx_power TX power integer value.
*
* @retval RADIO TX power allowed value.
*/
static nrf_radio_txpower_t to_radio_tx_power_convert(int8_t integer_tx_power)
{
static const nrf_radio_txpower_t allowed_values[] =
{
#if defined(RADIO_TXPOWER_TXPOWER_Neg40dBm)
NRF_RADIO_TXPOWER_NEG40DBM, /**< -40 dBm. */
#endif
NRF_RADIO_TXPOWER_NEG20DBM, /**< -20 dBm. */
NRF_RADIO_TXPOWER_NEG16DBM, /**< -16 dBm. */
NRF_RADIO_TXPOWER_NEG12DBM, /**< -12 dBm. */
NRF_RADIO_TXPOWER_NEG8DBM, /**< -8 dBm. */
NRF_RADIO_TXPOWER_NEG4DBM, /**< -4 dBm. */
NRF_RADIO_TXPOWER_0DBM, /**< 0 dBm. */
#if defined(RADIO_TXPOWER_TXPOWER_Pos2dBm)
NRF_RADIO_TXPOWER_POS2DBM, /**< 2 dBm. */
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos3dBm)
NRF_RADIO_TXPOWER_POS3DBM, /**< 3 dBm. */
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos4dBm)
NRF_RADIO_TXPOWER_POS4DBM, /**< 4 dBm. */
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos5dBm)
NRF_RADIO_TXPOWER_POS5DBM, /**< 5 dBm. */
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos6dBm)
NRF_RADIO_TXPOWER_POS6DBM, /**< 6 dBm. */
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos7dBm)
NRF_RADIO_TXPOWER_POS7DBM, /**< 7 dBm. */
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos8dBm)
NRF_RADIO_TXPOWER_POS8DBM, /**< 8 dBm. */
#endif
};
for (uint32_t i = NUMELTS(allowed_values) - 1; i > 0; i--)
{
if (integer_tx_power >= (int8_t)allowed_values[i])
{
return allowed_values[i];
}
}
return allowed_values[0];
}
int32_t mpsl_fem_disable(void)
{
return 0;
@ -112,13 +173,11 @@ void mpsl_fem_cleanup(void)
// Intentionally empty
}
int32_t mpsl_fem_tx_power_split(const mpsl_tx_power_t power,
mpsl_tx_power_split_t * const p_tx_power_split)
void mpsl_fem_tx_power_split(const mpsl_tx_power_t power,
mpsl_tx_power_split_t * const p_tx_power_split)
{
p_tx_power_split->radio_tx_power = power;
p_tx_power_split->radio_tx_power = to_radio_tx_power_convert(power);
p_tx_power_split->fem_gain = 0;
return 0;
}
int32_t mpsl_fem_pa_gain_set(int8_t gain)
@ -150,19 +209,13 @@ bool mpsl_fem_device_config_254_apply_get(void)
return false;
}
int8_t nrf_802154_fal_tx_power_get(const uint8_t channel, const int8_t power)
{
(void)channel;
return power;
}
int32_t nrf_802154_fal_tx_power_split(const uint8_t channel,
const int8_t power,
nrf_802154_fal_tx_power_split_t * const p_tx_power_split)
{
(void)channel;
p_tx_power_split->radio_tx_power = power;
p_tx_power_split->radio_tx_power = to_radio_tx_power_convert(power);
p_tx_power_split->fem_gain = 0;
return 0;