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
1 change: 1 addition & 0 deletions nrf_802154/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ target_sources(nrf-802154-driver
src/nrf_802154_rx_buffer.c
src/nrf_802154_stats.c
src/nrf_802154_swi.c
src/nrf_802154_swi_callouts_weak.c
src/nrf_802154_trx.c
src/nrf_802154_trx_dppi.c
src/nrf_802154_trx_ppi.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#if NRF_802154_TX_TIMESTAMP_PROVIDER_ENABLED

static uint64_t m_tx_timestamp_us; ///< Cached transmit timestamp.
static uint32_t m_tx_timestamp_us; ///< Cached transmit timestamp.
static uint8_t * mp_tx_timestamp_addr; ///< Cached tx timestamp placeholder address.

nrf_802154_tx_error_t nrf_802154_tx_timestamp_provider_tx_setup(
Expand Down Expand Up @@ -127,8 +127,14 @@ void nrf_802154_tx_timestamp_provider_tx_started_hook(uint8_t * p_frame)
* This function executes approximately 32us before the first bit of PHR.
* The calculation takes it into account by adding 32us to the current time.
*/
m_tx_timestamp_us = nrf_802154_sl_timer_current_time_get() + 32;
host_64_to_big(m_tx_timestamp_us, mp_tx_timestamp_addr);
NRF_STATIC_ASSERT(NRF_802154_TX_TIMESTAMP_PROVIDER_TIMESTAMP_SIZE == 4,
"Currently, only TX timestamp size 4 can be handled.");
/* The current time value is 64 bits (8 bytes).
* Since the timestamp size is 32 bits (4 bytes),
* only the least significant 32 bits are used.
*/
m_tx_timestamp_us = (uint32_t)(nrf_802154_sl_timer_current_time_get()) + 32U;
host_32_to_little(m_tx_timestamp_us, mp_tx_timestamp_addr);

mp_tx_timestamp_addr = NULL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

#include "nrf_802154_types_internal.h"

#define NRF_802154_TX_TIMESTAMP_PROVIDER_TIMESTAMP_SIZE (sizeof(uint64_t))
#define NRF_802154_TX_TIMESTAMP_PROVIDER_TIMESTAMP_SIZE (sizeof(uint32_t))

/**
* @brief TX setup hook for the tx timestamp provider module.
Expand Down
38 changes: 31 additions & 7 deletions nrf_802154/driver/src/nrf_802154_peripherals.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,34 @@ extern "C" {
#define NRF_802154_EGU_SYNC_USED_CHANNELS_MASK (1U << NRF_802154_EGU_SYNC_CHANNEL_NO)

/**
* @def NRF_802154_EGU_RAMP_UP_CHANNEL_NO
* @def NRF_802154_EGU_TRIGGER_CHANNEL_NO
*
* The channel number of the @ref NRF_802154_EGU_INSTANCE used for triggering the ramp-up of the RADIO.
* The channel number of the @ref NRF_802154_EGU_INSTANCE used for triggering the radio hardware.
*/
#define NRF_802154_EGU_RAMP_UP_CHANNEL_NO 15
#define NRF_802154_EGU_TRIGGER_CHANNEL_NO 14

/**
* @def NRF_802154_EGU_RAMP_UP_USED_CHANNELS_MASK
* @def NRF_802154_EGU_TRIGGER_EVENT
*
* Mask of EGU channels used for triggering the ramp-up of the RADIO.
* See @ref NRF_802154_EGU_USED_CHANNELS_MASK.
* The EGU event used by the driver to trigger the radio hardware.
*/
#define NRF_802154_EGU_TRIGGER_EVENT NRFX_CONCAT_2(NRF_EGU_EVENT_TRIGGERED, \
NRF_802154_EGU_TRIGGER_CHANNEL_NO)

/**
* @def NRF_802154_EGU_TRIGGER_TASK
*
* The EGU task used by the driver to trigger the radio hardware.
*/
#define NRF_802154_EGU_TRIGGER_TASK NRFX_CONCAT_2(NRF_EGU_TASK_TRIGGER, \
NRF_802154_EGU_TRIGGER_CHANNEL_NO)

/**
* @def NRF_802154_EGU_RAMP_UP_CHANNEL_NO
*
* The channel number of the @ref NRF_802154_EGU_INSTANCE used for triggering the ramp-up of the RADIO.
*/
#define NRF_802154_EGU_RAMP_UP_USED_CHANNELS_MASK (1U << NRF_802154_EGU_RAMP_UP_CHANNEL_NO)
#define NRF_802154_EGU_RAMP_UP_CHANNEL_NO 15

/**
* @def NRF_802154_EGU_RAMP_UP_EVENT
Expand All @@ -265,6 +280,15 @@ extern "C" {
#define NRF_802154_EGU_RAMP_UP_TASK NRFX_CONCAT_2(NRF_EGU_TASK_TRIGGER, \
NRF_802154_EGU_RAMP_UP_CHANNEL_NO)

/**
* @def NRF_802154_EGU_RAMP_UP_USED_CHANNELS_MASK
*
* Mask of EGU channels used for triggering the ramp-up of the RADIO.
* See @ref NRF_802154_EGU_USED_CHANNELS_MASK.
*/
#define NRF_802154_EGU_RAMP_UP_USED_CHANNELS_MASK (1U << NRF_802154_EGU_RAMP_UP_CHANNEL_NO) | \
(1U << NRF_802154_EGU_TRIGGER_CHANNEL_NO)

#ifndef NRF_802154_EGU_TIMER_START_USED_CHANNELS_MASK
#define NRF_802154_EGU_TIMER_START_USED_CHANNELS_MASK 0U
#endif
Expand Down
4 changes: 2 additions & 2 deletions nrf_802154/driver/src/nrf_802154_peripherals_nrf53.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ extern "C" {
* The channel number of the @ref NRF_802154_EGU_INSTANCE used for starting the TIMER.
* Used only when @ref NRF_802154_CCAIDLE_TO_TXEN_EXTRA_TIME_US is non-zero.
*/
#define NRF_802154_EGU_TIMER_START_CHANNEL_NO 14
#define NRF_802154_EGU_TIMER_START_CHANNEL_NO 13

#define NRF_802154_EGU_TIMER_START_USED_CHANNELS_MASK \
(1U << NRF_802154_EGU_TIMER_START_CHANNEL_NO)
Expand All @@ -110,7 +110,7 @@ extern "C" {
* The channel number of the @ref NRF_802154_EGU_INSTANCE used for starting the TIMER (second source).
* Used only when @ref NRF_802154_CCAIDLE_TO_TXEN_EXTRA_TIME_US is non-zero.
*/
#define NRF_802154_EGU_TIMER_START2_CHANNEL_NO 13
#define NRF_802154_EGU_TIMER_START2_CHANNEL_NO 12

#define NRF_802154_EGU_TIMER_START2_USED_CHANNELS_MASK \
(1U << NRF_802154_EGU_TIMER_START2_CHANNEL_NO)
Expand Down
4 changes: 2 additions & 2 deletions nrf_802154/driver/src/nrf_802154_peripherals_nrf54l.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ extern "C" {
* The channel number of the @ref NRF_802154_EGU_INSTANCE used for starting the TIMER.
* Used only when @ref NRF_802154_CCAIDLE_TO_TXEN_EXTRA_TIME_US is non-zero.
*/
#define NRF_802154_EGU_TIMER_START_CHANNEL_NO 14
#define NRF_802154_EGU_TIMER_START_CHANNEL_NO 13

#define NRF_802154_EGU_TIMER_START_USED_CHANNELS_MASK \
(1U << NRF_802154_EGU_TIMER_START_CHANNEL_NO)
Expand All @@ -109,7 +109,7 @@ extern "C" {
* The channel number of the @ref NRF_802154_EGU_INSTANCE used for starting the TIMER (second source).
* Used only when @ref NRF_802154_CCAIDLE_TO_TXEN_EXTRA_TIME_US is non-zero.
*/
#define NRF_802154_EGU_TIMER_START2_CHANNEL_NO 13
#define NRF_802154_EGU_TIMER_START2_CHANNEL_NO 12

#define NRF_802154_EGU_TIMER_START2_USED_CHANNELS_MASK \
(1U << NRF_802154_EGU_TIMER_START2_CHANNEL_NO)
Expand Down
41 changes: 18 additions & 23 deletions nrf_802154/driver/src/nrf_802154_swi.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@
*/

#include "nrf_802154_swi.h"
#include "nrf_802154_swi_callouts.h"

#include <stdbool.h>
#include <stdint.h>

#include "compiler_abstraction.h"
#include "nrf_802154.h"
#include "nrf_802154_config.h"
#if !NRF_802154_INTERNAL_SWI_IRQ_HANDLING
#include "nrf_802154_irq_handlers.h"
#endif
#include "nrf_802154_peripherals.h"
#include "platform/nrf_802154_irq.h"

#if NRF_802154_INTERNAL_SWI_IRQ_HANDLING
Expand All @@ -55,20 +57,7 @@
#define SWI_IRQHandler nrf_802154_swi_irq_handler ///< Symbol of SWI IRQ handler.
#endif

__WEAK void nrf_802154_trx_swi_irq_handler(void)
{
/* Implementation provided by other module if necessary */
}

__WEAK void nrf_802154_notification_swi_irq_handler(void)
{
/* Implementation provided by other module if necessary */
}

__WEAK void nrf_802154_request_swi_irq_handler(void)
{
/* Implementation provided by other module if necessary */
}
static bool initialized = false;

static void swi_irq_handler(void)
{
Expand All @@ -79,14 +68,12 @@ static void swi_irq_handler(void)

void nrf_802154_swi_init(void)
{
static bool initialized = false;

if (!initialized)
{
nrf_802154_irq_init(nrfx_get_irq_number(NRF_802154_EGU_INSTANCE),
NRF_802154_SWI_PRIORITY,
swi_irq_handler);
nrf_802154_irq_enable(nrfx_get_irq_number(NRF_802154_EGU_INSTANCE));
IRQn_Type irq_number = nrfx_get_irq_number(NRF_802154_EGU_INSTANCE);

nrf_802154_irq_init(irq_number, NRF_802154_SWI_PRIORITY, &swi_irq_handler);
nrf_802154_irq_enable(irq_number);
initialized = true;
}
}
Expand All @@ -95,3 +82,11 @@ void SWI_IRQHandler(void)
{
swi_irq_handler();
}

#ifdef TEST
void nrf_802154_swi_module_reset(void)
{
initialized = false;
}

#endif // TEST
3 changes: 0 additions & 3 deletions nrf_802154/driver/src/nrf_802154_swi.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
#ifndef NRF_802154_SWI_H__
#define NRF_802154_SWI_H__

#include <stdbool.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
55 changes: 55 additions & 0 deletions nrf_802154/driver/src/nrf_802154_swi_callouts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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_SWI_CALLOUTS_H__
#define NRF_802154_SWI_CALLOUTS_H__

#ifdef __cplusplus
extern "C" {
#endif

/** @brief Callout from SWI for nrf_802154_trx module. */
void nrf_802154_trx_swi_irq_handler(void);

/** @brief Callout from SWI for nrf_802154_notification_swi module. */
void nrf_802154_notification_swi_irq_handler(void);

/** @brief Callout from SWI for nrf_802154_request_swi module. */
void nrf_802154_request_swi_irq_handler(void);

#ifdef __cplusplus
}
#endif

#endif /* NRF_802154_SWI_CALLOUTS_H__ */
51 changes: 51 additions & 0 deletions nrf_802154/driver/src/nrf_802154_swi_callouts_weak.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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.
*
*/

#include "nrf_802154_swi_callouts.h"
#include "compiler_abstraction.h"

__WEAK void nrf_802154_trx_swi_irq_handler(void)
{
/* Implementation provided by other module if necessary */
}

__WEAK void nrf_802154_notification_swi_irq_handler(void)
{
/* Implementation provided by other module if necessary */
}

__WEAK void nrf_802154_request_swi_irq_handler(void)
{
/* Implementation provided by other module if necessary */
}
5 changes: 4 additions & 1 deletion nrf_802154/driver/src/nrf_802154_trx.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,11 @@ static void trigger_disable_to_start_rampup(void)
{
if (!nrf_802154_trx_ppi_for_ramp_up_was_triggered())
{
#if defined(DPPI_PRESENT)
nrf_egu_task_trigger(NRF_802154_EGU_INSTANCE, NRF_802154_EGU_TRIGGER_TASK);
#else
nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_DISABLE);
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
#endif
}
}

Expand Down
12 changes: 9 additions & 3 deletions nrf_802154/driver/src/nrf_802154_trx_dppi.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ void nrf_802154_trx_ppi_for_ramp_up_set(nrf_radio_task_t ra
}

nrf_egu_publish_set(NRF_802154_EGU_INSTANCE, EGU_EVENT, PPI_EGU_RAMP_UP);
nrf_egu_publish_set(NRF_802154_EGU_INSTANCE, NRF_802154_EGU_TRIGGER_EVENT, PPI_DISABLED_EGU);

nrf_egu_subscribe_set(NRF_802154_EGU_INSTANCE, EGU_TASK, PPI_DISABLED_EGU);

Expand All @@ -176,9 +177,9 @@ void nrf_802154_trx_ppi_for_ramp_up_set(nrf_radio_task_t ra

if (trigg_mode == TRX_RAMP_UP_HW_TRIGGER)
{
nrf_radio_subscribe_set(NRF_RADIO,
NRF_RADIO_TASK_DISABLE,
NRF_802154_DPPI_RADIO_HW_TRIGGER);
nrf_egu_subscribe_set(NRF_802154_EGU_INSTANCE,
NRF_802154_EGU_TRIGGER_TASK,
NRF_802154_DPPI_RADIO_HW_TRIGGER);
}

nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_HIGH);
Expand Down Expand Up @@ -271,6 +272,11 @@ void nrf_802154_trx_ppi_for_ramp_up_clear(nrf_radio_task_t ramp_up_task, bool st
(1UL << PPI_EGU_RAMP_UP));

nrf_egu_publish_clear(NRF_802154_EGU_INSTANCE, EGU_EVENT);
nrf_egu_publish_clear(NRF_802154_EGU_INSTANCE, NRF_802154_EGU_TRIGGER_EVENT);

nrf_egu_subscribe_clear(NRF_802154_EGU_INSTANCE, EGU_TASK);
nrf_egu_subscribe_clear(NRF_802154_EGU_INSTANCE, NRF_802154_EGU_TRIGGER_TASK);

nrf_radio_subscribe_clear(NRF_RADIO, ramp_up_task);
nrf_radio_subscribe_clear(NRF_RADIO, NRF_RADIO_TASK_DISABLE);

Expand Down
Loading