Skip to content

Commit bcd3948

Browse files
committed
nrf_802154: rev 537640fbdd2fc023cc7910d3e59b7bd063c2e65b
This commit updates revision of the nrf_802154 component. Signed-off-by: Rafal Kuznia <[email protected]>
1 parent 2b36f96 commit bcd3948

File tree

14 files changed

+115
-48
lines changed

14 files changed

+115
-48
lines changed

nrf_802154/common/include/nrf_802154_config.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#endif
4141

4242
#include <nrfx.h>
43+
#include "nrf_802154_nrfx_addons.h"
4344

4445
#ifdef __cplusplus
4546
extern "C" {
@@ -68,13 +69,20 @@ extern "C" {
6869
#endif
6970

7071
/**
71-
* @def NRF_802154_CCA_ED_THRESHOLD_DEFAULT
72+
* @def NRF_802154_CCA_ED_THRESHOLD_DBM_DEFAULT
7273
*
73-
* Energy detection threshold used in the CCA procedure.
74+
* Energy detection threshold in dBm used in the CCA procedure.
75+
*
76+
* Note: NRF_802154_CCA_ED_THRESHOLD_DEFAULT is deprecated.
7477
*
7578
*/
76-
#ifndef NRF_802154_CCA_ED_THRESHOLD_DEFAULT
77-
#define NRF_802154_CCA_ED_THRESHOLD_DEFAULT 0x14
79+
#ifdef NRF_802154_CCA_ED_THRESHOLD_DEFAULT
80+
#undef NRF_802154_CCA_ED_THRESHOLD_DBM_DEFAULT
81+
#define NRF_802154_CCA_ED_THRESHOLD_DBM_DEFAULT (ED_RSSIOFFS + NRF_802154_CCA_ED_THRESHOLD_DEFAULT)
82+
#else
83+
#ifndef NRF_802154_CCA_ED_THRESHOLD_DBM_DEFAULT
84+
#define NRF_802154_CCA_ED_THRESHOLD_DBM_DEFAULT (-75)
85+
#endif
7886
#endif
7987

8088
/**

nrf_802154/common/include/nrf_802154_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ typedef uint8_t nrf_802154_term_t;
162162
typedef struct
163163
{
164164
nrf_radio_cca_mode_t mode; // !< CCA mode.
165-
uint8_t ed_threshold; // !< Busy threshold of the CCA energy. Not used in @ref NRF_RADIO_CCA_MODE_CARRIER.
165+
int8_t ed_threshold; // !< Busy threshold of the CCA energy. Not used in @ref NRF_RADIO_CCA_MODE_CARRIER. The threshold is absolute value in dBm.
166166
uint8_t corr_threshold; // !< Busy threshold of the CCA correlator. Not used in @ref NRF_RADIO_CCA_MODE_ED.
167167
uint8_t corr_limit; // !< Limit of occurrences above the busy threshold of the CCA correlator. Not used in @ref NRF_RADIO_CCA_MODE_ED.
168168
} nrf_802154_cca_cfg_t;

nrf_802154/doc/CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ See also :ref:`nrf_802154_limitations` for permanent limitations.
1313
Main branch - nRF 802.15.4 Radio Driver
1414
***************************************
1515

16+
Notable changes
17+
===============
18+
19+
* The configuration macro :c:macro:`NRF_802154_CCA_ED_THRESHOLD_DEFAULT` is deprecated.
20+
It is superseded by the :c:macro:`NRF_802154_CCA_ED_THRESHOLD_DBM_DEFAULT` macro, which specifies the absolute value of the CCA ED threshold in dBm. (KRKNWK-19974)
21+
* The Energy Detection (ED) sample, Received Signal Strength Indicator (RSSI), and Clear Channel Assessment (CCA) threshold now account for Low-Noise Amplifier (LNA) gain.
22+
These values now represent the power at the antenna connector, rather than at the radio. (KRKNWK-19974)
23+
1624
Added
1725
=====
1826

nrf_802154/driver/src/mac_features/nrf_802154_delayed_trx.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include <stdbool.h>
4747
#include <stdint.h>
4848

49+
#include <nrfx.h>
4950
#include "../nrf_802154_debug.h"
5051
#include "nrf_802154_config.h"
5152
#include "nrf_802154_const.h"
@@ -75,8 +76,10 @@
7576
#define TX_SETUP_TIME_MAX 360u ///< Maximum time needed to prepare TX procedure [us]. It does not include TX ramp-up time.
7677
#define RX_SETUP_TIME_MAX 290u ///< Maximum time needed to prepare RX procedure [us]. It does not include RX ramp-up time.
7778
#elif defined(NRF54L_SERIES)
78-
#define TX_SETUP_TIME_MAX 600u ///< Maximum time needed to prepare TX procedure [us]. It does not include TX ramp-up time.
79-
#define RX_SETUP_TIME_MAX 600u ///< Maximum time needed to prepare RX procedure [us]. It does not include RX ramp-up time.
79+
NRF_STATIC_ASSERT(NRF_CONFIG_CPU_FREQ_MHZ == 128,
80+
"Currently nrf-802154 only works when frequency is 128MHz");
81+
#define TX_SETUP_TIME_MAX 185u ///< Maximum time needed to prepare TX procedure [us]. It does not include TX ramp-up time.
82+
#define RX_SETUP_TIME_MAX 150u ///< Maximum time needed to prepare RX procedure [us]. It does not include RX ramp-up time.
8083
#elif defined(NRF54H_SERIES)
8184
#ifndef TX_SETUP_TIME_MAX
8285
#define TX_SETUP_TIME_MAX 400u ///< Maximum time needed to prepare TX procedure [us]. It does not include TX ramp-up time.

nrf_802154/driver/src/nrf_802154_core.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#include "nrf_802154_tx_power.h"
6868
#include "nrf_802154_types_internal.h"
6969
#include "nrf_802154_utils.h"
70+
#include "nrf_802154_nrfx_addons.h"
7071
#include "drivers/nrfx_errors.h"
7172
#include "hal/nrf_radio.h"
7273
#include "mac_features/nrf_802154_filter.h"
@@ -94,10 +95,10 @@
9495
/// Overhead of hardware preparation for ED procedure (aTurnaroundTime) [number of iterations]
9596
#define ED_ITERS_OVERHEAD 2U
9697

97-
#define MAX_CRIT_SECT_TIME 60 ///< Maximal time that the driver spends in single critical section.
98+
#define MAX_CRIT_SECT_TIME 60 ///< Maximal time that the driver spends in single critical section.
9899

99-
#define LQI_VALUE_FACTOR 4 ///< Factor needed to calculate LQI value based on data from RADIO peripheral
100-
#define LQI_MAX 0xff ///< Maximal LQI value
100+
#define LQI_VALUE_FACTOR ED_RSSISCALE ///< Factor needed to calculate LQI value based on data from RADIO peripheral
101+
#define LQI_MAX 0xff ///< Maximal LQI value
101102

102103
/** Get LQI of given received packet. If CRC is calculated by hardware LQI is included instead of CRC
103104
* in the frame. Length is stored in byte with index 0; CRC is 2 last bytes.
@@ -122,7 +123,7 @@ static rx_buffer_t * const mp_current_rx_buffer = &nrf_802154_rx_buffers[0];
122123
static uint8_t * mp_ack; ///< Pointer to Ack frame buffer.
123124
static uint8_t * mp_tx_data; ///< Pointer to the data to transmit.
124125
static uint32_t m_ed_time_left; ///< Remaining time of the current energy detection procedure [us].
125-
static uint8_t m_ed_result; ///< Result of the current energy detection procedure.
126+
static int8_t m_ed_result; ///< Result of the current energy detection procedure.
126127
static uint8_t m_last_lqi; ///< LQI of the last received non-ACK frame, corrected for the temperature.
127128
static nrf_802154_fal_tx_power_split_t m_tx_power; ///< Power to be used to transmit the current frame split into components.
128129
static uint8_t m_tx_channel; ///< Channel to be used to transmit the current frame.
@@ -241,11 +242,7 @@ static void rssi_measurement_wait(void)
241242
*/
242243
static int8_t rssi_last_measurement_get(void)
243244
{
244-
uint8_t rssi_sample = nrf_802154_trx_rssi_last_sample_get();
245-
246-
rssi_sample = nrf_802154_rssi_sample_corrected_get(rssi_sample);
247-
248-
return -((int8_t)rssi_sample);
245+
return nrf_802154_trx_rssi_last_sample_get();
249246
}
250247

251248
/** Get LQI of a received frame.
@@ -2500,15 +2497,11 @@ void nrf_802154_trx_transmit_frame_ccabusy(void)
25002497
nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
25012498
}
25022499

2503-
void nrf_802154_trx_energy_detection_finished(uint8_t ed_sample)
2500+
void nrf_802154_trx_energy_detection_finished(int8_t ed_sample_dbm)
25042501
{
25052502
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
25062503

2507-
if (m_ed_result < ed_sample)
2508-
{
2509-
// Collect maximum value of samples provided by trx
2510-
m_ed_result = ed_sample;
2511-
}
2504+
m_ed_result = MAX(m_ed_result, ed_sample_dbm);
25122505

25132506
if (m_ed_time_left >= ED_ITER_DURATION)
25142507
{
@@ -2536,7 +2529,7 @@ void nrf_802154_trx_energy_detection_finished(uint8_t ed_sample)
25362529

25372530
nrf_802154_energy_detected_t ed_result = {};
25382531

2539-
ed_result.ed_dbm = nrf_802154_rssi_ed_sample_to_dbm_convert(m_ed_result);
2532+
ed_result.ed_dbm = m_ed_result;
25402533

25412534
energy_detected_notify(&ed_result);
25422535
}
@@ -2844,7 +2837,7 @@ bool nrf_802154_core_energy_detection(nrf_802154_term_t term_lvl, uint32_t time_
28442837
}
28452838

28462839
m_ed_time_left = time_us;
2847-
m_ed_result = 0;
2840+
m_ed_result = ED_RSSIOFFS;
28482841

28492842
state_set(RADIO_STATE_ED);
28502843
ed_init();

nrf_802154/driver/src/nrf_802154_pib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ void nrf_802154_pib_init(void)
192192
memset(m_data.extended_addr, 0, sizeof(m_data.extended_addr));
193193

194194
m_data.cca.mode = NRF_802154_CCA_MODE_DEFAULT;
195-
m_data.cca.ed_threshold = NRF_802154_CCA_ED_THRESHOLD_DEFAULT;
195+
m_data.cca.ed_threshold = NRF_802154_CCA_ED_THRESHOLD_DBM_DEFAULT;
196196
m_data.cca.corr_threshold = NRF_802154_CCA_CORR_THRESHOLD_DEFAULT;
197197
m_data.cca.corr_limit = NRF_802154_CCA_CORR_LIMIT_DEFAULT;
198198

nrf_802154/driver/src/nrf_802154_rssi.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#if defined(NRF52_SERIES)
5050

5151
/* Implementation for nRF52 family. */
52-
int8_t nrf_802154_rssi_sample_temp_corr_value_get(uint8_t rssi_sample)
52+
static int8_t nrf_802154_rssi_sample_temp_corr_value_get(uint8_t rssi_sample)
5353
{
5454
(void)rssi_sample;
5555

@@ -99,7 +99,7 @@ int8_t nrf_802154_rssi_sample_temp_corr_value_get(uint8_t rssi_sample)
9999
return result;
100100
}
101101

102-
#else
102+
#elif defined(NRF53_SERIES)
103103

104104
/** Macro for calculating x raised to the power of 2. */
105105
#define POW_2(x) ((x) * (x))
@@ -137,7 +137,7 @@ static int8_t normalize_rssi(int32_t rssi_value)
137137
}
138138

139139
/* Implementation based on Errata 87 for nRF53 family. */
140-
int8_t nrf_802154_rssi_sample_temp_corr_value_get(uint8_t rssi_sample)
140+
static int8_t nrf_802154_rssi_sample_temp_corr_value_get(uint8_t rssi_sample)
141141
{
142142
int32_t temp;
143143
int32_t rssi_sample_i32;
@@ -154,6 +154,13 @@ int8_t nrf_802154_rssi_sample_temp_corr_value_get(uint8_t rssi_sample)
154154
return compensated_rssi - (int8_t)rssi_sample;
155155
}
156156

157+
#else
158+
159+
static int8_t nrf_802154_rssi_sample_temp_corr_value_get(uint8_t rssi_sample)
160+
{
161+
return 0;
162+
}
163+
157164
#endif
158165

159166
uint8_t nrf_802154_rssi_sample_corrected_get(uint8_t rssi_sample)
@@ -213,3 +220,13 @@ int8_t nrf_802154_rssi_ed_sample_to_dbm_convert(uint8_t ed_sample)
213220

214221
return result;
215222
}
223+
224+
uint8_t nrf_802154_rssi_dbm_to_hw(int8_t dbm)
225+
{
226+
return dbm - ED_RSSIOFFS;
227+
}
228+
229+
int8_t nrf_802154_rssi_hw_to_dbm(uint8_t hwval)
230+
{
231+
return hwval + ED_RSSIOFFS;
232+
}

nrf_802154/driver/src/nrf_802154_rssi.h

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,6 @@
4444
* @brief RSSI calculations used internally in the 802.15.4 driver.
4545
*/
4646

47-
/**
48-
* @brief Gets the RSSISAMPLE temperature correction value.
49-
*
50-
* The correction value is based on the last temperature value reported by the platform.
51-
*
52-
* @param[in] rssi_sample Value read from the RSSISAMPLE register.
53-
*
54-
* @returns RSSISAMPLE temperature correction value.
55-
*/
56-
int8_t nrf_802154_rssi_sample_temp_corr_value_get(uint8_t rssi_sample);
57-
5847
/**
5948
* @brief Adjusts the given RSSISAMPLE value by a temperature correction factor.
6049
*
@@ -120,6 +109,24 @@ int8_t nrf_802154_rssi_dbm_from_energy_level_calculate(uint8_t energy_level);
120109
*/
121110
int8_t nrf_802154_rssi_ed_sample_to_dbm_convert(uint8_t ed_sample);
122111

112+
/**
113+
* @brief Converts the a dBm value to radio hardware value.
114+
*
115+
* @param[in] dbm The dBm value.
116+
*
117+
* @return Value in hardware units.
118+
*/
119+
uint8_t nrf_802154_rssi_dbm_to_hw(int8_t dbm);
120+
121+
/**
122+
* @brief Converts the a radio hardware value to dBm value.
123+
*
124+
* @param[in] hwval The radio hardware value.
125+
*
126+
* @return Value in dBm.
127+
*/
128+
int8_t nrf_802154_rssi_hw_to_dbm(uint8_t hwval);
129+
123130
/**
124131
*@}
125132
**/

nrf_802154/driver/src/nrf_802154_trx.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,17 @@ static void channel_set(uint8_t channel)
572572
static void cca_configuration_update(void)
573573
{
574574
nrf_802154_cca_cfg_t cca_cfg;
575+
uint8_t threshold_hw;
576+
int8_t lna_gain_db = 0;
575577

576578
nrf_802154_pib_cca_cfg_get(&cca_cfg);
579+
mpsl_fem_lna_is_configured(&lna_gain_db);
580+
581+
threshold_hw = nrf_802154_rssi_dbm_to_hw(cca_cfg.ed_threshold + lna_gain_db);
582+
577583
nrf_radio_cca_configure(NRF_RADIO,
578584
cca_cfg.mode,
579-
nrf_802154_rssi_cca_ed_threshold_corrected_get(cca_cfg.ed_threshold),
585+
nrf_802154_rssi_cca_ed_threshold_corrected_get(threshold_hw),
580586
cca_cfg.corr_threshold,
581587
cca_cfg.corr_limit);
582588
}
@@ -1514,7 +1520,15 @@ bool nrf_802154_trx_rssi_measure_is_started(void)
15141520

15151521
uint8_t nrf_802154_trx_rssi_last_sample_get(void)
15161522
{
1517-
return nrf_radio_rssi_sample_get(NRF_RADIO);
1523+
int8_t lna_gain_db = 0;
1524+
uint8_t rssi_sample_minus_dbm = nrf_radio_rssi_sample_get(NRF_RADIO);
1525+
uint8_t rssi_sample_corrected_minus_dbm =
1526+
nrf_802154_rssi_sample_corrected_get(rssi_sample_minus_dbm);
1527+
int8_t rssi_sample_corrected_dbm = -((int8_t)rssi_sample_corrected_minus_dbm);
1528+
1529+
mpsl_fem_lna_is_configured(&lna_gain_db);
1530+
1531+
return rssi_sample_corrected_dbm - lna_gain_db;
15181532
}
15191533

15201534
bool nrf_802154_trx_rssi_sample_is_available(void)
@@ -2848,12 +2862,16 @@ static void irq_handler_edend(void)
28482862

28492863
NRF_802154_ASSERT(m_trx_state == TRX_STATE_ENERGY_DETECTION);
28502864

2851-
uint8_t ed_sample = nrf_radio_ed_sample_get(NRF_RADIO);
2865+
int8_t lna_gain_db = 0;
2866+
uint8_t ed_sample_hw = nrf_radio_ed_sample_get(NRF_RADIO);
2867+
int8_t ed_sample_dbm = nrf_802154_rssi_ed_sample_to_dbm_convert(ed_sample_hw);
28522868

28532869
energy_detection_finish();
28542870
m_trx_state = TRX_STATE_FINISHED;
28552871

2856-
nrf_802154_trx_energy_detection_finished(ed_sample);
2872+
mpsl_fem_lna_is_configured(&lna_gain_db);
2873+
2874+
nrf_802154_trx_energy_detection_finished(ed_sample_dbm - lna_gain_db);
28572875

28582876
nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
28592877
}

nrf_802154/driver/src/nrf_802154_trx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,9 @@ extern void nrf_802154_trx_standalone_cca_finished(bool channel_was_idle);
776776
* - @ref nrf_802154_trx_go_idle,
777777
* - @ref nrf_802154_trx_disable.
778778
*
779-
* @param ed_sample Sample of detected energy.
779+
* @param ed_sample_dbm Sample of detected energy.
780780
*/
781-
extern void nrf_802154_trx_energy_detection_finished(uint8_t ed_sample);
781+
extern void nrf_802154_trx_energy_detection_finished(int8_t ed_sample_dbm);
782782

783783
/**@brief Returns RADIO->EVENTS_END handle that hardware can subscribe to.
784784
*

0 commit comments

Comments
 (0)