Skip to content

Commit 14d7496

Browse files
e-rkrlubos
authored andcommitted
nrf_802154: rev 0f7ea29d2ae899d52c3dd0ce2355dc4d4176b2b8
This commit updates revision of the nrf_802154 component. Signed-off-by: Rafal Kuznia <[email protected]>
1 parent 0c29eb8 commit 14d7496

32 files changed

+848
-908
lines changed

nrf_802154/common/include/nrf_802154.h

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ extern "C" {
9292
#define NRF_802154_MAX_PENDING_NOTIFICATIONS \
9393
(NRF_802154_RX_BUFFERS + NRF_802154_MAX_DISREGARDABLE_NOTIFICATIONS + 4 + 1)
9494

95+
/**
96+
* @brief Temporary macro to detect new API signatures.
97+
*
98+
* The macro is used during transition to new API declarations, where the TX functions return
99+
* an error code instead of a boolean value.
100+
*/
101+
#define NRF_802154_TX_FUNCTIONS_RETURN_ERROR_CODE
102+
95103
/**
96104
* @brief Initializes the 802.15.4 driver.
97105
*
@@ -548,11 +556,14 @@ bool nrf_802154_receive_at_scheduled_cancel(uint32_t id);
548556
* @c cca | @c true
549557
* @c tx_timestamp_encode | @c false
550558
*
551-
* @retval true The transmission procedure was scheduled.
552-
* @retval false The driver could not schedule the transmission procedure.
559+
* @retval NRF_802154_TX_ERROR_NONE The TX request was successful.
560+
* Transmit success or failure will be indicated by the callout.
561+
*
562+
* @returns Error that prevented the frame from being transmitted.
563+
* No callout will be called.
553564
*/
554-
bool nrf_802154_transmit_raw(uint8_t * p_data,
555-
const nrf_802154_transmit_metadata_t * p_metadata);
565+
nrf_802154_tx_error_t nrf_802154_transmit_raw(uint8_t * p_data,
566+
const nrf_802154_transmit_metadata_t * p_metadata);
556567

557568
/**
558569
* @brief Requests transmission at the specified time.
@@ -627,12 +638,16 @@ bool nrf_802154_transmit_raw(uint8_t * p_data,
627638
* @c extra_cca_attempts | @c 0
628639
* @c tx_timestamp_encode | @c 0
629640
*
630-
* @retval true The transmission procedure was scheduled.
631-
* @retval false The driver could not schedule the transmission procedure.
641+
* @retval NRF_802154_TX_ERROR_NONE The TX request was successful.
642+
* Transmit success or failure will be indicated by the callout.
643+
*
644+
* @returns Error that prevented the frame from being transmitted.
645+
* No callout will be called.
632646
*/
633-
bool nrf_802154_transmit_raw_at(uint8_t * p_data,
634-
uint64_t tx_time,
635-
const nrf_802154_transmit_at_metadata_t * p_metadata);
647+
nrf_802154_tx_error_t nrf_802154_transmit_raw_at(
648+
uint8_t * p_data,
649+
uint64_t tx_time,
650+
const nrf_802154_transmit_at_metadata_t * p_metadata);
636651

637652
/**
638653
* @brief Cancels a delayed transmission scheduled by a call to @ref nrf_802154_transmit_raw_at.
@@ -1085,11 +1100,15 @@ void nrf_802154_cca_cfg_get(nrf_802154_cca_cfg_t * p_cca_cfg);
10851100
* @c frame_props | @ref NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT
10861101
* @c tx_timestamp_encode | false
10871102
*
1088-
* @retval true The chain of CSMA-CA and transmission procedure was scheduled.
1089-
* @retval false The driver could not schedule the procedure chain.
1103+
* @retval NRF_802154_TX_ERROR_NONE The TX request was successful.
1104+
* Transmit success or failure will be indicated by the callout.
1105+
*
1106+
* @returns Error that prevented the frame from being transmitted.
1107+
* No callout will be called.
10901108
*/
1091-
bool nrf_802154_transmit_csma_ca_raw(uint8_t * p_data,
1092-
const nrf_802154_transmit_csma_ca_metadata_t * p_metadata);
1109+
nrf_802154_tx_error_t nrf_802154_transmit_csma_ca_raw(
1110+
uint8_t * p_data,
1111+
const nrf_802154_transmit_csma_ca_metadata_t * p_metadata);
10931112

10941113
/**
10951114
* @brief Sets the minimum value of the backoff exponent (BE) in the CSMA-CA algorithm.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* Copyright (c) 2025, Nordic Semiconductor ASA
3+
* All rights reserved.
4+
*
5+
* SPDX-License-Identifier: BSD-3-Clause
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice, this
11+
* list of conditions and the following disclaimer.
12+
*
13+
* 2. Redistributions in binary form must reproduce the above copyright
14+
* notice, this list of conditions and the following disclaimer in the
15+
* documentation and/or other materials provided with the distribution.
16+
*
17+
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
18+
* contributors may be used to endorse or promote products derived from this
19+
* software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
* POSSIBILITY OF SUCH DAMAGE.
32+
*
33+
*/
34+
35+
#ifndef NRF_802154_COMPILER_H__
36+
#define NRF_802154_COMPILER_H__
37+
38+
#ifdef __cplusplus
39+
extern "C" {
40+
#endif
41+
42+
/**
43+
* @defgroup nrf_802154_config_compiler Compiler compatibility macros
44+
* @{
45+
* @ingroup nrf_802154
46+
* @brief Compiler compatibility macros for the 802.15.4 radio driver.
47+
*/
48+
49+
/**
50+
* @def SWITCH_CASE_FALLTHROUGH
51+
*
52+
* Portable fallthrough annotation for switch case statements.
53+
*
54+
* This macro provides a portable way to annotate intentional fallthrough
55+
* between switch case labels across different C standards and compilers:
56+
* - C23: Uses [[fallthrough]] attribute
57+
* - GCC 7+/Clang: Uses __attribute__((fallthrough))
58+
* - Older compilers: Falls back to comment-based annotation
59+
*
60+
* Usage:
61+
* @code
62+
* switch (value) {
63+
* case 1:
64+
* do_something();
65+
* SWITCH_CASE_FALLTHROUGH;
66+
* case 2:
67+
* do_something_else();
68+
* break;
69+
* }
70+
* @endcode
71+
*/
72+
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
73+
/* C23 and later */
74+
#define SWITCH_CASE_FALLTHROUGH [[fallthrough]]
75+
#elif defined(__has_attribute)
76+
/* Clang and GCC with __has_attribute support */
77+
#if __has_attribute(fallthrough)
78+
#define SWITCH_CASE_FALLTHROUGH __attribute__((fallthrough))
79+
#else
80+
#define SWITCH_CASE_FALLTHROUGH /* fallthrough */
81+
#endif
82+
#elif defined(__GNUC__) && (__GNUC__ >= 7)
83+
/* GCC 7+ */
84+
#define SWITCH_CASE_FALLTHROUGH __attribute__((fallthrough))
85+
#elif defined(__clang__)
86+
/* Clang (older versions) */
87+
#if defined(__clang_major__) && (__clang_major__ >= 10)
88+
#define SWITCH_CASE_FALLTHROUGH __attribute__((fallthrough))
89+
#else
90+
#define SWITCH_CASE_FALLTHROUGH /* fallthrough */
91+
#endif
92+
#else
93+
/* Fallback for other compilers */
94+
#define SWITCH_CASE_FALLTHROUGH /* fallthrough */
95+
#endif
96+
97+
/** @} */
98+
99+
#ifdef __cplusplus
100+
}
101+
#endif
102+
103+
#endif // NRF_802154_COMPILER_H__

nrf_802154/common/include/nrf_802154_types.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ typedef uint8_t nrf_802154_tx_error_t;
9292
#define NRF_802154_TX_ERROR_KEY_ID_INVALID 0x08 // !< Transmission did not start due to invalid key ID in frame's security header.
9393
#define NRF_802154_TX_ERROR_FRAME_COUNTER_ERROR 0x09 // !< Transmission did not start due a frame counter error.
9494
#define NRF_802154_TX_ERROR_TIMESTAMP_ENCODING_ERROR 0x0A // !< Timestamp could not been encoded in the transmission process.
95+
#define NRF_802154_TX_ERROR_INVALID_REQUEST 0x0B // !< The frame or transmit metadata is invalid.
9596

9697
/**
9798
* @brief Possible errors during the frame reception.
@@ -493,13 +494,6 @@ typedef struct
493494
} data; // !< Result values that are valid only for successful operations.
494495
} nrf_802154_transmit_done_metadata_t;
495496

496-
/**
497-
* @brief Function pointer used for notifying about transmission failure.
498-
*/
499-
typedef void (* nrf_802154_transmit_failed_notification_t)(
500-
nrf_802154_tx_error_t error,
501-
const nrf_802154_transmit_done_metadata_t * p_meta);
502-
503497
/**
504498
* @brief Structure that holds results of energy detection procedure.
505499
*/

nrf_802154/doc/CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Notable changes
2222
This feature improves the reception performance of Enhanced ACK (EnhACK) frames, for which the PHR field value is not known in advance. (KRKNWK-19125)
2323
* When the proprietary SL library is used, the radio driver no longer requests the HFCLK directly through the :c:func:`nrf_802154_clock_hfclk_start` API.
2424
Clock requests are now handled internally through MPSL. (KRKNWK-20716)
25+
* The experimental IFS feature has been removed. (KRKNWK-20788)
26+
* The return value of :c:func:`nrf_802154_transmit_raw`, :c:func:`nrf_802154_transmit_csma_ca_raw`, and :c:func:`nrf_802154_transmit_raw_at` was updated.
27+
These API functions now return ``nrf_802154_tx_error_t`` instead of ``bool``. (KRKNWK-18536)
2528

2629
Added
2730
=====

nrf_802154/driver/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ target_sources(nrf-802154-driver
7474
src/mac_features/nrf_802154_filter.c
7575
src/mac_features/nrf_802154_frame_parser.c
7676
src/mac_features/nrf_802154_ie_writer.c
77-
src/mac_features/nrf_802154_ifs.c
7877
src/mac_features/nrf_802154_imm_tx.c
7978
src/mac_features/nrf_802154_security_pib_ram.c
8079
src/mac_features/nrf_802154_security_writer.c

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "nrf_802154_enh_ack_generator.h"
4242

4343
#include "nrf_802154_assert.h"
44+
#include "nrf_802154_compiler.h"
4445
#include <string.h>
4546

4647
#include "mac_features/nrf_802154_frame_parser.h"
@@ -624,7 +625,7 @@ uint8_t * nrf_802154_enh_ack_generator_create(
624625
#endif
625626

626627
ack_state_set(ACK_STATE_PROCESSING);
627-
// Fallthrough
628+
SWITCH_CASE_FALLTHROUGH;
628629

629630
case ACK_STATE_PROCESSING:
630631
{

nrf_802154/driver/src/mac_features/nrf_802154_csma_ca.c

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -350,43 +350,48 @@ static bool channel_busy(void)
350350
return result;
351351
}
352352

353-
bool nrf_802154_csma_ca_start(const nrf_802154_frame_t * p_frame,
354-
const nrf_802154_transmit_csma_ca_metadata_t * p_metadata)
353+
nrf_802154_tx_error_t nrf_802154_csma_ca_start(
354+
const nrf_802154_frame_t * p_frame,
355+
const nrf_802154_transmit_csma_ca_metadata_t * p_metadata)
355356
{
356357
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
357358

358359
#if (NRF_802154_FRAME_TIMESTAMP_ENABLED)
359360
uint64_t ts = nrf_802154_sl_timer_current_time_get();
360361

361-
nrf_802154_stat_timestamp_write(last_csmaca_start_timestamp, ts);
362+
nrf_802154_stat_timestamp_write_last_csmaca_start_timestamp(ts);
362363
#endif
363364

364-
bool result = csma_ca_state_set(CSMA_CA_STATE_IDLE, CSMA_CA_STATE_BACKOFF);
365-
366-
NRF_802154_ASSERT(result);
367-
(void)result;
365+
nrf_802154_tx_error_t error = NRF_802154_TX_ERROR_TIMESLOT_DENIED;
368366

369-
uint8_t channel =
370-
p_metadata->tx_channel.use_metadata_value ? p_metadata->tx_channel.channel :
371-
nrf_802154_pib_channel_get();
372-
373-
m_frame = *p_frame;
374-
m_data_props = p_metadata->frame_props;
375-
m_nb = 0;
376-
m_be = nrf_802154_pib_csmaca_min_be_get();
377-
m_tx_channel = channel;
378-
#if NRF_802154_TX_TIMESTAMP_PROVIDER_ENABLED
379-
m_tx_timestamp_encode = p_metadata->tx_timestamp_encode;
380-
#endif
381-
(void)nrf_802154_tx_power_convert_metadata_to_tx_power_split(channel,
382-
p_metadata->tx_power,
383-
&m_tx_power);
367+
bool result = csma_ca_state_set(CSMA_CA_STATE_IDLE, CSMA_CA_STATE_BACKOFF);
384368

385-
random_backoff_start();
369+
if (result)
370+
{
371+
uint8_t channel =
372+
p_metadata->tx_channel.use_metadata_value ? p_metadata->tx_channel.channel :
373+
nrf_802154_pib_channel_get();
374+
375+
m_frame = *p_frame;
376+
m_data_props = p_metadata->frame_props;
377+
m_nb = 0;
378+
m_be = nrf_802154_pib_csmaca_min_be_get();
379+
m_tx_channel = channel;
380+
#if NRF_802154_TX_TIMESTAMP_PROVIDER_ENABLED
381+
m_tx_timestamp_encode = p_metadata->tx_timestamp_encode;
382+
#endif
383+
(void)nrf_802154_tx_power_convert_metadata_to_tx_power_split(channel,
384+
p_metadata->tx_power,
385+
&m_tx_power);
386+
387+
random_backoff_start();
388+
389+
error = NRF_802154_TX_ERROR_NONE;
390+
}
386391

387392
nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
388393

389-
return true;
394+
return error;
390395
}
391396

392397
static bool csma_ca_can_abort(nrf_802154_term_t term_lvl,

nrf_802154/driver/src/mac_features/nrf_802154_csma_ca.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@
6363
*
6464
* @retval true The function always returns true for compatibility reasons
6565
*/
66-
bool nrf_802154_csma_ca_start(const nrf_802154_frame_t * p_frame,
67-
const nrf_802154_transmit_csma_ca_metadata_t * p_metadata);
66+
nrf_802154_tx_error_t nrf_802154_csma_ca_start(
67+
const nrf_802154_frame_t * p_frame,
68+
const nrf_802154_transmit_csma_ca_metadata_t * p_metadata);
6869

6970
/**
7071
*@}

nrf_802154/driver/src/mac_features/nrf_802154_delayed_trx.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -845,12 +845,14 @@ void nrf_802154_delayed_trx_deinit(void)
845845
}
846846
}
847847

848-
bool nrf_802154_delayed_trx_transmit(const nrf_802154_frame_t * p_frame,
849-
uint64_t tx_time,
850-
const nrf_802154_transmit_at_metadata_t * p_metadata)
848+
nrf_802154_tx_error_t nrf_802154_delayed_trx_transmit(
849+
const nrf_802154_frame_t * p_frame,
850+
uint64_t tx_time,
851+
const nrf_802154_transmit_at_metadata_t * p_metadata)
851852
{
852-
dly_op_data_t * p_dly_tx_data = available_dly_tx_slot_get();
853-
bool result = false;
853+
dly_op_data_t * p_dly_tx_data = available_dly_tx_slot_get();
854+
nrf_802154_tx_error_t error = NRF_802154_TX_ERROR_TIMESLOT_DENIED;
855+
bool result = false;
854856

855857
if (p_dly_tx_data != NULL)
856858
{
@@ -894,7 +896,12 @@ bool nrf_802154_delayed_trx_transmit(const nrf_802154_frame_t * p
894896
result = dly_op_request(&dly_ts_param, p_dly_tx_data);
895897
}
896898

897-
return result;
899+
if (result)
900+
{
901+
error = NRF_802154_TX_ERROR_NONE;
902+
}
903+
904+
return error;
898905
}
899906

900907
bool nrf_802154_delayed_trx_receive(uint64_t rx_time,

nrf_802154/driver/src/mac_features/nrf_802154_delayed_trx.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ void nrf_802154_delayed_trx_deinit(void);
7878
* @param[in] p_metadata Pointer to metadata structure. Contains detailed properties of data
7979
* to transmit and additional parameters for the procedure.
8080
*/
81-
bool nrf_802154_delayed_trx_transmit(const nrf_802154_frame_t * p_frame,
82-
uint64_t tx_time,
83-
const nrf_802154_transmit_at_metadata_t * p_metadata);
81+
nrf_802154_tx_error_t nrf_802154_delayed_trx_transmit(
82+
const nrf_802154_frame_t * p_frame,
83+
uint64_t tx_time,
84+
const nrf_802154_transmit_at_metadata_t * p_metadata);
8485

8586
/**
8687
* @brief Cancels a transmission scheduled by a call to @ref nrf_802154_delayed_trx_transmit.

0 commit comments

Comments
 (0)