Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions nrf_802154/common/include/nrf_802154_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@
#ifndef NRF_802154_CONFIG_H__
#define NRF_802154_CONFIG_H__

/* This file must not include nrf.h or nrfx.h directly or indirectly,
* to avoid circular dependencies.
*/

#ifdef NRF_802154_PROJECT_CONFIG
#include NRF_802154_PROJECT_CONFIG
#endif

#include <nrfx.h>
#include "nrf_802154_nrfx_addons.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -499,19 +500,6 @@ extern "C" {
#define NRF_802154_ENCRYPTION_ENABLED 1
#endif

/**
* @def NRF_802154_ENCRYPTION_ACCELERATOR_ECB
*
* Enables ECB peripheral to be used as hardware accelerator for on-the-fly AES-CCM* encryption.
*/
#if !defined(NRF_802154_ENCRYPTION_ACCELERATOR_ECB) || defined(__DOXYGEN__)
#if defined(NRF52_SERIES) || defined(NRF5340_XXAA) || defined(__DOXYGEN__)
#define NRF_802154_ENCRYPTION_ACCELERATOR_ECB 1
#elif defined(NRF54H_SERIES) || defined(NRF54L_SERIES)
#define NRF_802154_ENCRYPTION_ACCELERATOR_ECB 0
#endif
#endif

/**
* @}
* @defgroup nrf_802154_ie Information Elements configuration
Expand Down
119 changes: 119 additions & 0 deletions nrf_802154/common/include/nrf_802154_config_soc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* Copyright (c) 2025, 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.
*
*/

#ifndef NRF_802154_CONFIG_SOC_H_
#define NRF_802154_CONFIG_SOC_H_

/* This file provides information about the SoC to the nRF 802.15.4 driver.
* It defines nrf 802.15.4 driver's internal macros to denote SoC series and
* SoC features based on macros provided by the build system.
*
* This file intentionally does not include nrf.h or nrfx.h to avoid
* circular include dependencies.
*/

#ifdef NRF_802154_SOC_SUPPORTED
#error "Do not define NRF_802154_SOC_SUPPORTED externally"
#endif

#ifdef NRF_802154_SOC_NRF52_SERIES
#error "Do not define NRF_802154_SOC_NRF52_SERIES externally"
#endif

#if defined (NRF52833_XXAA) || defined (NRF52840_XXAA)
#define NRF_802154_SOC_NRF52_SERIES
#define NRF_802154_SOC_SUPPORTED
#endif

#ifdef NRF_802154_SOC_NRF53_SERIES
#error "Do not define NRF_802154_SOC_NRF53_SERIES externally"
#endif

#if defined (NRF5340_XXAA) || defined(NRF5340_XXAA_APPLICATION) || defined(NRF5340_XXAA_NETWORK)
#define NRF_802154_SOC_NRF53_SERIES
#define NRF_802154_SOC_SUPPORTED
#endif

#ifdef NRF_802154_SOC_NRF54H_SERIES
#error "Do not define NRF_802154_SOC_NRF54H_SERIES externally"
#endif

#if defined (NRF54H20_XXAA)
#define NRF_802154_SOC_NRF54H_SERIES
#define NRF_802154_SOC_SUPPORTED
#endif

#ifdef NRF_802154_SOC_NRF54L_SERIES
#error "Do not define NRF_802154_SOC_NRF54L_SERIES externally"
#endif

#if defined (NRF54L05_XXAA) || defined (NRF54LV10A_ENGA_XXAA) || defined (NRF54L10_XXAA) \
|| defined (NRF54L15_XXAA) || defined (NRF54LM20A_ENGA_XXAA)
#define NRF_802154_SOC_NRF54L_SERIES
#define NRF_802154_SOC_SUPPORTED
#endif

#ifdef NRF_802154_SOC_PPI_PRESENT
#error "Do not define NRF_802154_SOC_PPI_PRESENT externally"
#endif

#ifdef NRF_802154_SOC_DPPI_PRESENT
#error "Do not define NRF_802154_SOC_DPPI_PRESENT externally"
#endif

#if defined(NRF_802154_SOC_NRF52_SERIES)
#define NRF_802154_SOC_PPI_PRESENT
#endif

#if defined(NRF_802154_SOC_NRF53_SERIES)
#define NRF_802154_SOC_DPPI_PRESENT
#endif

#if defined(NRF_802154_SOC_NRF54H_SERIES)
#define NRF_802154_SOC_DPPI_PRESENT
#endif

#if defined(NRF_802154_SOC_NRF54L_SERIES)
#define NRF_802154_SOC_DPPI_PRESENT
#endif

#ifdef NRF_802154_USE_INTERNAL_INCLUDES
#include "nrf_802154_soc_config_internal.h"
#endif

#ifndef NRF_802154_SOC_SUPPORTED
#error "nRF 802.15.4 driver is not supported on the selected SoC."
#endif

#endif /* NRF_802154_CONFIG_SOC_H_ */
6 changes: 6 additions & 0 deletions nrf_802154/doc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Notable changes
* The experimental IFS feature has been removed. (KRKNWK-20788)
* 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.
These API functions now return ``nrf_802154_tx_error_t`` instead of ``bool``. (KRKNWK-18536)
* The following header files no longer include ``nrf.h`` or ``nrfx.h`` to avoid circular dependencies (KRKNWK-20956):

* ``nrf_802154_peripherals_nrf52.h``
* ``nrf_802154_peripherals_nrf53.h``
* ``nrf_802154_peripherals_nrf54h.h``
* ``nrf_802154_peripherals_nrf54l.h``

Added
=====
Expand Down
2 changes: 0 additions & 2 deletions nrf_802154/doc/rd_including.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Using CMake

The nRF 802.15.4 Radio Driver supports the CMake build system and can be directly included in a project using the CMake build system with the ``add_subdirectory(nrfxlib/nrf_802154)`` CMake command.

To do so, you must first set the ``NRF52_SERIES`` or ``NRF53_SERIES`` CMake variable to ``1``, depending on the used SoC family.

If building on a single core SoC, you should then do the following:

1. Link the following libraries (CMake targets) to the application library:
Expand Down
1 change: 1 addition & 0 deletions nrf_802154/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ target_sources(nrf-802154-driver
src/nrf_802154_core_hooks.c
src/nrf_802154_critical_section.c
src/nrf_802154_debug.c
src/nrf_802154_debug_gpio.c
src/nrf_802154_encrypt.c
src/nrf_802154_notification_direct.c
src/nrf_802154_notification_swi.c
Expand Down
64 changes: 9 additions & 55 deletions nrf_802154/driver/src/nrf_802154.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <string.h>

#include "nrf_802154_config.h"
#include "nrf_802154_facade_helpers.h"
#include "nrf_802154_utils.h"
#include "nrf_802154_const.h"
#include "nrf_802154_core.h"
Expand Down Expand Up @@ -92,25 +93,6 @@ static uint8_t m_tx_buffer[RAW_PAYLOAD_OFFSET + MAX_PACKET_SIZE];

#endif // NRF_802154_CARRIER_FUNCTIONS_ENABLED

static inline bool are_frame_properties_valid(const nrf_802154_transmitted_frame_props_t * p_props)
{
return p_props->dynamic_data_is_set || !(p_props->is_secured);
}

static inline bool are_extra_cca_attempts_valid(const nrf_802154_transmit_at_metadata_t * p_data)
{
return !p_data->cca || (p_data->extra_cca_attempts < UINT8_MAX);
}

static inline bool is_tx_timestamp_request_valid(const bool tx_timestamp_encode)
{
#if NRF_802154_TX_TIMESTAMP_PROVIDER_ENABLED
return true;
#else
return !tx_timestamp_encode;
#endif
}

void nrf_802154_channel_set(uint8_t channel)
{
bool changed = nrf_802154_pib_channel_get() != channel;
Expand Down Expand Up @@ -403,16 +385,7 @@ nrf_802154_tx_error_t nrf_802154_transmit_raw(uint8_t

if (p_metadata == NULL)
{
static const nrf_802154_transmit_metadata_t metadata_default =
{
.frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
.cca = true,
.tx_power = {.use_metadata_value = false},
.tx_channel = {.use_metadata_value = false},
.tx_timestamp_encode = false
};

p_metadata = &metadata_default;
p_metadata = nrf_802154_transmit_metadata_default_ptr_get();
}

result = nrf_802154_frame_parser_data_init(p_data,
Expand All @@ -432,8 +405,7 @@ nrf_802154_tx_error_t nrf_802154_transmit_raw(uint8_t

if (result)
{
result = are_frame_properties_valid(&p_metadata->frame_props) &&
is_tx_timestamp_request_valid(p_metadata->tx_timestamp_encode);
result = nrf_802154_transmit_metadata_is_valid(p_metadata);
}

if (result)
Expand All @@ -459,21 +431,14 @@ nrf_802154_tx_error_t nrf_802154_transmit_raw_at(
bool result;
nrf_802154_frame_t frame;
nrf_802154_tx_error_t error;
nrf_802154_transmit_at_metadata_t metadata_default =
{
.frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
.cca = true,
.tx_power = {.use_metadata_value = false},
.extra_cca_attempts = 0,
.tx_timestamp_encode = false,
};
nrf_802154_transmit_at_metadata_t metadata_default;

nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);

if (p_metadata == NULL)
{
metadata_default.channel = nrf_802154_channel_get();
p_metadata = &metadata_default;
nrf_802154_transmit_at_metadata_default_prepare(&metadata_default);
p_metadata = &metadata_default;
}

result = nrf_802154_frame_parser_data_init(p_data,
Expand All @@ -493,9 +458,7 @@ nrf_802154_tx_error_t nrf_802154_transmit_raw_at(

if (result)
{
result = are_frame_properties_valid(&p_metadata->frame_props) &&
are_extra_cca_attempts_valid(p_metadata) &&
is_tx_timestamp_request_valid(p_metadata->tx_timestamp_encode);
result = nrf_802154_transmit_at_metadata_is_valid(p_metadata);
}

if (result)
Expand Down Expand Up @@ -766,15 +729,7 @@ nrf_802154_tx_error_t nrf_802154_transmit_csma_ca_raw(

if (p_metadata == NULL)
{
static const nrf_802154_transmit_csma_ca_metadata_t metadata_default =
{
.frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
.tx_power = {.use_metadata_value = false},
.tx_channel = {.use_metadata_value = false},
.tx_timestamp_encode = false
};

p_metadata = &metadata_default;
p_metadata = nrf_802154_transmit_csma_ca_metadata_default_ptr_get();
}

result = nrf_802154_frame_parser_data_init(p_data,
Expand All @@ -794,8 +749,7 @@ nrf_802154_tx_error_t nrf_802154_transmit_csma_ca_raw(

if (result)
{
result = are_frame_properties_valid(&p_metadata->frame_props) &&
is_tx_timestamp_request_valid(p_metadata->tx_timestamp_encode);
result = nrf_802154_transmit_csma_ca_metadata_is_valid(p_metadata);
}

if (result)
Expand Down
6 changes: 4 additions & 2 deletions nrf_802154/driver/src/nrf_802154_aes_ccm_acc_ccm.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
*/

#include "nrf_802154_config.h"
#include "nrf_802154_peripherals.h"

#if NRF_802154_ENCRYPTION_ENABLED && !NRF_802154_ENCRYPTION_ACCELERATOR_ECB
#if NRF_802154_ENCRYPTION_ENABLED && defined(NRF_802154_ENCRYPTION_ACCELERATOR_CCM)

/** Configures if the CCM's OUT.PTR pointer points to the same memory location as PACKETPTR register
* of the RADIO.
Expand All @@ -48,6 +49,7 @@
#define CCM_ADATA_ATTR_ID 13 ///< Attribute field that identifies the adata CCM job
#define CCM_MDATA_ATTR_ID 14 ///< Attribute field that identifies the mdata CCM job

#include <nrfx.h>
#include "nrf_802154_aes_ccm.h"

#include <string.h>
Expand Down Expand Up @@ -383,4 +385,4 @@ void nrf_802154_aes_ccm_transform_reset(void)
memset(m_nonce, 0, sizeof(m_nonce));
}

#endif // NRF_802154_ENCRYPTION_ENABLED && !NRF_802154_ENCRYPTION_ACCELERATOR_ECB
#endif // NRF_802154_ENCRYPTION_ENABLED && defined(NRF_802154_ENCRYPTION_ACCELERATOR_CCM)
7 changes: 4 additions & 3 deletions nrf_802154/driver/src/nrf_802154_aes_ccm_acc_ecb.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@
*/

#include "nrf_802154_config.h"
#include "nrf_802154_peripherals.h"

#if NRF_802154_ENCRYPTION_ACCELERATOR_ECB
#if NRF_802154_ENCRYPTION_ENABLED && defined(NRF_802154_ENCRYPTION_ACCELERATOR_ECB)

#include <nrfx.h>
#include "nrf_802154_aes_ccm.h"

#include "nrf_802154_assert.h"
#include <string.h>

#include "nrf_802154_const.h"
#include "nrf_802154_config.h"
#include "nrf_802154_tx_work_buffer.h"
#if defined(CONFIG_MPSL)
#include "mpsl_ecb.h"
Expand Down Expand Up @@ -614,4 +615,4 @@ void nrf_802154_aes_ccm_transform_abort(uint8_t * p_frame)
m_aes_ccm_data.raw_frame = NULL;
}

#endif /* NRF_802154_ENCRYPTION_ACCELERATOR_ECB */
#endif /* NRF_802154_ENCRYPTION_ENABLED && defined(NRF_802154_ENCRYPTION_ACCELERATOR_ECB) */
Loading