Skip to content

Commit 57d9fc5

Browse files
e-rkcarlescufi
authored andcommitted
drivers: nrf_802154: Update the IEEE 802.15.4 component
This commit updates the nRF 802.15.4 radio driver to feature the latest changes. sdk-nrf-802154 commit: 8fa87173f1a314ce4de0a307999de3fb32979c7a Signed-off-by: Rafał Kuźnia <[email protected]>
1 parent d0cef23 commit 57d9fc5

File tree

66 files changed

+3830
-3151
lines changed

Some content is hidden

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

66 files changed

+3830
-3151
lines changed

drivers/nrf_802154/common/include/nrf_802154.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,10 @@ bool nrf_802154_receive_at_scheduled_cancel(uint32_t id);
514514
* @note This function is implemented in zero-copy fashion. It passes the given buffer pointer to
515515
* the RADIO peripheral.
516516
*
517+
* @note Setting @p tx_timestamp_encode to true is only allowed if
518+
* @ref NRF_802154_TX_TIMESTAMP_PROVIDER_ENABLED is enabled.
519+
* If this condition is not met, any attempt to transmit a frame will fail unconditionally.
520+
*
517521
* In the transmit state, the radio transmits a given frame. If requested, it waits for
518522
* an ACK frame. Depending on @ref NRF_802154_ACK_TIMEOUT_ENABLED, the radio driver automatically
519523
* stops waiting for an ACK frame or waits indefinitely for an ACK frame. If it is configured to
@@ -542,6 +546,7 @@ bool nrf_802154_receive_at_scheduled_cancel(uint32_t id);
542546
* ----------------|-----------------------------------------------------
543547
* @c frame_props | @ref NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT
544548
* @c cca | @c true
549+
* @c tx_timestamp_encode | @c false
545550
*
546551
* @retval true The transmission procedure was scheduled.
547552
* @retval false The driver could not schedule the transmission procedure.
@@ -602,6 +607,10 @@ bool nrf_802154_transmit_raw(uint8_t * p_data,
602607
* A successfully scheduled transmission can be cancelled by a call
603608
* to @ref nrf_802154_transmit_at_cancel.
604609
*
610+
 * @note Setting @p tx_timestamp_encode to true is only allowed if
611+
* @ref NRF_802154_TX_TIMESTAMP_PROVIDER_ENABLED is enabled.
612+
* If this condition is not met, any attempt to transmit a frame will fail unconditionally.
613+
*
605614
* @param[in] p_data Pointer to the array with data to transmit. The first byte must contain
606615
* the frame length (including FCS). The following bytes contain data.
607616
* The CRC is computed automatically by the radio hardware. Therefore,
@@ -616,6 +625,7 @@ bool nrf_802154_transmit_raw(uint8_t * p_data,
616625
* @c channel | As returned by @ref nrf_802154_channel_get
617626
* @c tx_power | As set with @ref nrf_802154_tx_power_set
618627
* @c extra_cca_attempts | @c 0
628+
* @c tx_timestamp_encode | @c 0
619629
*
620630
* @retval true The transmission procedure was scheduled.
621631
* @retval false The driver could not schedule the transmission procedure.
@@ -1063,13 +1073,17 @@ void nrf_802154_cca_cfg_get(nrf_802154_cca_cfg_t * p_cca_cfg);
10631073
* the CSMA-CA procedure does not time out waiting for an ACK frame if a frame
10641074
* with the ACK request bit set was transmitted.
10651075
* @note This function is available if @ref NRF_802154_CSMA_CA_ENABLED is enabled.
1076+
* @note Setting @p tx_timestamp_encode to true is only allowed if
1077+
* @ref NRF_802154_TX_TIMESTAMP_PROVIDER_ENABLED is enabled.
1078+
* If this condition is not met, any attempt to transmit a frame will fail unconditionally.
10661079
*
10671080
* @param[in] p_data Pointer to the frame to transmit. See also @ref nrf_802154_transmit_raw.
10681081
* @param[in] p_metadata Pointer to metadata structure. Contains detailed properties of data
10691082
* to transmit. If @c NULL following metadata are used:
10701083
* Field | Value
10711084
* ----------------|-----------------------------------------------------
10721085
* @c frame_props | @ref NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT
1086+
* @c tx_timestamp_encode | false
10731087
*
10741088
* @retval true The chain of CSMA-CA and transmission procedure was scheduled.
10751089
* @retval false The driver could not schedule the procedure chain.

drivers/nrf_802154/common/include/nrf_802154_config.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,54 @@ extern "C" {
595595
#define NRF_802154_REQUEST_IMPL NRF_802154_REQUEST_IMPL_SWI
596596
#endif
597597

598+
/**
599+
* @}
600+
* @defgroup nrf_802154_tx_timestamp_provider Transmit Timestamp configuration
601+
* @{
602+
*/
603+
604+
/**
605+
* @def NRF_802154_TX_TIMESTAMP_PROVIDER_ENABLED
606+
*
607+
* Enables the Transmit Timestamp Provider module. The module encodes the transmission
608+
* start timestamp in a frame's payload upon request.
609+
*/
610+
#ifndef NRF_802154_TX_TIMESTAMP_PROVIDER_ENABLED
611+
#define NRF_802154_TX_TIMESTAMP_PROVIDER_ENABLED 0
612+
#endif
613+
614+
/**
615+
* @}
616+
* @defgroup nrf_802154_tx_misc Miscellaneous options
617+
* @{
618+
*/
619+
620+
/**
621+
* @def NRF_802154_TX_DIAGNOSTIC_MODE
622+
*
623+
* Disables strict frame validation.
624+
*
625+
* When this option is disabled the nRF 802.154 Radio Driver performs strict frame format
626+
* validation of any frame that is to be transmitted. Frames that do not conform
627+
* the IEEE 802.15.4 MAC frame format will be discarded on transmit attempts.
628+
*
629+
* When this option is enabled the validation of frame format is disabled what allows for
630+
* sending arbitrary frames. The functionality set of the radio driver is reduced.
631+
* The IE writer, security writer, encryption, and TX timestamp modules cannot be used.
632+
*/
633+
#ifndef NRF_802154_TX_DIAGNOSTIC_MODE
634+
#define NRF_802154_TX_DIAGNOSTIC_MODE 0
635+
#endif
636+
637+
#if NRF_802154_TX_DIAGNOSTIC_MODE
638+
#if NRF_802154_IE_WRITER_ENABLED || \
639+
NRF_802154_SECURITY_WRITER_ENABLED || \
640+
NRF_802154_ENCRYPTION_ENABLED || \
641+
NRF_802154_TX_TIMESTAMP_PROVIDER_ENABLED
642+
#error "TX Diagnostic mode is not compatible with IE writer, Security writer, Encryption, and TX timestamp."
643+
#endif
644+
#endif
645+
598646
/** @} */
599647

600648
/**

drivers/nrf_802154/common/include/nrf_802154_types.h

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,17 @@ typedef uint8_t nrf_802154_state_t;
8181
*/
8282
typedef uint8_t nrf_802154_tx_error_t;
8383

84-
#define NRF_802154_TX_ERROR_NONE 0x00 // !< There is no transmit error.
85-
#define NRF_802154_TX_ERROR_BUSY_CHANNEL 0x01 // !< CCA reported busy channel before the transmission.
86-
#define NRF_802154_TX_ERROR_INVALID_ACK 0x02 // !< Received ACK frame is other than expected.
87-
#define NRF_802154_TX_ERROR_NO_MEM 0x03 // !< No receive buffer is available to receive an ACK.
88-
#define NRF_802154_TX_ERROR_TIMESLOT_ENDED 0x04 // !< Radio timeslot ended during the transmission procedure.
89-
#define NRF_802154_TX_ERROR_NO_ACK 0x05 // !< ACK frame was not received during the timeout period.
90-
#define NRF_802154_TX_ERROR_ABORTED 0x06 // !< Procedure was aborted by another operation.
91-
#define NRF_802154_TX_ERROR_TIMESLOT_DENIED 0x07 // !< Transmission did not start due to a denied timeslot request.
92-
#define NRF_802154_TX_ERROR_KEY_ID_INVALID 0x08 // !< Transmission did not start due to invalid key ID in frame's security header.
93-
#define NRF_802154_TX_ERROR_FRAME_COUNTER_ERROR 0x09 // !< Transmission did not start due a frame counter error.
84+
#define NRF_802154_TX_ERROR_NONE 0x00 // !< There is no transmit error.
85+
#define NRF_802154_TX_ERROR_BUSY_CHANNEL 0x01 // !< CCA reported busy channel before the transmission.
86+
#define NRF_802154_TX_ERROR_INVALID_ACK 0x02 // !< Received ACK frame is other than expected.
87+
#define NRF_802154_TX_ERROR_NO_MEM 0x03 // !< No receive buffer is available to receive an ACK.
88+
#define NRF_802154_TX_ERROR_TIMESLOT_ENDED 0x04 // !< Radio timeslot ended during the transmission procedure.
89+
#define NRF_802154_TX_ERROR_NO_ACK 0x05 // !< ACK frame was not received during the timeout period.
90+
#define NRF_802154_TX_ERROR_ABORTED 0x06 // !< Procedure was aborted by another operation.
91+
#define NRF_802154_TX_ERROR_TIMESLOT_DENIED 0x07 // !< Transmission did not start due to a denied timeslot request.
92+
#define NRF_802154_TX_ERROR_KEY_ID_INVALID 0x08 // !< Transmission did not start due to invalid key ID in frame's security header.
93+
#define NRF_802154_TX_ERROR_FRAME_COUNTER_ERROR 0x09 // !< Transmission did not start due a frame counter error.
94+
#define NRF_802154_TX_ERROR_TIMESTAMP_ENCODING_ERROR 0x0A // !< Timestamp could not been encoded in the transmission process.
9495

9596
/**
9697
* @brief Possible errors during the frame reception.
@@ -442,6 +443,7 @@ typedef struct
442443
bool cca; // !< If the driver is to perform a CCA procedure before transmission.
443444
nrf_802154_tx_power_metadata_t tx_power; // !< Information about the TX power to be used.
444445
nrf_802154_tx_channel_metadata_t tx_channel; // !< Information about the TX channel to be used.
446+
bool tx_timestamp_encode; // !< True if the transmit timestamp shall be encoded in the payload.
445447
} nrf_802154_transmit_metadata_t;
446448

447449
/**
@@ -454,6 +456,7 @@ typedef struct
454456
uint8_t channel; // !< Radio channel on which the frame is to be transmitted.
455457
nrf_802154_tx_power_metadata_t tx_power; // !< Information about the TX power to be used.
456458
uint8_t extra_cca_attempts; // !< Maximum number of additional CCA attempts that can be performed if the first attempt returns busy channel. Ignored if @ref cca equals @c false.
459+
bool tx_timestamp_encode; // !< True if the transmit timestamp shall be encoded in the payload.
457460
} nrf_802154_transmit_at_metadata_t;
458461

459462
/**
@@ -464,6 +467,7 @@ typedef struct
464467
nrf_802154_transmitted_frame_props_t frame_props; // !< Properties of the frame to be transmitted.
465468
nrf_802154_tx_power_metadata_t tx_power; // !< Information about the TX power to be used.
466469
nrf_802154_tx_channel_metadata_t tx_channel; // !< Information about the TX channel to be used.
470+
bool tx_timestamp_encode; // !< True if the transmit timestamp shall be encoded in the payload.
467471
} nrf_802154_transmit_csma_ca_metadata_t;
468472

469473
/**
@@ -489,14 +493,6 @@ typedef struct
489493
} data; // !< Result values that are valid only for successful operations.
490494
} nrf_802154_transmit_done_metadata_t;
491495

492-
/**
493-
* @brief Function pointer used for notifying about transmission failure.
494-
*/
495-
typedef void (* nrf_802154_transmit_failed_notification_t)(
496-
uint8_t * p_frame,
497-
nrf_802154_tx_error_t error,
498-
const nrf_802154_transmit_done_metadata_t * p_meta);
499-
500496
/**
501497
* @brief Structure that holds results of energy detection procedure.
502498
*/

drivers/nrf_802154/driver/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ 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
77+
src/mac_features/nrf_802154_imm_tx.c
7878
src/mac_features/nrf_802154_security_pib_ram.c
7979
src/mac_features/nrf_802154_security_writer.c
8080
src/mac_features/nrf_802154_precise_ack_timeout.c
81+
src/mac_features/nrf_802154_tx_timestamp_provider.c
8182
src/mac_features/ack_generator/nrf_802154_ack_data.c
8283
src/mac_features/ack_generator/nrf_802154_ack_generator.c
8384
src/mac_features/ack_generator/nrf_802154_enh_ack_generator.c

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include "nrf_802154_assert.h"
4545
#include <string.h>
4646

47-
#include "mac_features/nrf_802154_frame_parser.h"
47+
#include "mac_features/nrf_802154_frame.h"
4848
#include "nrf_802154_config.h"
4949
#include "nrf_802154_const.h"
5050

@@ -333,11 +333,11 @@ static bool addr_index_find(const uint8_t * p_addr,
333333
* @retval true Pending bit is to be set.
334334
* @retval false Pending bit is to be cleared.
335335
*/
336-
static bool addr_match_thread(const nrf_802154_frame_parser_data_t * p_frame_data)
336+
static bool addr_match_thread(const nrf_802154_frame_t * p_frame_data)
337337
{
338338
uint32_t location;
339-
bool extended = nrf_802154_frame_parser_src_addr_is_extended(p_frame_data);
340-
const uint8_t * p_src_addr = nrf_802154_frame_parser_src_addr_get(p_frame_data);
339+
bool extended = nrf_802154_frame_src_addr_is_extended(p_frame_data);
340+
const uint8_t * p_src_addr = nrf_802154_frame_src_addr_get(p_frame_data);
341341

342342
// The pending bit is set by default.
343343
if (!m_pending_bit.enabled || (NULL == p_src_addr))
@@ -356,7 +356,7 @@ static bool addr_match_thread(const nrf_802154_frame_parser_data_t * p_frame_dat
356356
* @retval true Pending bit is to be set.
357357
* @retval false Pending bit is to be cleared.
358358
*/
359-
static bool addr_match_zigbee(const nrf_802154_frame_parser_data_t * p_frame_data)
359+
static bool addr_match_zigbee(const nrf_802154_frame_t * p_frame_data)
360360
{
361361
uint8_t src_addr_type;
362362
uint32_t location;
@@ -371,10 +371,10 @@ static bool addr_match_zigbee(const nrf_802154_frame_parser_data_t * p_frame_dat
371371
}
372372

373373
// Check the frame type.
374-
p_src_addr = nrf_802154_frame_parser_src_addr_get(p_frame_data);
375-
src_addr_type = nrf_802154_frame_parser_src_addr_type_get(p_frame_data);
374+
p_src_addr = nrf_802154_frame_src_addr_get(p_frame_data);
375+
src_addr_type = nrf_802154_frame_src_addr_type_get(p_frame_data);
376376

377-
p_cmd = nrf_802154_frame_parser_mac_command_id_get(p_frame_data);
377+
p_cmd = nrf_802154_frame_mac_command_id_get(p_frame_data);
378378

379379
// Check frame type and command type.
380380
if ((p_cmd != NULL) && (*p_cmd == MAC_CMD_DATA_REQ))
@@ -407,7 +407,7 @@ static bool addr_match_zigbee(const nrf_802154_frame_parser_data_t * p_frame_dat
407407
*
408408
* @retval true Pending bit is to be set.
409409
*/
410-
static bool addr_match_standard_compliant(const nrf_802154_frame_parser_data_t * p_frame_data)
410+
static bool addr_match_standard_compliant(const nrf_802154_frame_t * p_frame_data)
411411
{
412412
(void)p_frame_data;
413413
return true;
@@ -597,18 +597,18 @@ static bool ie_data_set(uint32_t location, bool extended, const uint8_t * p_data
597597
ie_data_t * ie_data =
598598
extended ? &m_ie.ext_data[location].ie_data : &m_ie.short_data[location].ie_data;
599599

600-
const uint8_t new_ie_id = nrf_802154_frame_parser_ie_id_get(p_data);
600+
const uint8_t new_ie_id = nrf_802154_frame_ie_id_get(p_data);
601601

602-
for (const uint8_t * ie = nrf_802154_frame_parser_header_ie_iterator_begin(ie_data->p_data);
603-
nrf_802154_frame_parser_ie_iterator_end(ie, ie_data->p_data + ie_data->len) == false;
604-
ie = nrf_802154_frame_parser_ie_iterator_next(ie))
602+
for (const uint8_t * ie = nrf_802154_frame_header_ie_iterator_begin(ie_data->p_data);
603+
nrf_802154_frame_ie_iterator_end(ie, ie_data->p_data + ie_data->len) == false;
604+
ie = nrf_802154_frame_ie_iterator_next(ie))
605605
{
606-
if (nrf_802154_frame_parser_ie_id_get(ie) != new_ie_id)
606+
if (nrf_802154_frame_ie_id_get(ie) != new_ie_id)
607607
{
608608
continue;
609609
}
610610

611-
if (IE_DATA_OFFSET + nrf_802154_frame_parser_ie_length_get(ie) != data_len)
611+
if (IE_DATA_OFFSET + nrf_802154_frame_ie_length_get(ie) != data_len)
612612
{
613613
/* Overwriting an existing IE with a different size is not supported. */
614614
return false;
@@ -738,7 +738,7 @@ void nrf_802154_ack_data_src_addr_matching_method_set(nrf_802154_src_addr_match_
738738
}
739739

740740
bool nrf_802154_ack_data_pending_bit_should_be_set(
741-
const nrf_802154_frame_parser_data_t * p_frame_data)
741+
const nrf_802154_frame_t * p_frame_data)
742742
{
743743
bool ret;
744744

drivers/nrf_802154/driver/src/mac_features/ack_generator/nrf_802154_ack_data.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include <stdint.h>
4646

4747
#include "nrf_802154_types.h"
48-
#include "mac_features/nrf_802154_frame_parser.h"
48+
#include "mac_features/nrf_802154_frame.h"
4949

5050
/**
5151
* @brief Initializes the ACK data generator module.
@@ -130,7 +130,7 @@ void nrf_802154_ack_data_src_addr_matching_method_set(nrf_802154_src_addr_match_
130130
* @retval false Pending bit is to be cleared.
131131
*/
132132
bool nrf_802154_ack_data_pending_bit_should_be_set(
133-
const nrf_802154_frame_parser_data_t * p_frame_data);
133+
const nrf_802154_frame_t * p_frame_data);
134134

135135
/**
136136
* @brief Gets the IE data stored in the list for the source address of the provided frame.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ typedef enum
5454
} frame_version_t;
5555

5656
static frame_version_t frame_version_is_2015_or_above(
57-
const nrf_802154_frame_parser_data_t * p_frame_data)
57+
const nrf_802154_frame_t * p_frame_data)
5858
{
59-
switch (nrf_802154_frame_parser_frame_version_get(p_frame_data))
59+
switch (nrf_802154_frame_version_get(p_frame_data))
6060
{
6161
case FRAME_VERSION_0:
6262
case FRAME_VERSION_1:
@@ -84,10 +84,10 @@ void nrf_802154_ack_generator_reset(void)
8484
nrf_802154_enh_ack_generator_reset();
8585
}
8686

87-
uint8_t * nrf_802154_ack_generator_create(const nrf_802154_frame_parser_data_t * p_frame_data)
87+
uint8_t * nrf_802154_ack_generator_create(const nrf_802154_frame_t * p_frame_data)
8888
{
8989
// This function should not be called if ACK is not requested.
90-
NRF_802154_ASSERT(nrf_802154_frame_parser_ar_bit_is_set(p_frame_data));
90+
NRF_802154_ASSERT(nrf_802154_frame_ar_bit_is_set(p_frame_data));
9191

9292
switch (frame_version_is_2015_or_above(p_frame_data))
9393
{

drivers/nrf_802154/driver/src/mac_features/ack_generator/nrf_802154_ack_generator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#include <stdint.h>
4444

45-
#include "mac_features/nrf_802154_frame_parser.h"
45+
#include "mac_features/nrf_802154_frame.h"
4646

4747
/** Initializes the ACK generator module. */
4848
void nrf_802154_ack_generator_init(void);
@@ -69,6 +69,6 @@ void nrf_802154_ack_generator_reset(void);
6969
* of the created ACK frame, or NULL when the response cannot be created.
7070
*/
7171
uint8_t * nrf_802154_ack_generator_create(
72-
const nrf_802154_frame_parser_data_t * p_frame_data);
72+
const nrf_802154_frame_t * p_frame_data);
7373

7474
#endif // NRF_802154_ACK_GENERATOR_H

0 commit comments

Comments
 (0)