Skip to content

Commit 8b04943

Browse files
e-rkanangl
authored andcommitted
nrf_802154: rev ab926396fe37113664734181cc4dfbb53fb61863
This commit updates revision of the nrf_802154 component. Signed-off-by: Rafał Kuźnia <[email protected]>
1 parent 71308dc commit 8b04943

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1073
-329
lines changed

drivers/nrf_802154/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ add_library(nrf-802154-driver-interface INTERFACE)
3636
add_library(nrf-802154-serialization-interface INTERFACE)
3737

3838
add_subdirectory(common)
39-
4039
add_subdirectory(driver)
4140
add_subdirectory(sl)
42-
4341
add_subdirectory(serialization)
44-
45-
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/internal/CMakeLists.txt)
46-
add_subdirectory(internal)
47-
endif ()

drivers/nrf_802154/common/include/nrf_802154.h

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,29 @@ void nrf_802154_extended_address_set(const uint8_t * p_extended_address);
348348
*/
349349
void nrf_802154_short_address_set(const uint8_t * p_short_address);
350350

351+
/**
352+
* @brief Sets the alternate short address of the device.
353+
*
354+
* The alternate short address should be used when you need to change the
355+
* device short address without loss of connectivity.
356+
* The API addresses a race condition, where a remote peer sends a frame destined
357+
* to the old device address, but this device has already changed the short address
358+
* to a new one. The alternate address should be cleared after a while, after the new
359+
* short address becomes known to the peers.
360+
*
361+
* The API is meant to be used as follows:
362+
* 1. Set the alternate short address to the current old address.
363+
* 2. Set the primary short address (@ref nrf_802154_short_address_set) to the new address.
364+
* 3. Wait until the new short address becomes known among the peers.
365+
* 4. Clear the alternate short address.
366+
*
367+
* @param[in] p_short_address Pointer to the short address (2 bytes, little-endian).
368+
* Setting this value to NULL clears the alternate address.
369+
*
370+
* This function makes a copy of the address.
371+
*/
372+
void nrf_802154_alternate_short_address_set(const uint8_t * p_short_address);
373+
351374
#if !NRF_802154_SERIALIZATION_HOST || defined(DOXYGEN)
352375
/**
353376
* @}
@@ -415,7 +438,12 @@ bool nrf_802154_receive(void);
415438
* If the requested reception time is in the past, the function returns false and does not
416439
* schedule reception.
417440
*
418-
* A scheduled reception can be cancelled by a call to @ref nrf_802154_receive_at_cancel.
441+
* The reception ends after the configured timeout has elapsed. This event is notified to the
442+
* higher layer through the @ref nrf_802154_receive_failed notification with
443+
* @ref NRF_802154_RX_ERROR_DELAYED_TIMEOUT status code.
444+
*
445+
* A scheduled reception can be cancelled by a call to @ref nrf_802154_receive_at_cancel or
446+
* @ref nrf_802154_receive_at_scheduled_cancel.
419447
*
420448
* @note The identifier @p id must be unique. It must not have the same value as identifiers
421449
* of other delayed timeslots active at the moment, so that it can be mapped unambiguously
@@ -427,7 +455,8 @@ bool nrf_802154_receive(void);
427455
* @param[in] channel Radio channel on which the frame is to be received.
428456
* @param[in] id Identifier of the scheduled reception window. If the reception has been
429457
* scheduled successfully, the value of this parameter can be used in
430-
* @ref nrf_802154_receive_at_cancel to cancel it.
458+
* @ref nrf_802154_receive_at_cancel or
459+
* @ref nrf_802154_receive_at_scheduled_cancel to cancel it.
431460
*
432461
* @retval true The reception procedure was scheduled.
433462
* @retval false The driver could not schedule the reception procedure.
@@ -453,6 +482,35 @@ bool nrf_802154_receive_at(uint64_t rx_time,
453482
*/
454483
bool nrf_802154_receive_at_cancel(uint32_t id);
455484

485+
/**
486+
* @brief Cancels a delayed reception scheduled by a call to @ref nrf_802154_receive_at.
487+
*
488+
* If the receive window has been scheduled but has not started yet, this function prevents
489+
* entering the receive window. If the receive window has been scheduled and has already started,
490+
* the receive window is not affected and will continue until its scheduled timeout.
491+
*
492+
* The function also returns success when no window with given ID is scheduled and is not currently
493+
* ongoing.
494+
*
495+
* @note This function differs from @ref nrf_802154_receive_at_cancel in two aspects:
496+
* 1. This function can only cancel receive windows that are scheduled, but haven't started yet.
497+
* If the receive window has already started, the cancel will end with failure and the
498+
* receive window will last for the planned duration, ending with
499+
* @ref nrf_802154_receive_failed notification with @ref NRF_802154_RX_ERROR_DELAYED_TIMEOUT
500+
* status.
501+
* 2. If there are no scheduled and ongoing receive windows matching the given ID,
502+
* the function ends with a success.
503+
*
504+
* @param[in] id Identifier of the delayed reception window to be cancelled. If the provided
505+
* value does not refer to any scheduled or active receive window, the function
506+
* returns true.
507+
*
508+
* @retval true The delayed reception was scheduled and successfully cancelled or the
509+
* receive window was not scheduled at all.
510+
* @retval false The scheduled window is currently ongoing.
511+
*/
512+
bool nrf_802154_receive_at_scheduled_cancel(uint32_t id);
513+
456514
/**
457515
* @brief Changes the radio state to @ref RADIO_STATE_TX.
458516
*

drivers/nrf_802154/common/include/nrf_802154_config.h

Lines changed: 29 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
/**
@@ -97,6 +105,23 @@ extern "C" {
97105
#define NRF_802154_CCA_CORR_LIMIT_DEFAULT 0x02
98106
#endif
99107

108+
/**
109+
* @def NRF_802154_CCAIDLE_TO_TXEN_EXTRA_TIME_US
110+
*
111+
* Additional time in microseconds that delays triggering of @c TXEN after the
112+
* @c CCAIDLE event occurred. Default value for most use-cases is @c 0,
113+
* In this scenario, the short between the @c CCAIDLE event and the
114+
* @c TXEN task is used. If this value is non-zero, the short is not used.
115+
* The triggering of @c TXEN occurs through (D)PPI and TIMER.
116+
* A non-zero value may be necessary to ensure enough switching time for
117+
* use with some Front-End Modules.
118+
*
119+
* This option is supported for the nRF53 Series and the nRF54L Series only.
120+
*/
121+
#ifndef NRF_802154_CCAIDLE_TO_TXEN_EXTRA_TIME_US
122+
#define NRF_802154_CCAIDLE_TO_TXEN_EXTRA_TIME_US 0U
123+
#endif
124+
100125
/**
101126
* @def NRF_802154_INTERNAL_RADIO_IRQ_HANDLING
102127
*

drivers/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;

drivers/nrf_802154/driver/src/mac_features/ack_generator/nrf_802154_enh_ack_generator.c

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ static uint8_t security_key_id_set(const nrf_802154_frame_parser_data_t * p_fram
287287
{
288288
const uint8_t * p_frame_key_id = nrf_802154_frame_parser_key_id_get(p_frame_data);
289289
uint8_t * p_ack_key_id = (uint8_t *)nrf_802154_frame_parser_key_id_get(p_ack_data);
290-
uint8_t key_id_size = key_id_size_get(nrf_802154_frame_parser_sec_ctrl_key_id_mode_get(
291-
p_ack_data));
290+
uint8_t key_id_size =
291+
key_id_size_get(nrf_802154_frame_parser_sec_ctrl_key_id_mode_get(p_ack_data));
292292

293293
if ((p_ack_key_id != NULL) && (p_frame_key_id != NULL))
294294
{
@@ -416,35 +416,6 @@ static void ie_header_set(const uint8_t * p_ie_data,
416416
#endif
417417
}
418418

419-
static uint8_t ie_header_terminate(const uint8_t * p_ie_data,
420-
uint8_t ie_data_len,
421-
nrf_802154_frame_parser_data_t * p_ack_data)
422-
{
423-
if (p_ie_data == NULL)
424-
{
425-
// No IEs to terminate.
426-
return 0U;
427-
}
428-
429-
if ((nrf_802154_frame_parser_security_enabled_bit_is_set(p_ack_data) == false) ||
430-
(nrf_802154_frame_parser_sec_ctrl_sec_lvl_get(p_ack_data) == SECURITY_LEVEL_NONE))
431-
{
432-
// This code assumes that neither regular frame payload nor Payload IEs can be set by the
433-
// driver. Therefore without security, the Ack has no payload, so termination is not necessary.
434-
return 0U;
435-
}
436-
437-
uint8_t * p_ack_ie = (uint8_t *)p_ack_data->p_frame + p_ack_data->helper.aux_sec_hdr_end_offset;
438-
uint8_t ie_hdr_term[IE_HEADER_SIZE];
439-
440-
NRF_802154_ASSERT(p_ack_ie != NULL);
441-
442-
host_16_to_little((IE_HT2) << IE_HEADER_ELEMENT_ID_OFFSET, ie_hdr_term);
443-
444-
memcpy(p_ack_ie + ie_data_len, ie_hdr_term, sizeof(ie_hdr_term));
445-
return sizeof(ie_hdr_term);
446-
}
447-
448419
/***************************************************************************************************
449420
* @section Authentication and encryption transformation
450421
**************************************************************************************************/
@@ -543,8 +514,8 @@ static void ie_process(const nrf_802154_frame_parser_data_t * p_frame_data)
543514
ie_header_set(mp_ie_data, m_ie_data_len, &m_ack_data);
544515
m_ack[PHR_OFFSET] += m_ie_data_len;
545516

546-
// Terminate the IE header if needed.
547-
m_ack[PHR_OFFSET] += ie_header_terminate(mp_ie_data, m_ie_data_len, &m_ack_data) + FCS_SIZE;
517+
// Add space for the FCS field.
518+
m_ack[PHR_OFFSET] += FCS_SIZE;
548519

549520
bool result = nrf_802154_frame_parser_valid_data_extend(&m_ack_data,
550521
m_ack[PHR_OFFSET] + PHR_SIZE,

drivers/nrf_802154/driver/src/mac_features/nrf_802154_delayed_trx.c

Lines changed: 40 additions & 6 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.
@@ -184,7 +187,7 @@ static dly_op_data_t * dly_rx_data_by_id_search(rsch_dly_ts_id_t id)
184187
if (m_dly_rx_data[i].id == id)
185188
{
186189
// Slot with a matching identifier found
187-
if ((p_dly_op_data == NULL))
190+
if (p_dly_op_data == NULL)
188191
{
189192
// It's the first matching slot found
190193
p_dly_op_data = &m_dly_rx_data[i];
@@ -795,9 +798,10 @@ bool nrf_802154_delayed_trx_transmit(uint8_t * p
795798

796799
p_dly_tx_data->tx.p_data = p_data;
797800
p_dly_tx_data->tx.params.frame_props = p_metadata->frame_props;
798-
(void)nrf_802154_tx_power_convert_metadata_to_tx_power_split(p_metadata->channel,
799-
p_metadata->tx_power,
800-
&p_dly_tx_data->tx.params.tx_power);
801+
(void)nrf_802154_tx_power_convert_metadata_to_tx_power_split(
802+
p_metadata->channel,
803+
p_metadata->tx_power,
804+
&p_dly_tx_data->tx.params.tx_power);
801805
p_dly_tx_data->tx.params.cca = p_metadata->cca;
802806
p_dly_tx_data->tx.params.immediate = true;
803807
p_dly_tx_data->tx.params.extra_cca_attempts = p_metadata->extra_cca_attempts;
@@ -918,6 +922,36 @@ bool nrf_802154_delayed_trx_receive_cancel(uint32_t id)
918922
return stopped;
919923
}
920924

925+
bool nrf_802154_delayed_trx_receive_scheduled_cancel(uint32_t id)
926+
{
927+
dly_op_data_t * p_dly_op_data = dly_rx_data_by_id_search(id);
928+
929+
if (p_dly_op_data == NULL)
930+
{
931+
// Delayed receive window with provided ID could not be found.
932+
return true;
933+
}
934+
935+
bool result = nrf_802154_rsch_delayed_timeslot_cancel(id, false);
936+
937+
if (!result)
938+
{
939+
result =
940+
nrf_802154_sl_atomic_load_u8((uint8_t *)&p_dly_op_data->state) ==
941+
DELAYED_TRX_OP_STATE_STOPPED;
942+
}
943+
944+
if (result)
945+
{
946+
p_dly_op_data->id = NRF_802154_RESERVED_INVALID_ID;
947+
948+
nrf_802154_sl_atomic_store_u8((uint8_t *)&p_dly_op_data->state,
949+
DELAYED_TRX_OP_STATE_STOPPED);
950+
}
951+
952+
return result;
953+
}
954+
921955
bool nrf_802154_delayed_trx_abort(nrf_802154_term_t term_lvl, req_originator_t req_orig)
922956
{
923957
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_HIGH);

drivers/nrf_802154/driver/src/mac_features/nrf_802154_delayed_trx.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,22 @@ bool nrf_802154_delayed_trx_receive(uint64_t rx_time,
137137
*/
138138
bool nrf_802154_delayed_trx_receive_cancel(uint32_t id);
139139

140+
/**
141+
* @brief Cancels a scheduled reception scheduled by a call to @ref nrf_802154_delayed_trx_receive.
142+
*
143+
* If the receive window is currently ongoing, it will not be affected and a timeout event will
144+
* be notified at scheduled time.
145+
*
146+
* @param[in] id Identifier of the delayed reception window to be cancelled. If the provided
147+
* value does not refer to any scheduled or active receive window, the function
148+
* returns true.
149+
*
150+
* @retval true Successfully cancelled a scheduled transmission or no window
151+
* with given ID is scheduled.
152+
* @retval false The receive window is currently ongoing.
153+
*/
154+
bool nrf_802154_delayed_trx_receive_scheduled_cancel(uint32_t id);
155+
140156
/**
141157
* @brief Aborts an ongoing delayed reception procedure.
142158
*

drivers/nrf_802154/driver/src/mac_features/nrf_802154_filter.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,19 +337,20 @@ static bool dst_pan_id_check(const uint8_t * p_panid, uint8_t frame_type)
337337
*/
338338
static bool dst_short_addr_check(const uint8_t * p_dst_addr)
339339
{
340-
bool result;
341-
342340
if ((0 == memcmp(p_dst_addr, nrf_802154_pib_short_address_get(), SHORT_ADDRESS_SIZE)) ||
343341
(0 == memcmp(p_dst_addr, BROADCAST_ADDRESS, SHORT_ADDRESS_SIZE)))
344342
{
345-
result = true;
343+
return true;
346344
}
347-
else
345+
346+
const uint8_t * alternate_address = nrf_802154_pib_alternate_short_address_get();
347+
348+
if (alternate_address && (0 == memcmp(p_dst_addr, alternate_address, SHORT_ADDRESS_SIZE)))
348349
{
349-
result = false;
350+
return true;
350351
}
351352

352-
return result;
353+
return false;
353354
}
354355

355356
/**

drivers/nrf_802154/driver/src/mac_features/nrf_802154_frame_parser.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ static bool sec_ctrl_parse(nrf_802154_frame_parser_data_t * p_parser_data)
305305
if (nrf_802154_frame_parser_security_enabled_bit_is_set(p_parser_data) == false)
306306
{
307307
p_parser_data->helper.aux_sec_hdr_end_offset = offset;
308+
p_parser_data->helper.mic_size = 0;
308309
return true;
309310
}
310311

@@ -515,9 +516,10 @@ bool nrf_802154_frame_parser_data_init(const uint8_t * p_frame,
515516
return parse_state_advance(p_parser_data, requested_parse_level);
516517
}
517518

518-
bool nrf_802154_frame_parser_valid_data_extend(nrf_802154_frame_parser_data_t * p_parser_data,
519-
uint8_t valid_data_len,
520-
nrf_802154_frame_parser_level_t requested_parse_level)
519+
bool nrf_802154_frame_parser_valid_data_extend(
520+
nrf_802154_frame_parser_data_t * p_parser_data,
521+
uint8_t valid_data_len,
522+
nrf_802154_frame_parser_level_t requested_parse_level)
521523
{
522524
if (valid_data_len > p_parser_data->valid_data_len)
523525
{

0 commit comments

Comments
 (0)